aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/proclang.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2015-03-03 14:10:50 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2015-03-03 14:10:50 -0300
commita2e35b53c39b2a27d3e332dc7c506539c306fd44 (patch)
tree1f4cd33208d33f4a8b3159b0d3757109c67d4b14 /src/backend/commands/proclang.c
parent6f9d79904748c26a58991942dc6719db558f77b0 (diff)
downloadpostgresql-a2e35b53c39b2a27d3e332dc7c506539c306fd44.tar.gz
postgresql-a2e35b53c39b2a27d3e332dc7c506539c306fd44.zip
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
Diffstat (limited to 'src/backend/commands/proclang.c')
-rw-r--r--src/backend/commands/proclang.c156
1 files changed, 80 insertions, 76 deletions
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index 07224616145..11e6213e80f 100644
--- a/src/backend/commands/proclang.c
+++ b/src/backend/commands/proclang.c
@@ -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;
}
/*