aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/command.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-11-10 18:36:49 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2011-11-10 18:36:49 -0500
commit6f3dc00e24aa2a8e7e2c5e5095b6223712b8204c (patch)
tree341d9b2614b0625427bb7615f0308beba135fd91 /src/bin/psql/command.c
parent788cb1c2e8c68d054b7b5bb43f659347acf09278 (diff)
downloadpostgresql-6f3dc00e24aa2a8e7e2c5e5095b6223712b8204c.tar.gz
postgresql-6f3dc00e24aa2a8e7e2c5e5095b6223712b8204c.zip
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
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r--src/bin/psql/command.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 2c389021be7..5970ab32c15 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;
@@ -1115,7 +1121,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;