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 also the mount point for filesystems that 
support snapshots (e.g. ZFS or UFS2). The original patch to the FreeBSD ports 
team excluded ".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 special directories 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 that shouldn't be required. By 
UNIX convention, files/directories beginning with a dot are hidden anyway, and 
since PostgreSQL isn'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.

Attachment: src-port-pgcheckdir.c.patch
Description: Binary data


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
s...@chittenden.org

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to