postgres.git / summary / log / commit / refs
commit 07d5205582daa0a2b1472404f7929536d702e947
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu Nov 10 23:36:55 2011 +0000
First released in: 9.2.0, 8.4.10, 9.0.6, 9.1.2
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
src/bin/psql/command.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 472bcab03b5..a451c2b8ea1 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -583,7 +583,13 @@ exec_command(const char *cmd,
{
int lineno = -1;
- if (!query_buf)
+ if (pset.sversion < 80400)
+ {
+ psql_error("The server (version %d.%d) does not support editing function source.\n",
+ pset.sversion / 10000, (pset.sversion / 100) % 100);
+ status = PSQL_CMD_ERROR;
+ }
+ else if (!query_buf)
{
psql_error("no query buffer\n");
status = PSQL_CMD_ERROR;
@@ -1110,7 +1116,13 @@ exec_command(const char *cmd,
func_buf = createPQExpBuffer();
func = psql_scan_slash_option(scan_state,
OT_WHOLE_LINE, NULL, true);
- if (!func)
+ if (pset.sversion < 80400)
+ {
+ psql_error("The server (version %d.%d) does not support showing function source.\n",
+ pset.sversion / 10000, (pset.sversion / 100) % 100);
+ status = PSQL_CMD_ERROR;
+ }
+ else if (!func)
{
psql_error("function name is required\n");
status = PSQL_CMD_ERROR;
[parent: 91e8cb61a576]