src/ports/pgcheckdir.c - Ignore dot directories... - Mailing list pgsql-hackers

From Sean Chittenden
Subject src/ports/pgcheckdir.c - Ignore dot directories...
Date
Msg-id A37DC83F-75AA-4850-8261-AD16B104F044@chittenden.org
Whole thread Raw
Responses Re: src/ports/pgcheckdir.c - Ignore dot directories...  (Craig Ringer <craig@2ndquadrant.com>)
Re: src/ports/pgcheckdir.c - Ignore dot directories...  (Kevin Grittner <kgrittn@ymail.com>)
List pgsql-hackers
Hello. This was bounced my way via IRC[1] and I'm kicking an updated version of the patch upstream for review and
committing.

Currently src/port/pgcheckdir.c will reject non-empty directories, which is an issue during initdb(1) when PGDATA is
alsothe mount point for filesystems that support snapshots (e.g. ZFS or UFS2). The original patch to the FreeBSD ports
teamexcluded ".snap", but this seems limited. 

Instead, it seems more correct to simply ignore all directories that begin with a dot character. I'm not aware of any
specialdirectories exposed by filesystems that aren't dot directories so this seems like a relatively futureproof
solution,too. 

Granted it's not hard to create a subdirectory, initdb there and move the contents of the files around, it's extra work
thatshouldn't be required. By UNIX convention, files/directories beginning with a dot are hidden anyway, and since
PostgreSQLisn't using or creating any dot files or directories, this seems like the right trade off in usability. 

Here's a quick reproduction of the problem along with the patch.



Thanks in advance. -sc


> # zfs create tank/tmp/pginit-test
> # zfs set snapdir=visible tank/tmp/pginit-test
> # ll
> total 0
> dr-xr-xr-x  4 root  wheel  4 Feb  5 08:17 .zfs/
> # su - pgsql
> $ initdb -D /tmp/pginit-test
> The files belonging to this database system will be owned by user "pgsql".
> This user must also own the server process.
>
> The database cluster will be initialized with locale "C".
> The default database encoding has accordingly been set to "SQL_ASCII".
> The default text search configuration will be set to "english".
>
> initdb: directory "/tmp/pginit-test" exists but is not empty
> If you want to create a new database system, either remove or empty
> the directory "/tmp/pginit-test" or run initdb
> with an argument other than "/tmp/pginit-test".

[1] http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/174020


--
Sean Chittenden
sean@chittenden.org


Attachment

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: json api WIP patch
Next
From: Craig Ringer
Date:
Subject: Re: src/ports/pgcheckdir.c - Ignore dot directories...