Skip site navigation (1) Skip section navigation (2)

pgsql: Fix a number of places that were making file-type tests

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix a number of places that were making file-type tests
Date: 2008-03-31 01:32:01
Message-ID: 20080331013201.8930B7558E8@cvs.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
Fix a number of places that were making file-type tests infelicitously.
The places that did, eg,
	(statbuf.st_mode & S_IFMT) == S_IFDIR
were correct, but there is no good reason not to use S_ISDIR() instead,
especially when that's what the other 90% of our code does.  The places
that did, eg,
	(statbuf.st_mode & S_IFDIR)
were flat out *wrong* and would fail in various platform-specific ways,
eg a symlink could be mistaken for a regular file on most Unixen.

The actual impact of this is probably small, since the problem cases
seem to always involve symlinks or sockets, which are unlikely to be
found in the directories that PG code might be scanning.  But it's
clearly trouble waiting to happen, so patch all the way back anyway.
(There seem to be no occurrences of the mistake in 7.4.)

Tags:
----
REL8_3_STABLE

Modified Files:
--------------
    pgsql/src/backend/utils/adt:
        dbsize.c (r1.16 -> r1.16.2.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/dbsize.c?r1=1.16&r2=1.16.2.1)
        genfile.c (r1.17 -> r1.17.2.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/genfile.c?r1=1.17&r2=1.17.2.1)
    pgsql/src/port:
        copydir.c (r1.21 -> r1.21.2.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/port/copydir.c?r1=1.21&r2=1.21.2.1)
        exec.c (r1.57.2.1 -> r1.57.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/port/exec.c?r1=1.57.2.1&r2=1.57.2.2)
    pgsql/src/test/regress:
        pg_regress.c (r1.41.2.1 -> r1.41.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/pg_regress.c?r1=1.41.2.1&r2=1.41.2.2)

pgsql-committers by date

Next:From: Tom LaneDate: 2008-03-31 01:32:17
Subject: pgsql: Fix a number of places that were making file-type tests
Previous:From: Tom LaneDate: 2008-03-31 01:31:43
Subject: pgsql: Fix a number of places that were making file-type tests

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group