diff options
author | Robert Haas <rhaas@postgresql.org> | 2012-12-23 18:25:03 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2012-12-23 18:37:58 -0500 |
commit | c504513f83a9ee8dce4a719746ca73102cae9f13 (patch) | |
tree | 3664999ca3242003181bef1fa171e28fe557ecb9 /src/backend/commands/typecmds.c | |
parent | 31bc839724439440b2e94ea616b28ce5be94e19c (diff) | |
download | postgresql-c504513f83a9ee8dce4a719746ca73102cae9f13.tar.gz postgresql-c504513f83a9ee8dce4a719746ca73102cae9f13.zip |
Adjust many backend functions to return OID rather than void.
Extracted from a larger patch by Dimitri Fontaine. It is hoped that
this will provide infrastructure for enriching the new event trigger
functionality, but it seems possibly useful for other purposes as
well.
Diffstat (limited to 'src/backend/commands/typecmds.c')
-rw-r--r-- | src/backend/commands/typecmds.c | 84 |
1 files changed, 47 insertions, 37 deletions
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index 36de6d7e28b..6f99f38f118 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -111,7 +111,7 @@ static char *domainAddConstraint(Oid domainOid, Oid domainNamespace, * DefineType * Registers a new base type. */ -void +Oid DefineType(List *names, List *parameters) { char *typeName; @@ -225,7 +225,7 @@ DefineType(List *names, List *parameters) * creating the shell type was all we're supposed to do. */ if (parameters == NIL) - return; + return InvalidOid; } else { @@ -593,39 +593,41 @@ DefineType(List *names, List *parameters) /* alignment must be 'i' or 'd' for arrays */ alignment = (alignment == 'd') ? 'd' : 'i'; - TypeCreate(array_oid, /* force assignment of this type OID */ - array_type, /* type name */ - typeNamespace, /* namespace */ - InvalidOid, /* relation oid (n/a here) */ - 0, /* relation kind (ditto) */ - GetUserId(), /* owner's ID */ - -1, /* internal size (always varlena) */ - TYPTYPE_BASE, /* type-type (base type) */ - TYPCATEGORY_ARRAY, /* type-category (array) */ - false, /* array types are never preferred */ - delimiter, /* array element delimiter */ - F_ARRAY_IN, /* input procedure */ - F_ARRAY_OUT, /* output procedure */ - F_ARRAY_RECV, /* receive procedure */ - F_ARRAY_SEND, /* send procedure */ - typmodinOid, /* typmodin procedure */ - typmodoutOid, /* typmodout procedure */ - F_ARRAY_TYPANALYZE, /* analyze procedure */ - typoid, /* element type ID */ - true, /* yes this is an array type */ - InvalidOid, /* no further array type */ - InvalidOid, /* base type ID */ - NULL, /* never a default type value */ - NULL, /* binary default isn't sent either */ - false, /* never passed by value */ - alignment, /* see above */ - 'x', /* ARRAY is always toastable */ - -1, /* typMod (Domains only) */ - 0, /* Array dimensions of typbasetype */ - false, /* Type NOT NULL */ - collation); /* type's collation */ + typoid = TypeCreate(array_oid, /* force assignment of this type OID */ + array_type, /* type name */ + typeNamespace, /* namespace */ + InvalidOid, /* relation oid (n/a here) */ + 0, /* relation kind (ditto) */ + GetUserId(), /* owner's ID */ + -1, /* internal size (always varlena) */ + TYPTYPE_BASE, /* type-type (base type) */ + TYPCATEGORY_ARRAY, /* type-category (array) */ + false, /* array types are never preferred */ + delimiter, /* array element delimiter */ + F_ARRAY_IN, /* input procedure */ + F_ARRAY_OUT, /* output procedure */ + F_ARRAY_RECV, /* receive procedure */ + F_ARRAY_SEND, /* send procedure */ + typmodinOid, /* typmodin procedure */ + typmodoutOid, /* typmodout procedure */ + F_ARRAY_TYPANALYZE, /* analyze procedure */ + typoid, /* element type ID */ + true, /* yes this is an array type */ + InvalidOid, /* no further array type */ + InvalidOid, /* base type ID */ + NULL, /* never a default type value */ + NULL, /* binary default isn't sent either */ + false, /* never passed by value */ + alignment, /* see above */ + 'x', /* ARRAY is always toastable */ + -1, /* typMod (Domains only) */ + 0, /* Array dimensions of typbasetype */ + false, /* Type NOT NULL */ + collation); /* type's collation */ pfree(array_type); + + return typoid; } /* @@ -671,7 +673,7 @@ RemoveTypeById(Oid typeOid) * DefineDomain * Registers a new domain. */ -void +Oid DefineDomain(CreateDomainStmt *stmt) { char *domainName; @@ -1042,6 +1044,8 @@ DefineDomain(CreateDomainStmt *stmt) * Now we can clean up. */ ReleaseSysCache(typeTup); + + return domainoid; } @@ -3092,7 +3096,7 @@ GetDomainConstraints(Oid typeOid) /* * Execute ALTER TYPE RENAME */ -void +Oid RenameType(RenameStmt *stmt) { List *names = stmt->object; @@ -3161,12 +3165,14 @@ RenameType(RenameStmt *stmt) /* Clean up */ heap_close(rel, RowExclusiveLock); + + return typeOid; } /* * Change the owner of a type. */ -void +Oid AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype) { TypeName *typename; @@ -3283,6 +3289,8 @@ AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype) /* Clean up */ heap_close(rel, RowExclusiveLock); + + return typeOid; } /* @@ -3335,7 +3343,7 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId, /* * Execute ALTER TYPE SET SCHEMA */ -void +Oid AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype) { TypeName *typename; @@ -3360,6 +3368,8 @@ AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype) objsMoved = new_object_addresses(); AlterTypeNamespace_oid(typeOid, nspOid, objsMoved); free_object_addresses(objsMoved); + + return typeOid; } Oid |