Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
d1af54cf
Commit
d1af54cf
authored
23 years ago
by
Peter Eisentraut
Browse files
Options
Downloads
Patches
Plain Diff
Make sure fmgr_info() fills in fn_oid last, so that no partially
initialized FmgrInfo structs linger after elog.
parent
cb8b40e6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/utils/fmgr/fmgr.c
+22
-13
22 additions, 13 deletions
src/backend/utils/fmgr/fmgr.c
with
22 additions
and
13 deletions
src/backend/utils/fmgr/fmgr.c
+
22
−
13
View file @
d1af54cf
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.5
1
2001/0
3/22 03:59:59 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.5
2
2001/0
5/19 09:28:08 petere
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -57,8 +57,8 @@ typedef struct
...
@@ -57,8 +57,8 @@ typedef struct
}
Oldstyle_fnextra
;
}
Oldstyle_fnextra
;
static
void
fmgr_info_C_lang
(
FmgrInfo
*
finfo
,
HeapTuple
procedureTuple
);
static
void
fmgr_info_C_lang
(
Oid
functionId
,
FmgrInfo
*
finfo
,
HeapTuple
procedureTuple
);
static
void
fmgr_info_other_lang
(
FmgrInfo
*
finfo
,
HeapTuple
procedureTuple
);
static
void
fmgr_info_other_lang
(
Oid
functionId
,
FmgrInfo
*
finfo
,
HeapTuple
procedureTuple
);
static
Datum
fmgr_oldstyle
(
PG_FUNCTION_ARGS
);
static
Datum
fmgr_oldstyle
(
PG_FUNCTION_ARGS
);
static
Datum
fmgr_untrusted
(
PG_FUNCTION_ARGS
);
static
Datum
fmgr_untrusted
(
PG_FUNCTION_ARGS
);
...
@@ -123,7 +123,11 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
...
@@ -123,7 +123,11 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
Form_pg_proc
procedureStruct
;
Form_pg_proc
procedureStruct
;
char
*
prosrc
;
char
*
prosrc
;
finfo
->
fn_oid
=
functionId
;
/*
* fn_oid *must* be filled in last. Code may assume that is fn_oid is valid,
* the whole struct is valid. Some FmgrInfo struct's do survive elogs.
*/
finfo
->
fn_oid
=
InvalidOid
;
finfo
->
fn_extra
=
NULL
;
finfo
->
fn_extra
=
NULL
;
finfo
->
fn_mcxt
=
CurrentMemoryContext
;
finfo
->
fn_mcxt
=
CurrentMemoryContext
;
...
@@ -138,6 +142,7 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
...
@@ -138,6 +142,7 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
finfo
->
fn_strict
=
fbp
->
strict
;
finfo
->
fn_strict
=
fbp
->
strict
;
finfo
->
fn_retset
=
fbp
->
retset
;
finfo
->
fn_retset
=
fbp
->
retset
;
finfo
->
fn_addr
=
fbp
->
func
;
finfo
->
fn_addr
=
fbp
->
func
;
finfo
->
fn_oid
=
functionId
;
return
;
return
;
}
}
...
@@ -158,6 +163,7 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
...
@@ -158,6 +163,7 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
{
{
/* This isn't really supported anymore... */
/* This isn't really supported anymore... */
finfo
->
fn_addr
=
fmgr_untrusted
;
finfo
->
fn_addr
=
fmgr_untrusted
;
finfo
->
fn_oid
=
functionId
;
ReleaseSysCache
(
procedureTuple
);
ReleaseSysCache
(
procedureTuple
);
return
;
return
;
}
}
...
@@ -187,7 +193,7 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
...
@@ -187,7 +193,7 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
break
;
break
;
case
ClanguageId
:
case
ClanguageId
:
fmgr_info_C_lang
(
finfo
,
procedureTuple
);
fmgr_info_C_lang
(
functionId
,
finfo
,
procedureTuple
);
break
;
break
;
case
SQLlanguageId
:
case
SQLlanguageId
:
...
@@ -195,18 +201,20 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
...
@@ -195,18 +201,20 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
break
;
break
;
default:
default:
fmgr_info_other_lang
(
finfo
,
procedureTuple
);
fmgr_info_other_lang
(
functionId
,
finfo
,
procedureTuple
);
break
;
break
;
}
}
finfo
->
fn_oid
=
functionId
;
ReleaseSysCache
(
procedureTuple
);
ReleaseSysCache
(
procedureTuple
);
}
}
/*
/*
* Special fmgr_info processing for C-language functions
* Special fmgr_info processing for C-language functions. Note that
* finfo->fn_oid is not valid yet.
*/
*/
static
void
static
void
fmgr_info_C_lang
(
FmgrInfo
*
finfo
,
HeapTuple
procedureTuple
)
fmgr_info_C_lang
(
Oid
functionId
,
FmgrInfo
*
finfo
,
HeapTuple
procedureTuple
)
{
{
Form_pg_proc
procedureStruct
=
(
Form_pg_proc
)
GETSTRUCT
(
procedureTuple
);
Form_pg_proc
procedureStruct
=
(
Form_pg_proc
)
GETSTRUCT
(
procedureTuple
);
Datum
prosrcattr
,
Datum
prosrcattr
,
...
@@ -224,14 +232,14 @@ fmgr_info_C_lang(FmgrInfo *finfo, HeapTuple procedureTuple)
...
@@ -224,14 +232,14 @@ fmgr_info_C_lang(FmgrInfo *finfo, HeapTuple procedureTuple)
Anum_pg_proc_prosrc
,
&
isnull
);
Anum_pg_proc_prosrc
,
&
isnull
);
if
(
isnull
)
if
(
isnull
)
elog
(
ERROR
,
"fmgr: Could not extract prosrc for %u from pg_proc"
,
elog
(
ERROR
,
"fmgr: Could not extract prosrc for %u from pg_proc"
,
f
info
->
fn_oi
d
);
f
unctionI
d
);
prosrcstring
=
DatumGetCString
(
DirectFunctionCall1
(
textout
,
prosrcattr
));
prosrcstring
=
DatumGetCString
(
DirectFunctionCall1
(
textout
,
prosrcattr
));
probinattr
=
SysCacheGetAttr
(
PROCOID
,
procedureTuple
,
probinattr
=
SysCacheGetAttr
(
PROCOID
,
procedureTuple
,
Anum_pg_proc_probin
,
&
isnull
);
Anum_pg_proc_probin
,
&
isnull
);
if
(
isnull
)
if
(
isnull
)
elog
(
ERROR
,
"fmgr: Could not extract probin for %u from pg_proc"
,
elog
(
ERROR
,
"fmgr: Could not extract probin for %u from pg_proc"
,
f
info
->
fn_oi
d
);
f
unctionI
d
);
probinstring
=
DatumGetCString
(
DirectFunctionCall1
(
textout
,
probinattr
));
probinstring
=
DatumGetCString
(
DirectFunctionCall1
(
textout
,
probinattr
));
/* Look up the function itself */
/* Look up the function itself */
...
@@ -276,10 +284,11 @@ fmgr_info_C_lang(FmgrInfo *finfo, HeapTuple procedureTuple)
...
@@ -276,10 +284,11 @@ fmgr_info_C_lang(FmgrInfo *finfo, HeapTuple procedureTuple)
}
}
/*
/*
* Special fmgr_info processing for other-language functions
* Special fmgr_info processing for other-language functions. Note
* that finfo->fn_oid is not valid yet.
*/
*/
static
void
static
void
fmgr_info_other_lang
(
FmgrInfo
*
finfo
,
HeapTuple
procedureTuple
)
fmgr_info_other_lang
(
Oid
functionId
,
FmgrInfo
*
finfo
,
HeapTuple
procedureTuple
)
{
{
Form_pg_proc
procedureStruct
=
(
Form_pg_proc
)
GETSTRUCT
(
procedureTuple
);
Form_pg_proc
procedureStruct
=
(
Form_pg_proc
)
GETSTRUCT
(
procedureTuple
);
Oid
language
=
procedureStruct
->
prolang
;
Oid
language
=
procedureStruct
->
prolang
;
...
@@ -312,7 +321,7 @@ fmgr_info_other_lang(FmgrInfo *finfo, HeapTuple procedureTuple)
...
@@ -312,7 +321,7 @@ fmgr_info_other_lang(FmgrInfo *finfo, HeapTuple procedureTuple)
else
else
{
{
elog
(
ERROR
,
"fmgr_info: function %u: unsupported language %u"
,
elog
(
ERROR
,
"fmgr_info: function %u: unsupported language %u"
,
f
info
->
fn_oi
d
,
language
);
f
unctionI
d
,
language
);
}
}
ReleaseSysCache
(
languageTuple
);
ReleaseSysCache
(
languageTuple
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment