attnum++;
attname = entry->colname;
- atttypid = typenameTypeId(NULL, entry->typeName, &atttypmod);
+ typenameTypeIdAndMod(NULL, entry->typeName, &atttypid, &atttypmod);
attdim = list_length(entry->typeName->arrayBounds);
if (entry->typeName->setof)
case OBJECT_TYPE:
address.classId = TypeRelationId;
address.objectId =
- typenameTypeId(NULL, makeTypeNameFromNameList(objname), NULL);
+ typenameTypeId(NULL, makeTypeNameFromNameList(objname));
address.objectSubId = 0;
break;
case OBJECT_AGGREGATE:
{
TypeName *sourcetype = (TypeName *) linitial(objname);
TypeName *targettype = (TypeName *) linitial(objargs);
- Oid sourcetypeid = typenameTypeId(NULL, sourcetype, NULL);
- Oid targettypeid = typenameTypeId(NULL, targettype, NULL);
+ Oid sourcetypeid = typenameTypeId(NULL, sourcetype);
+ Oid targettypeid = typenameTypeId(NULL, targettype);
address.classId = CastRelationId;
address.objectId =
{
numArgs = 1;
aggArgTypes = (Oid *) palloc(sizeof(Oid));
- aggArgTypes[0] = typenameTypeId(NULL, baseType, NULL);
+ aggArgTypes[0] = typenameTypeId(NULL, baseType);
}
}
else
{
TypeName *curTypeName = (TypeName *) lfirst(lc);
- aggArgTypes[i++] = typenameTypeId(NULL, curTypeName, NULL);
+ aggArgTypes[i++] = typenameTypeId(NULL, curTypeName);
}
}
* worse) by connecting up incompatible internal-using functions in an
* aggregate.
*/
- transTypeId = typenameTypeId(NULL, transType, NULL);
+ transTypeId = typenameTypeId(NULL, transType);
if (get_typtype(transTypeId) == TYPTYPE_PSEUDO &&
!IsPolymorphicType(transTypeId))
{
targettype = (TypeName *) linitial(arguments);
Assert(IsA(targettype, TypeName));
- sourcetypeid = typenameTypeId(NULL, sourcetype, NULL);
- targettypeid = typenameTypeId(NULL, targettype, NULL);
+ sourcetypeid = typenameTypeId(NULL, sourcetype);
+ targettypeid = typenameTypeId(NULL, targettype);
/* Permission check */
if (!pg_type_ownercheck(sourcetypeid, GetUserId())
ObjectAddress myself,
referenced;
- sourcetypeid = typenameTypeId(NULL, stmt->sourcetype, NULL);
- targettypeid = typenameTypeId(NULL, stmt->targettype, NULL);
+ sourcetypeid = typenameTypeId(NULL, stmt->sourcetype);
+ targettypeid = typenameTypeId(NULL, stmt->targettype);
sourcetyptype = get_typtype(sourcetypeid);
targettyptype = get_typtype(targettypeid);
ObjectAddress object;
/* when dropping a cast, the types must exist even if you use IF EXISTS */
- sourcetypeid = typenameTypeId(NULL, stmt->sourcetype, NULL);
- targettypeid = typenameTypeId(NULL, stmt->targettype, NULL);
+ sourcetypeid = typenameTypeId(NULL, stmt->sourcetype);
+ targettypeid = typenameTypeId(NULL, stmt->targettype);
object.classId = CastRelationId;
object.objectId = get_cast_oid(sourcetypeid, targettypeid,
errmsg("must be superuser to create an operator class")));
/* Look up the datatype */
- typeoid = typenameTypeId(NULL, stmt->datatype, NULL);
+ typeoid = typenameTypeId(NULL, stmt->datatype);
#ifdef NOT_USED
/* XXX this is unnecessary given the superuser check above */
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("storage type specified more than once")));
- storageoid = typenameTypeId(NULL, item->storedtype, NULL);
+ storageoid = typenameTypeId(NULL, item->storedtype);
#ifdef NOT_USED
/* XXX this is unnecessary given the superuser check above */
Assert(args != NIL);
typeName = (TypeName *) linitial(args);
- *lefttype = typenameTypeId(NULL, typeName, NULL);
+ *lefttype = typenameTypeId(NULL, typeName);
if (list_length(args) > 1)
{
typeName = (TypeName *) lsecond(args);
- *righttype = typenameTypeId(NULL, typeName, NULL);
+ *righttype = typenameTypeId(NULL, typeName);
}
else
*righttype = *lefttype;
/* Transform type names to type OIDs */
if (typeName1)
- typeId1 = typenameTypeId(NULL, typeName1, NULL);
+ typeId1 = typenameTypeId(NULL, typeName1);
if (typeName2)
- typeId2 = typenameTypeId(NULL, typeName2, NULL);
+ typeId2 = typenameTypeId(NULL, typeName2);
if (!OidIsValid(typeId1) && !OidIsValid(typeId2))
ereport(ERROR,
foreach(l, stmt->argtypes)
{
TypeName *tn = lfirst(l);
- Oid toid = typenameTypeId(pstate, tn, NULL);
+ Oid toid = typenameTypeId(pstate, tn);
argtypes[i++] = toid;
}
(void) heap_reloptions(relkind, reloptions, true);
if (stmt->ofTypename)
- ofTypeId = typenameTypeId(NULL, stmt->ofTypename, NULL);
+ ofTypeId = typenameTypeId(NULL, stmt->ofTypename);
else
ofTypeId = InvalidOid;
(errmsg("merging multiple inherited definitions of column \"%s\"",
attributeName)));
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
- defTypeId = typenameTypeId(NULL, def->typeName, &deftypmod);
+ typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
if (defTypeId != attribute->atttypid ||
deftypmod != attribute->atttypmod)
ereport(ERROR,
(errmsg("merging column \"%s\" with inherited definition",
attributeName)));
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
- defTypeId = typenameTypeId(NULL, def->typeName, &deftypmod);
- newTypeId = typenameTypeId(NULL, newdef->typeName, &newtypmod);
+ typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
+ typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod);
if (defTypeId != newTypeId || deftypmod != newtypmod)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
int32 ctypmod;
/* Child column must match by type */
- ctypeId = typenameTypeId(NULL, colDef->typeName, &ctypmod);
+ typenameTypeIdAndMod(NULL, colDef->typeName, &ctypeId, &ctypmod);
if (ctypeId != childatt->atttypid ||
ctypmod != childatt->atttypmod)
ereport(ERROR,
colName)));
/* Look up the target type */
- targettype = typenameTypeId(NULL, typeName, &targettypmod);
+ typenameTypeIdAndMod(NULL, typeName, &targettype, &targettypmod);
/* make sure datatype is legal for a column */
CheckAttributeType(colName, targettype, false);
}
if (elemTypeEl)
{
- elemType = typenameTypeId(NULL, defGetTypeName(elemTypeEl), NULL);
+ elemType = typenameTypeId(NULL, defGetTypeName(elemTypeEl));
/* disallow arrays of pseudotypes */
if (get_typtype(elemType) == TYPTYPE_PSEUDO)
ereport(ERROR,
/* Make a TypeName so we can use standard type lookup machinery */
typename = makeTypeNameFromNameList(stmt->typeName);
- enum_type_oid = typenameTypeId(NULL, typename, NULL);
+ enum_type_oid = typenameTypeId(NULL, typename);
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(enum_type_oid));
if (!HeapTupleIsValid(tup))
/* Make a TypeName so we can use standard type lookup machinery */
typename = makeTypeNameFromNameList(names);
- domainoid = typenameTypeId(NULL, typename, NULL);
+ domainoid = typenameTypeId(NULL, typename);
/* Look up the domain in the type table */
rel = heap_open(TypeRelationId, RowExclusiveLock);
/* Make a TypeName so we can use standard type lookup machinery */
typename = makeTypeNameFromNameList(names);
- domainoid = typenameTypeId(NULL, typename, NULL);
+ domainoid = typenameTypeId(NULL, typename);
/* Look up the domain in the type table */
typrel = heap_open(TypeRelationId, RowExclusiveLock);
/* Make a TypeName so we can use standard type lookup machinery */
typename = makeTypeNameFromNameList(names);
- domainoid = typenameTypeId(NULL, typename, NULL);
+ domainoid = typenameTypeId(NULL, typename);
/* Look up the domain in the type table */
rel = heap_open(TypeRelationId, RowExclusiveLock);
/* Make a TypeName so we can use standard type lookup machinery */
typename = makeTypeNameFromNameList(names);
- domainoid = typenameTypeId(NULL, typename, NULL);
+ domainoid = typenameTypeId(NULL, typename);
/* Look up the domain in the type table */
typrel = heap_open(TypeRelationId, RowExclusiveLock);
/* Make a TypeName so we can use standard type lookup machinery */
typename = makeTypeNameFromNameList(names);
- typeOid = typenameTypeId(NULL, typename, NULL);
+ typeOid = typenameTypeId(NULL, typename);
/* Look up the type in the type table */
rel = heap_open(TypeRelationId, RowExclusiveLock);
/* Make a TypeName so we can use standard type lookup machinery */
typename = makeTypeNameFromNameList(names);
- typeOid = typenameTypeId(NULL, typename, NULL);
+ typeOid = typenameTypeId(NULL, typename);
/* check permissions on type */
if (!pg_type_ownercheck(typeOid, GetUserId()))
Oid elementType;
int32 targetTypmod;
- targetType = typenameTypeId(pstate, tc->typeName,
- &targetTypmod);
+ typenameTypeIdAndMod(pstate, tc->typeName,
+ &targetType, &targetTypmod);
/*
* If target is a domain over array, work with the base
* array type here. transformTypeCast below will cast the
ltype = exprType(lexpr);
foreach(telem, (List *) a->rexpr)
{
- rtype = typenameTypeId(pstate, lfirst(telem), NULL);
+ rtype = typenameTypeId(pstate, lfirst(telem));
matched = (rtype == ltype);
if (matched)
break;
XMLOID,
"XMLSERIALIZE"));
- targetType = typenameTypeId(pstate, xs->typeName, &targetTypmod);
+ typenameTypeIdAndMod(pstate, xs->typeName, &targetType, &targetTypmod);
xexpr->xmloption = xs->xmloption;
xexpr->location = xs->location;
int32 targetTypmod;
int location;
- targetType = typenameTypeId(pstate, tc->typeName, &targetTypmod);
+ typenameTypeIdAndMod(pstate, tc->typeName, &targetType, &targetTypmod);
if (inputType == InvalidOid)
return expr; /* do nothing if NULL input */
if (oprleft == NULL)
leftoid = InvalidOid;
else
- leftoid = typenameTypeId(pstate, oprleft, NULL);
+ leftoid = typenameTypeId(pstate, oprleft);
if (oprright == NULL)
rightoid = InvalidOid;
else
- rightoid = typenameTypeId(pstate, oprright, NULL);
+ rightoid = typenameTypeId(pstate, oprright);
return LookupOperName(pstate, opername, leftoid, rightoid,
noError, location);
errmsg("column \"%s\" cannot be declared SETOF",
attrname),
parser_errposition(pstate, n->typeName->location)));
- attrtype = typenameTypeId(pstate, n->typeName, &attrtypmod);
+ typenameTypeIdAndMod(pstate, n->typeName, &attrtype, &attrtypmod);
eref->colnames = lappend(eref->colnames, makeString(attrname));
rte->funccoltypes = lappend_oid(rte->funccoltypes, attrtype);
rte->funccoltypmods = lappend_int(rte->funccoltypmods, attrtypmod);
}
/*
- * typenameTypeId - given a TypeName, return the type's OID and typmod
+ * typenameTypeId - given a TypeName, return the type's OID
*
- * This is equivalent to typenameType, but we only hand back the type OID
+ * This is similar to typenameType, but we only hand back the type OID
* not the syscache entry.
*/
Oid
-typenameTypeId(ParseState *pstate, const TypeName *typeName, int32 *typmod_p)
+typenameTypeId(ParseState *pstate, const TypeName *typeName)
{
Oid typoid;
Type tup;
- tup = typenameType(pstate, typeName, typmod_p);
+ tup = typenameType(pstate, typeName, NULL);
typoid = HeapTupleGetOid(tup);
ReleaseSysCache(tup);
return typoid;
}
+/*
+ * typenameTypeIdAndMod - given a TypeName, return the type's OID and typmod
+ *
+ * This is equivalent to typenameType, but we only hand back the type OID
+ * and typmod, not the syscache entry.
+ */
+void
+typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName,
+ Oid *typeid_p, int32 *typmod_p)
+{
+ Type tup;
+
+ tup = typenameType(pstate, typeName, typmod_p);
+ *typeid_p = HeapTupleGetOid(tup);
+ ReleaseSysCache(tup);
+}
+
/*
* typenameTypeMod - given a TypeName, return the internal typmod value
*
* the string and convert it to a type OID and type modifier.
*/
void
-parseTypeString(const char *str, Oid *type_id, int32 *typmod_p)
+parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p)
{
StringInfoData buf;
List *raw_parsetree_list;
if (typeName->setof)
goto fail;
- *type_id = typenameTypeId(NULL, typeName, typmod_p);
+ typenameTypeIdAndMod(NULL, typeName, typeid_p, typmod_p);
pfree(buf.data);
Datum interval;
char *intervalout;
- typoid = typenameTypeId(NULL, typeName, &typmod);
+ typenameTypeIdAndMod(NULL, typeName, &typoid, &typmod);
Assert(typoid == INTERVALOID);
interval =
int32 *typmod_p);
extern Type typenameType(ParseState *pstate, const TypeName *typeName,
int32 *typmod_p);
-extern Oid typenameTypeId(ParseState *pstate, const TypeName *typeName,
- int32 *typmod_p);
+extern Oid typenameTypeId(ParseState *pstate, const TypeName *typeName);
+extern void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName,
+ Oid *typeid_p, int32 *typmod_p);
extern char *TypeNameToString(const TypeName *typeName);
extern char *TypeNameListToString(List *typenames);
extern Oid typeidTypeRelid(Oid type_id);
-extern void parseTypeString(const char *str, Oid *type_id, int32 *typmod_p);
+extern void parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p);
#define ISCOMPLEX(typeid) (typeidTypeRelid(typeid) != InvalidOid)