Skip to content

[pull] master from postgres:master #988

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 3 commits into from
Jun 24, 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
2 changes: 1 addition & 1 deletion doc/src/sgml/func.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -14384,7 +14384,7 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
<sect1 id="functions-uuid">
<title>UUID Functions</title>

<indexterm zone="datatype-uuid">
<indexterm zone="functions-uuid">
<primary>UUID</primary>
<secondary>generating</secondary>
</indexterm>
Expand Down
8 changes: 4 additions & 4 deletions doc/src/sgml/ref/psql-ref.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,8 @@ INSERT INTO tbls1 VALUES ($1, $2) \parse stmt1
</listitem>
</varlistentry>

<varlistentry id="app-psql-meta-command-close">
<term><literal>\close</literal> <replaceable class="parameter">prepared_statement_name</replaceable></term>
<varlistentry id="app-psql-meta-command-close-prepared">
<term><literal>\close_prepared</literal> <replaceable class="parameter">prepared_statement_name</replaceable></term>

<listitem>
<para>
Expand All @@ -1081,7 +1081,7 @@ INSERT INTO tbls1 VALUES ($1, $2) \parse stmt1
Example:
<programlisting>
SELECT $1 \parse stmt1
\close stmt1
\close_prepared stmt1
</programlisting>
</para>

Expand Down Expand Up @@ -3710,7 +3710,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
All queries executed while a pipeline is ongoing use the extended
query protocol. Queries are appended to the pipeline when ending with
a semicolon. The meta-commands <literal>\bind</literal>,
<literal>\bind_named</literal>, <literal>\close</literal> or
<literal>\bind_named</literal>, <literal>\close_prepared</literal> or
<literal>\parse</literal> can be used in an ongoing pipeline. While
a pipeline is ongoing, <literal>\sendpipeline</literal> will append
the current query buffer to the pipeline. Other meta-commands like
Expand Down
2 changes: 1 addition & 1 deletion doc/src/sgml/release-18.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -2746,7 +2746,7 @@ Author: Michael Paquier <[email protected]>
<link
linkend="app-psql-meta-command-bind-named"><literal>\bind_named</literal></link>,
and <link
linkend="app-psql-meta-command-close"><literal>\close</literal></link>.
linkend="app-psql-meta-command-close-prepared"><literal>\close_prepared</literal></link>.
</para>
</listitem>

