Skip to content

[pull] master from postgres:master #954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/backend/libpq/be-secure-gssapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ be_gssapi_write(Port *port, const void *ptr, size_t len)
* again, so if it offers a len less than that, something is wrong.
*
* Note: it may seem attractive to report partial write completion once
* we've successfully sent any encrypted packets. However, that can cause
* problems for callers; notably, pqPutMsgEnd's heuristic to send only
* full 8K blocks interacts badly with such a hack. We won't save much,
* we've successfully sent any encrypted packets. However, doing that
* expands the state space of this processing and has been responsible for
* bugs in the past (cf. commit d053a879b). We won't save much,
* typically, by letting callers discard data early, so don't risk it.
*/
if (len < PqGSSSendConsumed)
Expand Down
5 changes: 3 additions & 2 deletions src/bin/psql/tab-complete.in.c
Original file line number Diff line number Diff line change
Expand Up @@ -3664,9 +3664,10 @@ match_previous_words(int pattern_id,
TailMatches("CREATE", "TEMP|TEMPORARY|UNLOGGED", "TABLE", MatchAny, "(*)", "AS"))
COMPLETE_WITH("EXECUTE", "SELECT", "TABLE", "VALUES", "WITH");
/* Complete CREATE TABLE name (...) with supported options */
else if (TailMatches("CREATE", "TABLE", MatchAny, "(*)") ||
TailMatches("CREATE", "UNLOGGED", "TABLE", MatchAny, "(*)"))
else if (TailMatches("CREATE", "TABLE", MatchAny, "(*)"))
COMPLETE_WITH("AS", "INHERITS (", "PARTITION BY", "USING", "TABLESPACE", "WITH (");
else if (TailMatches("CREATE", "UNLOGGED", "TABLE", MatchAny, "(*)"))
COMPLETE_WITH("AS", "INHERITS (", "USING", "TABLESPACE", "WITH (");
else if (TailMatches("CREATE", "TEMP|TEMPORARY", "TABLE", MatchAny, "(*)"))
COMPLETE_WITH("AS", "INHERITS (", "ON COMMIT", "PARTITION BY", "USING",
"TABLESPACE", "WITH (");
Expand Down
28 changes: 27 additions & 1 deletion src/interfaces/libpq/fe-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,35 @@ pqPutMsgEnd(PGconn *conn)
/* Make message eligible to send */
conn->outCount = conn->outMsgEnd;

/* If appropriate, try to push out some data */
if (conn->outCount >= 8192)
{
int toSend = conn->outCount - (conn->outCount % 8192);
int toSend = conn->outCount;

/*
* On Unix-pipe connections, it seems profitable to prefer sending
* pipe-buffer-sized packets not randomly-sized ones, so retain the
* last partial-8K chunk in our buffer for now. On TCP connections,
* the advantage of that is far less clear. Moreover, it flat out
* isn't safe when using SSL or GSSAPI, because those code paths have
* API stipulations that if they fail to send all the data that was
* offered in the previous write attempt, we mustn't offer less data
* in this write attempt. The previous write attempt might've been
* pqFlush attempting to send everything in the buffer, so we mustn't
* offer less now. (Presently, we won't try to use SSL or GSSAPI on
* Unix connections, so those checks are just Asserts. They'll have
* to become part of the regular if-test if we ever change that.)
*/
if (conn->raddr.addr.ss_family == AF_UNIX)
{
#ifdef USE_SSL
Assert(!conn->ssl_in_use);
#endif
#ifdef ENABLE_GSS
Assert(!conn->gssenc);
#endif
toSend -= toSend % 8192;
}

if (pqSendSome(conn, toSend) < 0)
return EOF;
Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/libpq/fe-secure-gssapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ pg_GSS_write(PGconn *conn, const void *ptr, size_t len)
* again, so if it offers a len less than that, something is wrong.
*
* Note: it may seem attractive to report partial write completion once
* we've successfully sent any encrypted packets. However, that can cause
* problems for callers; notably, pqPutMsgEnd's heuristic to send only
* full 8K blocks interacts badly with such a hack. We won't save much,
* we've successfully sent any encrypted packets. However, doing that
* expands the state space of this processing and has been responsible for
* bugs in the past (cf. commit d053a879b). We won't save much,
* typically, by letting callers discard data early, so don't risk it.
*/
if (len < PqGSSSendConsumed)
Expand Down