mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Adjust psql's new \ef command to present an empty CREATE FUNCTION template
for editing if no function name is specified. This seems a much cleaner way to offer that functionality than the original patch had. In passing, de-clutter the error displays that are given for a bogus function-name argument, and standardize on "$function$" as the default delimiter for the function body. (The original coding would use the shortest possible dollar-quote delimiter, which seems to create unnecessarily high risk of later conflicts with the user-modified function body.)
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.283 2008/09/06 00:01:21 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.284 2008/09/06 20:18:08 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1543,9 +1543,15 @@ pg_get_functiondef(PG_FUNCTION_ARGS)
|
||||
elog(ERROR, "null prosrc");
|
||||
prosrc = TextDatumGetCString(tmp);
|
||||
|
||||
/* We always use dollar quoting. Figure out a suitable delimiter. */
|
||||
/*
|
||||
* We always use dollar quoting. Figure out a suitable delimiter.
|
||||
*
|
||||
* Since the user is likely to be editing the function body string,
|
||||
* we shouldn't use a short delimiter that he might easily create a
|
||||
* conflict with. Hence prefer "$function$", but extend if needed.
|
||||
*/
|
||||
initStringInfo(&dq);
|
||||
appendStringInfoChar(&dq, '$');
|
||||
appendStringInfoString(&dq, "$function");
|
||||
while (strstr(prosrc, dq.data) != NULL)
|
||||
appendStringInfoChar(&dq, 'x');
|
||||
appendStringInfoChar(&dq, '$');
|
||||
|
Reference in New Issue
Block a user