Expand Down
7 changes: 0 additions & 7 deletions src/backend/replication/logical/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@
* If ever a user needs to be aware of the tri-state value, they can fetch it
* from the pg_subscription catalog (see column subtwophasestate).
*
* We don't allow to toggle two_phase option of a subscription because it can
* lead to an inconsistent replica. Consider, initially, it was on and we have
* received some prepare then we turn it off, now at commit time the server
* will send the entire transaction data along with the commit. With some more
* analysis, we can allow changing this option from off to on but not sure if
* that alone would be useful.
*
* Finally, to avoid problems mentioned in previous paragraphs from any
* subsequent (not READY) tablesyncs (need to toggle two_phase option from 'on'
* to 'off' and then again back to 'on') there is a restriction for
Expand Down
12 changes: 6 additions & 6 deletions src/bin/psql/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ static backslashResult exec_command_C(PsqlScanState scan_state, bool active_bran
static backslashResult exec_command_connect(PsqlScanState scan_state, bool active_branch);
static backslashResult exec_command_cd(PsqlScanState scan_state, bool active_branch,
const char *cmd);
static backslashResult exec_command_close(PsqlScanState scan_state, bool active_branch,
const char *cmd);
static backslashResult exec_command_close_prepared(PsqlScanState scan_state,
bool active_branch, const char *cmd);
static backslashResult exec_command_conninfo(PsqlScanState scan_state, bool active_branch);
static backslashResult exec_command_copy(PsqlScanState scan_state, bool active_branch);
static backslashResult exec_command_copyright(PsqlScanState scan_state, bool active_branch);
Expand Down Expand Up @@ -330,8 +330,8 @@ exec_command(const char *cmd,
status = exec_command_connect(scan_state, active_branch);
else if (strcmp(cmd, "cd") == 0)
status = exec_command_cd(scan_state, active_branch, cmd);
else if (strcmp(cmd, "close") == 0)
status = exec_command_close(scan_state, active_branch, cmd);
else if (strcmp(cmd, "close_prepared") == 0)
status = exec_command_close_prepared(scan_state, active_branch, cmd);
else if (strcmp(cmd, "conninfo") == 0)
status = exec_command_conninfo(scan_state, active_branch);
else if (pg_strcasecmp(cmd, "copy") == 0)
Expand Down Expand Up @@ -728,10 +728,10 @@ exec_command_cd(PsqlScanState scan_state, bool active_branch, const char *cmd)
}

/*
* \close -- close a previously prepared statement
* \close_prepared -- close a previously prepared statement
*/
static backslashResult
exec_command_close(PsqlScanState scan_state, bool active_branch, const char *cmd)
exec_command_close_prepared(PsqlScanState scan_state, bool active_branch, const char *cmd)
{
backslashResult status = PSQL_CMD_SKIP_LINE;

Expand Down
2 changes: 1 addition & 1 deletion src/bin/psql/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,7 @@ clean_extended_state(void)

switch (pset.send_mode)
{
case PSQL_SEND_EXTENDED_CLOSE: /* \close */
case PSQL_SEND_EXTENDED_CLOSE: /* \close_prepared */
free(pset.stmtName);
break;
case PSQL_SEND_EXTENDED_PARSE: /* \parse */
Expand Down
3 changes: 2 additions & 1 deletion src/bin/psql/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ slashUsage(unsigned short int pager)
HELP0(" \\bind [PARAM]... set query parameters\n");
HELP0(" \\bind_named STMT_NAME [PARAM]...\n"
" set query parameters for an existing prepared statement\n");
HELP0(" \\close STMT_NAME close an existing prepared statement\n");
HELP0(" \\close_prepared STMT_NAME\n"
" close an existing prepared statement\n");
HELP0(" \\endpipeline exit pipeline mode\n");
HELP0(" \\flush flush output data to the server\n");
HELP0(" \\flushrequest send request to the server to flush its output buffer\n");
Expand Down
2 changes: 1 addition & 1 deletion src/bin/psql/tab-complete.in.c
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ psql_completion(const char *text, int start, int end)
static const char *const backslash_commands[] = {
"\\a",
"\\bind", "\\bind_named",
"\\connect", "\\conninfo", "\\C", "\\cd", "\\close", "\\copy",
"\\connect", "\\conninfo", "\\C", "\\cd", "\\close_prepared", "\\copy",
"\\copyright", "\\crosstabview",
"\\d", "\\da", "\\dA", "\\dAc", "\\dAf", "\\dAo", "\\dAp",
"\\db", "\\dc", "\\dconfig", "\\dC", "\\dd", "\\ddp", "\\dD",
Expand Down
14 changes: 7 additions & 7 deletions src/test/regress/expected/psql.out
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ LINE 1: SELECT $1, $2
foo4 | bar4
(1 row)

-- \close (extended query protocol)
\close
\close: missing required argument
\close ''
\close stmt2
\close stmt2
-- \close_prepared (extended query protocol)
\close_prepared
\close_prepared: missing required argument
\close_prepared ''
\close_prepared stmt2
\close_prepared stmt2
SELECT name, statement FROM pg_prepared_statements ORDER BY name;
name | statement
-------+----------------
Expand Down Expand Up @@ -4666,7 +4666,7 @@ bar 'bar' "bar"
\C arg1
\c arg1 arg2 arg3 arg4
\cd arg1
\close stmt1
\close_prepared stmt1
\conninfo
\copy arg1 arg2 arg3 arg4 arg5 arg6
\copyright
Expand Down
6 changes: 3 additions & 3 deletions src/test/regress/expected/psql_pipeline.out
Original file line number Diff line number Diff line change
Expand Up @@ -564,23 +564,23 @@ SELECT $1 \bind \sendpipeline
SELECT $1 \bind 1 \sendpipeline
SELECT $1 \parse a
\bind_named a 1 \sendpipeline
\close a
\close_prepared a
\flushrequest
\getresults
ERROR: bind message supplies 0 parameters, but prepared statement "" requires 1
-- Pipeline is aborted.
SELECT $1 \bind 1 \sendpipeline
SELECT $1 \parse a
\bind_named a 1 \sendpipeline
\close a
\close_prepared a
-- Sync allows pipeline to recover.
\syncpipeline
\getresults
Pipeline aborted, command did not run
SELECT $1 \bind 1 \sendpipeline
SELECT $1 \parse a
\bind_named a 1 \sendpipeline
\close a
\close_prepared a
\flushrequest
\getresults
?column?
Expand Down
12 changes: 6 additions & 6 deletions src/test/regress/sql/psql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ SELECT $1, $2 \parse stmt3
-- Multiple \g calls mean multiple executions
\bind_named stmt2 'foo3' \g \bind_named stmt3 'foo4' 'bar4' \g

-- \close (extended query protocol)
\close
\close ''
\close stmt2
\close stmt2
-- \close_prepared (extended query protocol)
\close_prepared
\close_prepared ''
\close_prepared stmt2
\close_prepared stmt2
SELECT name, statement FROM pg_prepared_statements ORDER BY name;

-- \bind (extended query protocol)
Expand Down Expand Up @@ -1035,7 +1035,7 @@ select \if false \\ (bogus \else \\ 42 \endif \\ forty_two;
\C arg1
\c arg1 arg2 arg3 arg4
\cd arg1
\close stmt1
\close_prepared stmt1
\conninfo
\copy arg1 arg2 arg3 arg4 arg5 arg6
\copyright
Expand Down
6 changes: 3 additions & 3 deletions src/test/regress/sql/psql_pipeline.sql
Original file line number Diff line number Diff line change
Expand Up @@ -306,21 +306,21 @@ SELECT $1 \bind \sendpipeline
SELECT $1 \bind 1 \sendpipeline
SELECT $1 \parse a
\bind_named a 1 \sendpipeline
\close a
\close_prepared a
\flushrequest
\getresults
-- Pipeline is aborted.
SELECT $1 \bind 1 \sendpipeline
SELECT $1 \parse a
\bind_named a 1 \sendpipeline
\close a
\close_prepared a
-- Sync allows pipeline to recover.
\syncpipeline
\getresults
SELECT $1 \bind 1 \sendpipeline
SELECT $1 \parse a
\bind_named a 1 \sendpipeline
\close a
\close_prepared a
\flushrequest
\getresults
\endpipeline
Expand Down