Skip to content

Commit c49130a

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 019d45e commit c49130a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/bin/psql/command.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,13 @@ exec_command(const char *cmd,
508508
*/
509509
else if (strcmp(cmd, "ef") == 0)
510510
{
511-
if (!query_buf)
511+
if (pset.sversion < 80400)
512+
{
513+
psql_error("The server (version %d.%d) does not support editing function source.\n",
514+
pset.sversion / 10000, (pset.sversion / 100) % 100);
515+
status = PSQL_CMD_ERROR;
516+
}
517+
else if (!query_buf)
512518
{
513519
psql_error("no query buffer\n");
514520
status = PSQL_CMD_ERROR;

0 commit comments

Comments
 (0)