mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Change many routines to return ObjectAddress rather than OID
The changed routines are mostly those that can be directly called by ProcessUtilitySlow; the intention is to make the affected object information more precise, in support for future event trigger changes. Originally it was envisioned that the OID of the affected object would be enough, and in most cases that is correct, but upon actually implementing the event trigger changes it turned out that ObjectAddress is more widely useful. Additionally, some command execution routines grew an output argument that's an object address which provides further info about the executed command. To wit: * for ALTER DOMAIN / ADD CONSTRAINT, it corresponds to the address of the new constraint * for ALTER OBJECT / SET SCHEMA, it corresponds to the address of the schema that originally contained the object. * for ALTER EXTENSION {ADD, DROP} OBJECT, it corresponds to the address of the object added to or dropped from the extension. There's no user-visible change in this commit, and no functional change either. Discussion: 20150218213255.GC6717@tamriel.snowman.net Reviewed-By: Stephen Frost, Andres Freund
This commit is contained in:
@ -51,7 +51,7 @@ typedef struct
|
||||
char *tmpllibrary; /* path of shared library */
|
||||
} PLTemplate;
|
||||
|
||||
static Oid create_proc_lang(const char *languageName, bool replace,
|
||||
static ObjectAddress create_proc_lang(const char *languageName, bool replace,
|
||||
Oid languageOwner, Oid handlerOid, Oid inlineOid,
|
||||
Oid valOid, bool trusted);
|
||||
static PLTemplate *find_language_template(const char *languageName);
|
||||
@ -60,10 +60,11 @@ static PLTemplate *find_language_template(const char *languageName);
|
||||
* CREATE PROCEDURAL LANGUAGE
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
Oid
|
||||
ObjectAddress
|
||||
CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
{
|
||||
PLTemplate *pltemplate;
|
||||
ObjectAddress tmpAddr;
|
||||
Oid handlerOid,
|
||||
inlineOid,
|
||||
valOid;
|
||||
@ -118,30 +119,31 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
}
|
||||
else
|
||||
{
|
||||
handlerOid = ProcedureCreate(pltemplate->tmplhandler,
|
||||
PG_CATALOG_NAMESPACE,
|
||||
false, /* replace */
|
||||
false, /* returnsSet */
|
||||
LANGUAGE_HANDLEROID,
|
||||
BOOTSTRAP_SUPERUSERID,
|
||||
ClanguageId,
|
||||
F_FMGR_C_VALIDATOR,
|
||||
pltemplate->tmplhandler,
|
||||
pltemplate->tmpllibrary,
|
||||
false, /* isAgg */
|
||||
false, /* isWindowFunc */
|
||||
false, /* security_definer */
|
||||
false, /* isLeakProof */
|
||||
false, /* isStrict */
|
||||
PROVOLATILE_VOLATILE,
|
||||
buildoidvector(funcargtypes, 0),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
NIL,
|
||||
PointerGetDatum(NULL),
|
||||
1,
|
||||
0);
|
||||
tmpAddr = ProcedureCreate(pltemplate->tmplhandler,
|
||||
PG_CATALOG_NAMESPACE,
|
||||
false, /* replace */
|
||||
false, /* returnsSet */
|
||||
LANGUAGE_HANDLEROID,
|
||||
BOOTSTRAP_SUPERUSERID,
|
||||
ClanguageId,
|
||||
F_FMGR_C_VALIDATOR,
|
||||
pltemplate->tmplhandler,
|
||||
pltemplate->tmpllibrary,
|
||||
false, /* isAgg */
|
||||
false, /* isWindowFunc */
|
||||
false, /* security_definer */
|
||||
false, /* isLeakProof */
|
||||
false, /* isStrict */
|
||||
PROVOLATILE_VOLATILE,
|
||||
buildoidvector(funcargtypes, 0),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
NIL,
|
||||
PointerGetDatum(NULL),
|
||||
1,
|
||||
0);
|
||||
handlerOid = tmpAddr.objectId;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -155,30 +157,31 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
inlineOid = LookupFuncName(funcname, 1, funcargtypes, true);
|
||||
if (!OidIsValid(inlineOid))
|
||||
{
|
||||
inlineOid = ProcedureCreate(pltemplate->tmplinline,
|
||||
PG_CATALOG_NAMESPACE,
|
||||
false, /* replace */
|
||||
false, /* returnsSet */
|
||||
VOIDOID,
|
||||
BOOTSTRAP_SUPERUSERID,
|
||||
ClanguageId,
|
||||
F_FMGR_C_VALIDATOR,
|
||||
pltemplate->tmplinline,
|
||||
pltemplate->tmpllibrary,
|
||||
false, /* isAgg */
|
||||
false, /* isWindowFunc */
|
||||
false, /* security_definer */
|
||||
false, /* isLeakProof */
|
||||
true, /* isStrict */
|
||||
PROVOLATILE_VOLATILE,
|
||||
buildoidvector(funcargtypes, 1),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
NIL,
|
||||
PointerGetDatum(NULL),
|
||||
1,
|
||||
0);
|
||||
tmpAddr = ProcedureCreate(pltemplate->tmplinline,
|
||||
PG_CATALOG_NAMESPACE,
|
||||
false, /* replace */
|
||||
false, /* returnsSet */
|
||||
VOIDOID,
|
||||
BOOTSTRAP_SUPERUSERID,
|
||||
ClanguageId,
|
||||
F_FMGR_C_VALIDATOR,
|
||||
pltemplate->tmplinline,
|
||||
pltemplate->tmpllibrary,
|
||||
false, /* isAgg */
|
||||
false, /* isWindowFunc */
|
||||
false, /* security_definer */
|
||||
false, /* isLeakProof */
|
||||
true, /* isStrict */
|
||||
PROVOLATILE_VOLATILE,
|
||||
buildoidvector(funcargtypes, 1),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
NIL,
|
||||
PointerGetDatum(NULL),
|
||||
1,
|
||||
0);
|
||||
inlineOid = tmpAddr.objectId;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -195,30 +198,31 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
valOid = LookupFuncName(funcname, 1, funcargtypes, true);
|
||||
if (!OidIsValid(valOid))
|
||||
{
|
||||
valOid = ProcedureCreate(pltemplate->tmplvalidator,
|
||||
PG_CATALOG_NAMESPACE,
|
||||
false, /* replace */
|
||||
false, /* returnsSet */
|
||||
VOIDOID,
|
||||
BOOTSTRAP_SUPERUSERID,
|
||||
ClanguageId,
|
||||
F_FMGR_C_VALIDATOR,
|
||||
pltemplate->tmplvalidator,
|
||||
pltemplate->tmpllibrary,
|
||||
false, /* isAgg */
|
||||
false, /* isWindowFunc */
|
||||
false, /* security_definer */
|
||||
false, /* isLeakProof */
|
||||
true, /* isStrict */
|
||||
PROVOLATILE_VOLATILE,
|
||||
buildoidvector(funcargtypes, 1),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
NIL,
|
||||
PointerGetDatum(NULL),
|
||||
1,
|
||||
0);
|
||||
tmpAddr = ProcedureCreate(pltemplate->tmplvalidator,
|
||||
PG_CATALOG_NAMESPACE,
|
||||
false, /* replace */
|
||||
false, /* returnsSet */
|
||||
VOIDOID,
|
||||
BOOTSTRAP_SUPERUSERID,
|
||||
ClanguageId,
|
||||
F_FMGR_C_VALIDATOR,
|
||||
pltemplate->tmplvalidator,
|
||||
pltemplate->tmpllibrary,
|
||||
false, /* isAgg */
|
||||
false, /* isWindowFunc */
|
||||
false, /* security_definer */
|
||||
false, /* isLeakProof */
|
||||
true, /* isStrict */
|
||||
PROVOLATILE_VOLATILE,
|
||||
buildoidvector(funcargtypes, 1),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
PointerGetDatum(NULL),
|
||||
NIL,
|
||||
PointerGetDatum(NULL),
|
||||
1,
|
||||
0);
|
||||
valOid = tmpAddr.objectId;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -309,7 +313,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
/*
|
||||
* Guts of language creation.
|
||||
*/
|
||||
static Oid
|
||||
static ObjectAddress
|
||||
create_proc_lang(const char *languageName, bool replace,
|
||||
Oid languageOwner, Oid handlerOid, Oid inlineOid,
|
||||
Oid valOid, bool trusted)
|
||||
@ -433,7 +437,7 @@ create_proc_lang(const char *languageName, bool replace,
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
return myself.objectId;
|
||||
return myself;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user