Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4b82c6d

Browse files
committed
Allow CREATE FUNCTION xyz AS '' LANGUAGE 'internal' to
work the way it used to (ie, assume xyz is the name of the builtinfunction to call). Complain if an unknown builtin function name isreferenced.
1 parent00a4196 commit4b82c6d

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

‎src/backend/catalog/pg_proc.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.26 1999/02/21 03:48:32 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.27 1999/04/18 02:57:22 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -26,6 +26,7 @@
2626
#include"parser/parse_node.h"
2727
#include"tcop/tcopprot.h"
2828
#include"utils/builtins.h"
29+
#include"utils/fmgrtab.h"
2930
#include"utils/lsyscache.h"
3031
#include"utils/sets.h"
3132
#include"utils/syscache.h"
@@ -37,7 +38,7 @@
3738
#endif
3839

3940
/* ----------------------------------------------------------------
40-
*ProcedureDefine
41+
*ProcedureCreate
4142
* ----------------------------------------------------------------
4243
*/
4344
Oid
@@ -94,7 +95,7 @@ ProcedureCreate(char *procedureName,
9495
if (strcmp(strVal(t),"opaque")==0)
9596
{
9697
if (strcmp(languageName,"sql")==0)
97-
elog(ERROR,"ProcedureDefine: sql functions cannot take type \"opaque\"");
98+
elog(ERROR,"ProcedureCreate: sql functions cannot take type \"opaque\"");
9899
toid=0;
99100
}
100101
else
@@ -220,6 +221,32 @@ ProcedureCreate(char *procedureName,
220221
pg_checkretval(typeObjectId,querytree_list);
221222
}
222223

224+
/*
225+
* If this is an internal procedure, check that the given internal
226+
* function name (the 'prosrc' value) is a known builtin function.
227+
*
228+
* NOTE: in Postgres versions before 6.5, the SQL name of the created
229+
* function could not be different from the internal name, and 'prosrc'
230+
* wasn't used. So there is code out there that does CREATE FUNCTION
231+
* xyz AS '' LANGUAGE 'internal'. To preserve some modicum of
232+
* backwards compatibility, accept an empty 'prosrc' value as meaning
233+
* the supplied SQL function name.
234+
*/
235+
236+
if (strcmp(languageName,"internal")==0)
237+
{
238+
if (strlen(prosrc)==0)
239+
prosrc=procedureName;
240+
if (fmgr_lookupByName(prosrc)== (func_ptr)NULL)
241+
elog(ERROR,
242+
"ProcedureCreate: there is no builtin function named \"%s\"",
243+
prosrc);
244+
}
245+
246+
/*
247+
* All seems OK; prepare the tuple to be inserted into pg_proc.
248+
*/
249+
223250
for (i=0;i<Natts_pg_proc;++i)
224251
{
225252
nulls[i]=' ';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp