Commit 41b810fe authored by Tom Lane's avatar Tom Lane

Fix \ef and \sf to not fail on functions with nonnull probin.

Update comment about them in pg_get_functiondef.
parent b6e06942
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.331 2010/08/12 00:40:59 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.332 2010/08/14 14:20:35 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1622,8 +1622,9 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS) ...@@ -1622,8 +1622,9 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
* the specified function. * the specified function.
* *
* Note: if you change the output format of this function, be careful not * Note: if you change the output format of this function, be careful not
* to break psql's rules (in \ef) for identifying the start of the function * to break psql's rules (in \ef and \sf) for identifying the start of the
* body. * function body. To wit: the function body starts on a line that begins
* with "AS ", and no preceding line will look like that.
*/ */
Datum Datum
pg_get_functiondef(PG_FUNCTION_ARGS) pg_get_functiondef(PG_FUNCTION_ARGS)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2010, PostgreSQL Global Development Group * Copyright (c) 2000-2010, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.227 2010/08/14 13:59:49 tgl Exp $ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.228 2010/08/14 14:20:35 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "command.h" #include "command.h"
...@@ -611,17 +611,17 @@ exec_command(const char *cmd, ...@@ -611,17 +611,17 @@ exec_command(const char *cmd,
/* /*
* lineno "1" should correspond to the first line of the * lineno "1" should correspond to the first line of the
* function body. We expect that pg_get_functiondef() will * function body. We expect that pg_get_functiondef() will
* emit that on a line beginning with "AS $function", and that * emit that on a line beginning with "AS ", and that there
* there can be no such line before the real start of the * can be no such line before the real start of the function
* function body. Increment lineno by the number of lines * body. Increment lineno by the number of lines before that
* before that line, so that it becomes relative to the first * line, so that it becomes relative to the first line of the
* line of the function definition. * function definition.
*/ */
const char *lines = query_buf->data; const char *lines = query_buf->data;
while (*lines != '\0') while (*lines != '\0')
{ {
if (strncmp(lines, "AS $function", 12) == 0) if (strncmp(lines, "AS ", 3) == 0)
break; break;
lineno++; lineno++;
/* find start of next line */ /* find start of next line */
...@@ -1150,9 +1150,9 @@ exec_command(const char *cmd, ...@@ -1150,9 +1150,9 @@ exec_command(const char *cmd,
/* /*
* lineno "1" should correspond to the first line of the * lineno "1" should correspond to the first line of the
* function body. We expect that pg_get_functiondef() will * function body. We expect that pg_get_functiondef() will
* emit that on a line beginning with "AS $function", and that * emit that on a line beginning with "AS ", and that there
* there can be no such line before the real start of the * can be no such line before the real start of the function
* function body. * body.
* *
* Note that this loop scribbles on func_buf. * Note that this loop scribbles on func_buf.
*/ */
...@@ -1160,7 +1160,7 @@ exec_command(const char *cmd, ...@@ -1160,7 +1160,7 @@ exec_command(const char *cmd,
{ {
char *eol; char *eol;
if (in_header && strncmp(lines, "AS $function", 12) == 0) if (in_header && strncmp(lines, "AS ", 3) == 0)
in_header = false; in_header = false;
/* increment lineno only for body's lines */ /* increment lineno only for body's lines */
if (!in_header) if (!in_header)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment