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

Commit098e043

Browse files
committed
Fix CREATE OPERATOR ... LANGUAGE 'internal', which I broke while
making prosrc instead of proname be the link to the actual internal function.
1 parent7eb16b7 commit098e043

File tree

4 files changed

+45
-39
lines changed

4 files changed

+45
-39
lines changed

‎src/backend/commands/define.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.27 1999/02/13 23:15:06 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.28 1999/04/09 22:35:41 tgl Exp $
1313
*
1414
* DESCRIPTION
1515
* The "DefineFoo" routines take the parse tree and pick out the
@@ -186,14 +186,15 @@ interpret_AS_clause(const char *languageName, const char *as,
186186
char**prosrc_str_p,char**probin_str_p)
187187
{
188188

189-
if (strcmp(languageName,"C")==0||
190-
strcmp(languageName,"internal")==0)
189+
if (strcmp(languageName,"C")==0)
191190
{
191+
/* For "C" language, store the given string in probin */
192192
*prosrc_str_p="-";
193193
*probin_str_p= (char*)as;
194194
}
195195
else
196196
{
197+
/* Everything else wants the given string in prosrc */
197198
*prosrc_str_p= (char*)as;
198199
*probin_str_p="-";
199200
}

‎src/backend/utils/Gen_fmgrtab.sh.in

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
#
1010
# IDENTIFICATION
11-
# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.14 1999/03/29 01:30:35 tgl Exp $
11+
# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.15 1999/04/09 22:35:41 tgl Exp $
1212
#
1313
# NOTES
1414
# Passes any -D options on to cpp prior to generating the list
@@ -83,7 +83,7 @@ cat > $HFILE <<FuNkYfMgRsTuFf
8383
*
8484
* Copyright (c) 1994, Regents of the University of California
8585
*
86-
*$Id: Gen_fmgrtab.sh.in,v 1.14 1999/03/29 01:30:35 tgl Exp $
86+
*$Id: Gen_fmgrtab.sh.in,v 1.15 1999/04/09 22:35:41 tgl Exp $
8787
*
8888
* NOTES
8989
*******************************
@@ -206,7 +206,7 @@ cat > $TABCFILE <<FuNkYfMgRtAbStUfF
206206
*
207207
*
208208
* IDENTIFICATION
209-
*$Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.14 1999/03/29 01:30:35 tgl Exp $
209+
*$Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.15 1999/04/09 22:35:41 tgl Exp $
210210
*
211211
* NOTES
212212
*
@@ -225,22 +225,7 @@ cat > $TABCFILE <<FuNkYfMgRtAbStUfF
225225
*/
226226
227227
#include <string.h>
228-
229228
#include <postgres.h>
230-
231-
#ifdef WIN32
232-
# include <limits.h>
233-
#else
234-
# ifdef HAVE_LIMITS_H
235-
# include <limits.h>
236-
# ifndef MAXINT
237-
# define MAXINTINT_MAX
238-
# endif
239-
# else
240-
# include <values.h>
241-
# endif
242-
#endif
243-
244229
#include "utils/fmgrtab.h"
245230
246231
FuNkYfMgRtAbStUfF
@@ -252,20 +237,14 @@ cat >> $TABCFILE <<FuNkYfMgRtAbStUfF
252237
static FmgrCall fmgr_builtins[] = {
253238
FuNkYfMgRtAbStUfF
254239

255-
awk'{ printf (" {%d, %d, %s},\n"), $1, $8, $(NF-1) }'$RAWFILE>>$TABCFILE
240+
awk'{ printf (" {%d, %d, %s, \"%s\"},\n"), $1, $8, $(NF-1), $(NF-1) }'$RAWFILE>>$TABCFILE
256241

257242
cat>>$TABCFILE<<FuNkYfMgRtAbStUfF
258-
/* guardian value */
259-
#ifndef WIN32
260-
{ MAXINT, 0, (func_ptr) NULL }
261-
#else
262-
{ INT_MAX, 0, (func_ptr) NULL }
263-
#endif /* WIN32 */
243+
/* dummy entry is easier than getting rid of comma after last real one */
244+
{ 0, 0, (func_ptr) NULL, NULL }
264245
};
265246
266-
/* Note FMGR_NBUILTINS excludes the guardian entry, which is probably
267-
* not really needed at all ...
268-
*/
247+
/* Note FMGR_NBUILTINS excludes the dummy entry */
269248
#define FMGR_NBUILTINS ((sizeof(fmgr_builtins) / sizeof(FmgrCall)) - 1)
270249
271250
FmgrCall *fmgr_isbuiltin(Oid id)
@@ -289,6 +268,20 @@ FmgrCall *fmgr_isbuiltin(Oid id)
289268
return (FmgrCall *) NULL;
290269
}
291270
271+
func_ptr fmgr_lookupByName(char *name)
272+
{
273+
/* Lookup a builtin by name. Note there can be more than one entry in
274+
* the array matching this name, but they should all point to the same
275+
* routine.
276+
*/
277+
int i;
278+
for (i=0; i<FMGR_NBUILTINS; i++) {
279+
if (strcmp(name, fmgr_builtins[i].funcName) == 0)
280+
return fmgr_builtins[i].func;
281+
}
282+
return (func_ptr) NULL;
283+
}
284+
292285
FuNkYfMgRtAbStUfF
293286

