Skip to content

Commit 6f3dc00

Browse files
committed
Throw nice error if server is too old to support psql's \ef or \sf command.
Previously, you'd get "function pg_catalog.pg_get_functiondef(integer) does not exist", which is at best rather unprofessional-looking. Back-patch to 8.4 where \ef was introduced. Josh Kupershmidt
1 parent 788cb1c commit 6f3dc00

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/bin/psql/command.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,13 @@ exec_command(const char *cmd,
583583
{
584584
int lineno = -1;
585585

586-
if (!query_buf)
586+
if (pset.sversion < 80400)
587+
{
588+
psql_error("The server (version %d.%d) does not support editing function source.\n",
589+
pset.sversion / 10000, (pset.sversion / 100) % 100);
590+
status = PSQL_CMD_ERROR;
591+
}
592+
else if (!query_buf)
587593
{
588594
psql_error("no query buffer\n");
589595
status = PSQL_CMD_ERROR;
@@ -1115,7 +1121,13 @@ exec_command(const char *cmd,
11151121
func_buf = createPQExpBuffer();
11161122
func = psql_scan_slash_option(scan_state,
11171123
OT_WHOLE_LINE, NULL, true);
1118-
if (!func)
1124+
if (pset.sversion < 80400)
1125+
{
1126+
psql_error("The server (version %d.%d) does not support showing function source.\n",
1127+
pset.sversion / 10000, (pset.sversion / 100) % 100);
1128+
status = PSQL_CMD_ERROR;
1129+
}
1130+
else if (!func)
11191131
{
11201132
psql_error("function name is required\n");
11211133
status = PSQL_CMD_ERROR;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy