Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f545d23

Browse files
committed
Use a separate temporary directory for the Unix-domain socket
Creating the Unix-domain socket in the build directory can run into name-length limitations. Therefore, create the socket file in the default temporary directory of the operating system. Keep the temporary data directory etc. in the build tree.
1 parent 0490db6 commit f545d23

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/bin/pg_ctl/t/001_start_stop.pl

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Test::More tests => 10;
55

66
my $tempdir = TestLib::tempdir;
7+
my $tempdir_short = TestLib::tempdir_short;
78

89
program_help_ok('pg_ctl');
910
program_version_ok('pg_ctl');
@@ -12,7 +13,7 @@
1213
command_ok([ 'pg_ctl', 'initdb', '-D', "$tempdir/data" ], 'pg_ctl initdb');
1314
open CONF, ">>$tempdir/data/postgresql.conf";
1415
print CONF "listen_addresses = ''\n";
15-
print CONF "unix_socket_directories = '$tempdir'\n";
16+
print CONF "unix_socket_directories = '$tempdir_short'\n";
1617
close CONF;
1718
command_ok([ 'pg_ctl', 'start', '-D', "$tempdir/data", '-w' ],
1819
'pg_ctl start -w');

src/bin/pg_ctl/t/002_status.pl

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
use Test::More tests => 2;
55

66
my $tempdir = TestLib::tempdir;
7+
my $tempdir_short = TestLib::tempdir_short;
78

89
system_or_bail "initdb -D $tempdir/data -A trust >/dev/null";
910
open CONF, ">>$tempdir/data/postgresql.conf";
1011
print CONF "listen_addresses = ''\n";
11-
print CONF "unix_socket_directories = '$tempdir'\n";
12+
print CONF "unix_socket_directories = '$tempdir_short'\n";
1213
close CONF;
1314

1415
command_exit_is([ 'pg_ctl', 'status', '-D', "$tempdir/data" ],

src/test/perl/TestLib.pm

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use warnings;
66
use Exporter 'import';
77
our @EXPORT = qw(
88
tempdir
9+
tempdir_short
910
start_test_server
1011
restart_test_server
1112
psql
@@ -65,17 +66,26 @@ sub tempdir
6566
return File::Temp::tempdir('tmp_testXXXX', DIR => $ENV{TESTDIR} || cwd(), CLEANUP => 1);
6667
}
6768

69+
sub tempdir_short
70+
{
71+
# Use a separate temp dir outside the build tree for the
72+
# Unix-domain socket, to avoid file name length issues.
73+
return File::Temp::tempdir(CLEANUP => 1);
74+
}
75+
6876
my ($test_server_datadir, $test_server_logfile);
6977

7078
sub start_test_server
7179
{
7280
my ($tempdir) = @_;
7381
my $ret;
7482

83+
my $tempdir_short = tempdir_short;
84+
7585
system "initdb -D $tempdir/pgdata -A trust -N >/dev/null";
7686
$ret = system 'pg_ctl', '-D', "$tempdir/pgdata", '-s', '-w', '-l',
7787
"$tempdir/logfile", '-o',
78-
"--fsync=off -k $tempdir --listen-addresses='' --log-statement=all",
88+
"--fsync=off -k $tempdir_short --listen-addresses='' --log-statement=all",
7989
'start';
8090

8191
if ($ret != 0)
@@ -84,7 +94,7 @@ sub start_test_server
8494
BAIL_OUT("pg_ctl failed");
8595
}
8696

87-
$ENV{PGHOST} = $tempdir;
97+
$ENV{PGHOST} = $tempdir_short;
8898
$test_server_datadir = "$tempdir/pgdata";
8999
$test_server_logfile = "$tempdir/logfile";
90100
}

0 commit comments

Comments
 (0)