Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 07d5205

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 91e8cb6 commit 07d5205

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;
@@ -1110,7 +1116,13 @@ exec_command(const char *cmd,
11101116
func_buf = createPQExpBuffer();
11111117
func = psql_scan_slash_option(scan_state,
11121118
OT_WHOLE_LINE, NULL, true);
1113-
if (!func)
1119+
if (pset.sversion < 80400)
1120+
{
1121+
psql_error("The server (version %d.%d) does not support showing function source.\n",
1122+
pset.sversion / 10000, (pset.sversion / 100) % 100);
1123+
status = PSQL_CMD_ERROR;
1124+
}
1125+
else if (!func)
11141126
{
11151127
psql_error("function name is required\n");
11161128
status = PSQL_CMD_ERROR;

0 commit comments

Comments
 (0)