Skip to content

Commit 41b810f

Browse files
committed
Fix \ef and \sf to not fail on functions with nonnull probin.
Update comment about them in pg_get_functiondef.
1 parent b6e0694 commit 41b810f

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/backend/utils/adt/ruleutils.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.331 2010/08/12 00:40:59 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.332 2010/08/14 14:20:35 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -1622,8 +1622,9 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
16221622
* the specified function.
16231623
*
16241624
* Note: if you change the output format of this function, be careful not
1625-
* to break psql's rules (in \ef) for identifying the start of the function
1626-
* body.
1625+
* to break psql's rules (in \ef and \sf) for identifying the start of the
1626+
* function body. To wit: the function body starts on a line that begins
1627+
* with "AS ", and no preceding line will look like that.
16271628
*/
16281629
Datum
16291630
pg_get_functiondef(PG_FUNCTION_ARGS)

src/bin/psql/command.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.227 2010/08/14 13:59:49 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.228 2010/08/14 14:20:35 tgl Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "command.h"
@@ -611,17 +611,17 @@ exec_command(const char *cmd,
611611
/*
612612
* lineno "1" should correspond to the first line of the
613613
* function body. We expect that pg_get_functiondef() will
614-
* emit that on a line beginning with "AS $function", and that
615-
* there can be no such line before the real start of the
616-
* function body. Increment lineno by the number of lines
617-
* before that line, so that it becomes relative to the first
618-
* line of the function definition.
614+
* emit that on a line beginning with "AS ", and that there
615+
* can be no such line before the real start of the function
616+
* body. Increment lineno by the number of lines before that
617+
* line, so that it becomes relative to the first line of the
618+
* function definition.
619619
*/
620620
const char *lines = query_buf->data;
621621

622622
while (*lines != '\0')
623623
{
624-
if (strncmp(lines, "AS $function", 12) == 0)
624+
if (strncmp(lines, "AS ", 3) == 0)
625625
break;
626626
lineno++;
627627
/* find start of next line */
@@ -1150,17 +1150,17 @@ exec_command(const char *cmd,
11501150
/*
11511151
* lineno "1" should correspond to the first line of the
11521152
* function body. We expect that pg_get_functiondef() will
1153-
* emit that on a line beginning with "AS $function", and that
1154-
* there can be no such line before the real start of the
1155-
* function body.
1153+
* emit that on a line beginning with "AS ", and that there
1154+
* can be no such line before the real start of the function
1155+
* body.
11561156
*
11571157
* Note that this loop scribbles on func_buf.
11581158
*/
11591159
while (*lines != '\0')
11601160
{
11611161
char *eol;
11621162

1163-
if (in_header && strncmp(lines, "AS $function", 12) == 0)
1163+
if (in_header && strncmp(lines, "AS ", 3) == 0)
11641164
in_header = false;
11651165
/* increment lineno only for body's lines */
11661166
if (!in_header)

0 commit comments

Comments
 (0)