Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Throw nice error if server is too old to support psql's \ef or \sf command.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 10 Nov 2011 23:37:05 +0000 (18:37 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 10 Nov 2011 23:37:05 +0000 (18:37 -0500)
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

index 1339f336ff074df8992e3724a2d33ac8e875c57f..786f4139b5325041f8318a6ed811d055e54249c1 100644 (file)
@@ -492,7 +492,13 @@ exec_command(const char *cmd,
     */
    else if (strcmp(cmd, "ef") == 0)
    {
-       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;