Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita9cff89

Browse files
committed
Allow building without default socket directory
We have code paths for Unix socket support and no Unix socket support.Now add a third variant: Unix socket support but do not use a Unixsocket by default in the client or the server, only if you explicitlyspecify one. This will be useful when we enable Unix socket supporton Windows.To implement this, tweak things so that setting DEFAULT_PGSOCKET_DIRto "" has the desired effect. This mostly already worked like that;only a few places needed to be adjusted. Notably, the reference toDEFAULT_PGSOCKET_DIR in UNIXSOCK_PATH() could be removed because allcallers already resolve an empty socket directory setting with adefault if appropriate.Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://www.postgresql.org/message-id/75f72249-8ae6-322a-63df-4fe03eeccb9f@2ndquadrant.com
1 parent7c23bfd commita9cff89

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

‎src/include/libpq/pqcomm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ typedef struct
6868
/* Configure the UNIX socket location for the well known port. */
6969

7070
#defineUNIXSOCK_PATH(path,port,sockdir) \
71+
(AssertMacro(sockdir), \
72+
AssertMacro(*(sockdir) != '\0'), \
7173
snprintf(path, sizeof(path), "%s/.s.PGSQL.%d", \
72-
((sockdir) && *(sockdir) != '\0') ? (sockdir) : \
73-
DEFAULT_PGSOCKET_DIR, \
74-
(port))
74+
(sockdir), (port)))
7575

7676
/*
7777
* The maximum workable length of a socket path is what will fit into

‎src/include/pg_config_manual.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@
191191
* directory. But if you just hate the idea of sockets in /tmp,
192192
* here's where to twiddle it. You can also override this at runtime
193193
* with the postmaster's -k switch.
194+
*
195+
* If set to an empty string, then AF_UNIX sockets are not used by default: A
196+
* server will not create an AF_UNIX socket unless the run-time configuration
197+
* is changed, a client will connect via TCP/IP by default and will only use
198+
* an AF_UNIX socket if one is explicitly specified.
194199
*/
195200
#defineDEFAULT_PGSOCKET_DIR "/tmp"
196201

‎src/interfaces/libpq/fe-connect.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,12 +1095,17 @@ connectOptions2(PGconn *conn)
10951095
if (ch->host)
10961096
free(ch->host);
10971097
#ifdefHAVE_UNIX_SOCKETS
1098-
ch->host=strdup(DEFAULT_PGSOCKET_DIR);
1099-
ch->type=CHT_UNIX_SOCKET;
1100-
#else
1101-
ch->host=strdup(DefaultHost);
1102-
ch->type=CHT_HOST_NAME;
1098+
if (DEFAULT_PGSOCKET_DIR[0])
1099+
{
1100+
ch->host=strdup(DEFAULT_PGSOCKET_DIR);
1101+
ch->type=CHT_UNIX_SOCKET;
1102+
}
1103+
else
11031104
#endif
1105+
{
1106+
ch->host=strdup(DefaultHost);
1107+
ch->type=CHT_HOST_NAME;
1108+
}
11041109
if (ch->host==NULL)
11051110
gotooom_error;
11061111
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp