aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/typecmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/typecmds.c')
-rw-r--r--src/backend/commands/typecmds.c74
1 files changed, 26 insertions, 48 deletions
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 7d5b409f59e..86d631a0ad7 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.146 2010/01/20 05:47:09 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.147 2010/02/14 18:42:14 rhaas Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@@ -178,10 +178,9 @@ DefineType(List *names, List *parameters)
* Look to see if type already exists (presumably as a shell; if not,
* TypeCreate will complain).
*/
- typoid = GetSysCacheOid(TYPENAMENSP,
- CStringGetDatum(typeName),
- ObjectIdGetDatum(typeNamespace),
- 0, 0);
+ typoid = GetSysCacheOid2(TYPENAMENSP,
+ CStringGetDatum(typeName),
+ ObjectIdGetDatum(typeNamespace));
/*
* If it's not a shell, see if it's an autogenerated array type, and if so
@@ -710,9 +709,7 @@ RemoveTypeById(Oid typeOid)
relation = heap_open(TypeRelationId, RowExclusiveLock);
- tup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(typeOid),
- 0, 0, 0);
+ tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
@@ -787,10 +784,9 @@ DefineDomain(CreateDomainStmt *stmt)
* Check for collision with an existing type name. If there is one and
* it's an autogenerated array, we can rename it out of the way.
*/
- old_type_oid = GetSysCacheOid(TYPENAMENSP,
- CStringGetDatum(domainName),
- ObjectIdGetDatum(domainNamespace),
- 0, 0);
+ old_type_oid = GetSysCacheOid2(TYPENAMENSP,
+ CStringGetDatum(domainName),
+ ObjectIdGetDatum(domainNamespace));
if (OidIsValid(old_type_oid))
{
if (!moveArrayTypeName(old_type_oid, domainName, domainNamespace))
@@ -1113,10 +1109,9 @@ DefineEnum(CreateEnumStmt *stmt)
* Check for collision with an existing type name. If there is one and
* it's an autogenerated array, we can rename it out of the way.
*/
- old_type_oid = GetSysCacheOid(TYPENAMENSP,
- CStringGetDatum(enumName),
- ObjectIdGetDatum(enumNamespace),
- 0, 0);
+ old_type_oid = GetSysCacheOid2(TYPENAMENSP,
+ CStringGetDatum(enumName),
+ ObjectIdGetDatum(enumNamespace));
if (OidIsValid(old_type_oid))
{
if (!moveArrayTypeName(old_type_oid, enumName, enumNamespace))
@@ -1536,10 +1531,10 @@ DefineCompositeType(const RangeVar *typevar, List *coldeflist)
* about a "type" instead of below about a "relation".
*/
typeNamespace = RangeVarGetCreationNamespace(createStmt->relation);
- old_type_oid = GetSysCacheOid(TYPENAMENSP,
- CStringGetDatum(createStmt->relation->relname),
- ObjectIdGetDatum(typeNamespace),
- 0, 0);
+ old_type_oid =
+ GetSysCacheOid2(TYPENAMENSP,
+ CStringGetDatum(createStmt->relation->relname),
+ ObjectIdGetDatum(typeNamespace));
if (OidIsValid(old_type_oid))
{
if (!moveArrayTypeName(old_type_oid, createStmt->relation->relname, typeNamespace))
@@ -1582,9 +1577,7 @@ AlterDomainDefault(List *names, Node *defaultRaw)
/* Look up the domain in the type table */
rel = heap_open(TypeRelationId, RowExclusiveLock);
- tup = SearchSysCacheCopy(TYPEOID,
- ObjectIdGetDatum(domainoid),
- 0, 0, 0);
+ tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -1710,9 +1703,7 @@ AlterDomainNotNull(List *names, bool notNull)
/* Look up the domain in the type table */
typrel = heap_open(TypeRelationId, RowExclusiveLock);
- tup = SearchSysCacheCopy(TYPEOID,
- ObjectIdGetDatum(domainoid),
- 0, 0, 0);
+ tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -1812,9 +1803,7 @@ AlterDomainDropConstraint(List *names, const char *constrName,
/* Look up the domain in the type table */
rel = heap_open(TypeRelationId, RowExclusiveLock);
- tup = SearchSysCacheCopy(TYPEOID,
- ObjectIdGetDatum(domainoid),
- 0, 0, 0);
+ tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
@@ -1887,9 +1876,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint)
/* Look up the domain in the type table */
typrel = heap_open(TypeRelationId, RowExclusiveLock);
- tup = SearchSysCacheCopy(TYPEOID,
- ObjectIdGetDatum(domainoid),
- 0, 0, 0);
+ tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -2399,9 +2386,7 @@ GetDomainConstraints(Oid typeOid)
ScanKeyData key[1];
SysScanDesc scan;
- tup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(typeOid),
- 0, 0, 0);
+ tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -2512,9 +2497,7 @@ RenameType(List *names, const char *newTypeName)
/* Look up the type in the type table */
rel = heap_open(TypeRelationId, RowExclusiveLock);
- tup = SearchSysCacheCopy(TYPEOID,
- ObjectIdGetDatum(typeOid),
- 0, 0, 0);
+ tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -2699,9 +2682,7 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId,
rel = heap_open(TypeRelationId, RowExclusiveLock);
- tup = SearchSysCacheCopy(TYPEOID,
- ObjectIdGetDatum(typeOid),
- 0, 0, 0);
+ tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -2791,9 +2772,7 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
rel = heap_open(TypeRelationId, RowExclusiveLock);
- tup = SearchSysCacheCopy(TYPEOID,
- ObjectIdGetDatum(typeOid),
- 0, 0, 0);
+ tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
typform = (Form_pg_type) GETSTRUCT(tup);
@@ -2821,10 +2800,9 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
errmsg("cannot move objects into or out of TOAST schema")));
/* check for duplicate name (more friendly than unique-index failure) */
- if (SearchSysCacheExists(TYPENAMENSP,
- CStringGetDatum(NameStr(typform->typname)),
- ObjectIdGetDatum(nspOid),
- 0, 0))
+ if (SearchSysCacheExists2(TYPENAMENSP,
+ CStringGetDatum(NameStr(typform->typname)),
+ ObjectIdGetDatum(nspOid)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("type \"%s\" already exists in schema \"%s\"",