]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
psql: Disable %P (pipeline status) for non-active connection
authorMichael Paquier <michael@paquier.xyz>
Thu, 29 Jan 2026 07:20:45 +0000 (16:20 +0900)
committerMichael Paquier <michael@paquier.xyz>
Thu, 29 Jan 2026 07:20:45 +0000 (16:20 +0900)
In the psql prompt, %P prompt shows the current pipeline status.  Unlike
most of the other options, its status was showing up in the output
generated even if psql was not connected to a database.  This was
confusing, because without a connection a pipeline status makes no
sense.

Like the other options, %P is updated so as its data is now hidden
without an active connection.

Author: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/86EF76B5-6E62-404D-B9EC-66F4714D7D5F@gmail.com
Backpatch-through: 18

src/bin/psql/prompt.c

index 44eae59641ee6a02bbe11cb49b8b5657add615f4..891cd6374f0942a70843a6dfed2bfff3aa9c7588 100644 (file)
@@ -199,6 +199,7 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
                                        break;
                                        /* pipeline status */
                                case 'P':
+                                       if (pset.db)
                                        {
                                                PGpipelineStatus status = PQpipelineStatus(pset.db);
 
@@ -208,9 +209,8 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
                                                        strlcpy(buf, "abort", sizeof(buf));
                                                else
                                                        strlcpy(buf, "off", sizeof(buf));
-                                               break;
                                        }
-
+                                       break;
                                case '0':
                                case '1':
                                case '2':