294287
rm -f$RAWFILE

‎src/backend/utils/fmgr/fmgr.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.24 1999/04/03 22:57:29 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.25 1999/04/09 22:35:42 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -27,6 +27,7 @@
2727
#include"utils/syscache.h"
2828
#include"nodes/params.h"
2929

30+
#include"utils/builtins.h"
3031
#include"utils/elog.h"
3132

3233
#include"nodes/parsenodes.h"
@@ -206,6 +207,7 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo)
206207
HeapTuplelanguageTuple;
207208
Form_pg_languagelanguageStruct;
208209
Oidlanguage;
210+
char*prosrc;
209211

210212
finfo->fn_addr=NULL;
211213
finfo->fn_plhandler=NULL;
@@ -239,11 +241,21 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo)
239241
{
240242
caseINTERNALlanguageId:
241243
/*
242-
* Since we already tried to look up the OID as a builtin
243-
* function, we should never get here...
244+
* For an ordinary builtin function, we should never get here
245+
* because the isbuiltin() search above will have succeeded.
246+
* However, if the user has done a CREATE FUNCTION to create
247+
* an alias for a builtin function, we end up here. In that
248+
* case we have to look up the function by name. The name
249+
* of the internal function is stored in prosrc (it doesn't
250+
* have to be the same as the name of the alias!)
244251
*/
245-
elog(ERROR,"fmgr_info: function %d: not in internal table",
246-
procedureId);
252+
prosrc=textout(&(procedureStruct->prosrc));
253+
finfo->fn_addr=fmgr_lookupByName(prosrc);
254+
if (!finfo->fn_addr)
255+
elog(ERROR,"fmgr_info: function %s not in internal table",
256+
prosrc);
257+
finfo->fn_nargs=procedureStruct->pronargs;
258+
pfree(prosrc);
247259
break;
248260
caseClanguageId:
249261
finfo->fn_addr=fmgr_dynamic(procedureId,&(finfo->fn_nargs));

‎src/include/utils/fmgrtab.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: fmgrtab.h,v 1.10 1999/03/29 01:30:41 tgl Exp $
9+
* $Id: fmgrtab.h,v 1.11 1999/04/09 22:35:43 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -19,11 +19,11 @@ typedef struct
1919
Oidproid;
2020
intnargs;
2121
func_ptrfunc;
22-
intdummy;/* pad struct to 4 words for fast indexing */
22+
char*funcName;
2323
}FmgrCall;
2424

2525
externFmgrCall*fmgr_isbuiltin(Oidid);
26-
26+
externfunc_ptrfmgr_lookupByName(char*name);
2727
externvoidload_file(char*filename);
2828

2929
#endif/* FMGRTAB_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp