69 #include "utils/fmgroids.h"
114 Oid rangeOid,
Oid subtype);
116 Oid multirangeOid,
Oid rangeOid,
117 Oid rangeArrayOid,
Oid *castFuncOid);
156 int16 internalLength = -1;
165 char category = TYPCATEGORY_USER;
166 bool preferred =
false;
169 char *defaultValue = NULL;
170 bool byValue =
false;
171 char alignment = TYPALIGN_INT;
172 char storage = TYPSTORAGE_PLAIN;
175 DefElem *internalLengthEl = NULL;
180 DefElem *typmodinNameEl = NULL;
181 DefElem *typmodoutNameEl = NULL;
183 DefElem *subscriptNameEl = NULL;
188 DefElem *defaultValueEl = NULL;
220 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
221 errmsg(
"must be superuser to create a base type")));
253 errmsg(
"type \"%s\" already exists", typeName)));
260 if (parameters ==
NIL)
265 errmsg(
"type \"%s\" already exists", typeName)));
278 errmsg(
"type \"%s\" does not exist", typeName),
279 errhint(
"Create the type as a shell type, then create its I/O functions, then do a full CREATE TYPE.")));
282 foreach(pl, parameters)
287 if (strcmp(defel->
defname,
"like") == 0)
288 defelp = &likeTypeEl;
289 else if (strcmp(defel->
defname,
"internallength") == 0)
290 defelp = &internalLengthEl;
291 else if (strcmp(defel->
defname,
"input") == 0)
292 defelp = &inputNameEl;
293 else if (strcmp(defel->
defname,
"output") == 0)
294 defelp = &outputNameEl;
295 else if (strcmp(defel->
defname,
"receive") == 0)
296 defelp = &receiveNameEl;
297 else if (strcmp(defel->
defname,
"send") == 0)
298 defelp = &sendNameEl;
299 else if (strcmp(defel->
defname,
"typmod_in") == 0)
300 defelp = &typmodinNameEl;
301 else if (strcmp(defel->
defname,
"typmod_out") == 0)
302 defelp = &typmodoutNameEl;
303 else if (strcmp(defel->
defname,
"analyze") == 0 ||
304 strcmp(defel->
defname,
"analyse") == 0)
305 defelp = &analyzeNameEl;
306 else if (strcmp(defel->
defname,
"subscript") == 0)
307 defelp = &subscriptNameEl;
308 else if (strcmp(defel->
defname,
"category") == 0)
309 defelp = &categoryEl;
310 else if (strcmp(defel->
defname,
"preferred") == 0)
311 defelp = &preferredEl;
312 else if (strcmp(defel->
defname,
"delimiter") == 0)
313 defelp = &delimiterEl;
314 else if (strcmp(defel->
defname,
"element") == 0)
315 defelp = &elemTypeEl;
316 else if (strcmp(defel->
defname,
"default") == 0)
317 defelp = &defaultValueEl;
318 else if (strcmp(defel->
defname,
"passedbyvalue") == 0)
320 else if (strcmp(defel->
defname,
"alignment") == 0)
321 defelp = &alignmentEl;
322 else if (strcmp(defel->
defname,
"storage") == 0)
324 else if (strcmp(defel->
defname,
"collatable") == 0)
325 defelp = &collatableEl;
330 (
errcode(ERRCODE_SYNTAX_ERROR),
331 errmsg(
"type attribute \"%s\" not recognized",
353 internalLength = likeForm->typlen;
354 byValue = likeForm->typbyval;
355 alignment = likeForm->typalign;
356 storage = likeForm->typstorage;
359 if (internalLengthEl)
383 if (category < 32 || category > 126)
385 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
386 errmsg(
"invalid type category \"%s\": must be simple ASCII",
404 (
errcode(ERRCODE_DATATYPE_MISMATCH),
405 errmsg(
"array element type cannot be %s",
424 alignment = TYPALIGN_DOUBLE;
427 alignment = TYPALIGN_INT;
430 alignment = TYPALIGN_SHORT;
433 alignment = TYPALIGN_CHAR;
436 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
437 errmsg(
"alignment \"%s\" not recognized",
a)));
453 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
454 errmsg(
"storage \"%s\" not recognized",
a)));
462 if (inputName ==
NIL)
464 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
465 errmsg(
"type input function must be specified")));
466 if (outputName ==
NIL)
468 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
469 errmsg(
"type output function must be specified")));
471 if (typmodinName ==
NIL && typmodoutName !=
NIL)
473 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
474 errmsg(
"type modifier output function is useless without a type modifier input function")));
511 if (internalLength > 0 && !byValue &&
get_typlen(elemType) > 0)
512 subscriptOid = F_RAW_ARRAY_SUBSCRIPT_HANDLER;
515 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
516 errmsg(
"element type cannot be specified without a subscripting function")));
613 alignment = (alignment == TYPALIGN_DOUBLE) ? TYPALIGN_DOUBLE : TYPALIGN_INT;
633 F_ARRAY_SUBSCRIPT_HANDLER,
666 elog(
ERROR,
"cache lookup failed for type %u", typeOid);
700 char *domainArrayName;
703 int16 internalLength;
706 Oid receiveProcedure;
708 Oid analyzeProcedure;
717 char *defaultValue = NULL;
718 char *defaultValueBin = NULL;
719 bool saw_default =
false;
720 bool typNotNull =
false;
721 bool nullDefined =
false;
758 errmsg(
"type \"%s\" already exists", domainName)));
766 basetypeoid = baseType->oid;
776 typtype = baseType->typtype;
777 if (typtype != TYPTYPE_BASE &&
778 typtype != TYPTYPE_COMPOSITE &&
779 typtype != TYPTYPE_DOMAIN &&
780 typtype != TYPTYPE_ENUM &&
781 typtype != TYPTYPE_RANGE &&
782 typtype != TYPTYPE_MULTIRANGE)
784 (
errcode(ERRCODE_DATATYPE_MISMATCH),
785 errmsg(
"\"%s\" is not a valid base type for a domain",
801 baseColl = baseType->typcollation;
802 if (
stmt->collClause)
805 domaincoll = baseColl;
810 (
errcode(ERRCODE_DATATYPE_MISMATCH),
811 errmsg(
"collations are not supported by type %s",
815 byValue = baseType->typbyval;
818 alignment = baseType->typalign;
821 storage = baseType->typstorage;
824 internalLength = baseType->typlen;
827 category = baseType->typcategory;
830 delimiter = baseType->typdelim;
833 inputProcedure = F_DOMAIN_IN;
834 outputProcedure = baseType->typoutput;
835 receiveProcedure = F_DOMAIN_RECV;
836 sendProcedure = baseType->typsend;
841 analyzeProcedure = baseType->typanalyze;
851 Anum_pg_type_typdefault, &isnull);
857 Anum_pg_type_typdefaultbin, &isnull);
865 foreach(listptr, schema)
870 elog(
ERROR,
"unrecognized node type: %d",
882 (
errcode(ERRCODE_SYNTAX_ERROR),
883 errmsg(
"multiple default expressions")));
914 if (defaultExpr == NULL ||
916 ((
Const *) defaultExpr)->constisnull))
919 defaultValueBin = NULL;
938 defaultValueBin = NULL;
943 if (nullDefined && !typNotNull)
945 (
errcode(ERRCODE_SYNTAX_ERROR),
946 errmsg(
"conflicting NULL/NOT NULL constraints")));
952 if (nullDefined && typNotNull)
954 (
errcode(ERRCODE_SYNTAX_ERROR),
955 errmsg(
"conflicting NULL/NOT NULL constraints")));
970 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
971 errmsg(
"check constraints for domains cannot be marked NO INHERIT")));
979 (
errcode(ERRCODE_SYNTAX_ERROR),
980 errmsg(
"unique constraints not possible for domains")));
985 (
errcode(ERRCODE_SYNTAX_ERROR),
986 errmsg(
"primary key constraints not possible for domains")));
991 (
errcode(ERRCODE_SYNTAX_ERROR),
992 errmsg(
"exclusion constraints not possible for domains")));
997 (
errcode(ERRCODE_SYNTAX_ERROR),
998 errmsg(
"foreign key constraints not possible for domains")));
1006 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1007 errmsg(
"specifying constraint deferrability not supported for domains")));
1011 elog(
ERROR,
"unrecognized constraint subtype: %d",
1063 alignment = (alignment == TYPALIGN_DOUBLE) ? TYPALIGN_DOUBLE : TYPALIGN_INT;
1083 F_ARRAY_SUBSCRIPT_HANDLER,
1092 TYPSTORAGE_EXTENDED,
1098 pfree(domainArrayName);
1103 foreach(listptr, schema)
1113 basetypeoid, basetypeMod,
1114 constr, domainName, NULL);
1119 basetypeoid, basetypeMod,
1120 constr, domainName, NULL);
1150 char *enumArrayName;
1179 errmsg(
"type \"%s\" already exists", enumName)));
1246 F_ARRAY_SUBSCRIPT_HANDLER,
1255 TYPSTORAGE_EXTENDED,
1261 pfree(enumArrayName);
1263 return enumTypeAddr;
1284 elog(
ERROR,
"cache lookup failed for type %u", enum_type_oid);
1300 stmt->newValNeighbor,
stmt->newValIsAfter,
1301 stmt->skipIfNewValExists);
1324 if (typTup->typtype != TYPTYPE_ENUM)
1326 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
1327 errmsg(
"%s is not an enum",
1351 char *rangeArrayName;
1352 char *multirangeTypeName = NULL;
1353 char *multirangeArrayName;
1357 Oid multirangeArrayOid;
1359 List *rangeSubOpclassName =
NIL;
1360 List *rangeCollationName =
NIL;
1361 List *rangeCanonicalName =
NIL;
1362 List *rangeSubtypeDiffName =
NIL;
1363 Oid rangeSubOpclass;
1405 errmsg(
"type \"%s\" already exists", typeName)));
1414 foreach(lc,
stmt->params)
1418 if (strcmp(defel->
defname,
"subtype") == 0)
1425 else if (strcmp(defel->
defname,
"subtype_opclass") == 0)
1427 if (rangeSubOpclassName !=
NIL)
1431 else if (strcmp(defel->
defname,
"collation") == 0)
1433 if (rangeCollationName !=
NIL)
1437 else if (strcmp(defel->
defname,
"canonical") == 0)
1439 if (rangeCanonicalName !=
NIL)
1443 else if (strcmp(defel->
defname,
"subtype_diff") == 0)
1445 if (rangeSubtypeDiffName !=
NIL)
1449 else if (strcmp(defel->
defname,
"multirange_type_name") == 0)
1451 if (multirangeTypeName != NULL)
1455 &multirangeTypeName);
1459 (
errcode(ERRCODE_SYNTAX_ERROR),
1460 errmsg(
"type attribute \"%s\" not recognized",
1467 (
errcode(ERRCODE_SYNTAX_ERROR),
1468 errmsg(
"type attribute \"subtype\" is required")));
1472 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1473 errmsg(
"range subtype cannot be %s",
1482 if (rangeCollationName !=
NIL)
1489 if (rangeCollationName !=
NIL)
1491 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
1492 errmsg(
"range collation specified but subtype does not support collation")));
1497 if (rangeCanonicalName !=
NIL)
1501 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1502 errmsg(
"cannot specify a canonical function without a pre-created shell type"),
1503 errhint(
"Create the type as a shell type, then create its canonicalization function, then do a full CREATE TYPE.")));
1510 if (rangeSubtypeDiffName !=
NIL)
1517 &subtyplen, &subtypbyval, &subtypalign);
1520 alignment = (subtypalign == TYPALIGN_DOUBLE) ? TYPALIGN_DOUBLE : TYPALIGN_INT;
1556 TYPSTORAGE_EXTENDED,
1565 if (multirangeTypeName)
1585 errmsg(
"type \"%s\" already exists", multirangeTypeName)));
1591 multirangeNamespace = typeNamespace;
1598 multirangeNamespace,
1613 F_MULTIRANGE_TYPANALYZE,
1628 Assert(multirangeOid == mltrngaddress.objectId);
1631 RangeCreate(typoid, rangeSubtype, rangeCollation, rangeSubOpclass,
1632 rangeCanonical, rangeSubtypeDiff, multirangeOid);
1657 F_ARRAY_SUBSCRIPT_HANDLER,
1666 TYPSTORAGE_EXTENDED,
1672 pfree(rangeArrayName);
1679 multirangeArrayName,
1680 multirangeNamespace,
1696 F_ARRAY_SUBSCRIPT_HANDLER,
1714 multirangeOid, typoid, rangeArrayOid,
1719 COERCION_CODE_EXPLICIT, COERCION_METHOD_FUNCTION,
1722 pfree(multirangeArrayName);
1738 Oid rangeOid,
Oid subtype)
1740 static const char *
const prosrc[2] = {
"range_constructor2",
1741 "range_constructor3"};
1742 static const int pronargs[2] = {2, 3};
1744 Oid constructorArgTypes[3];
1749 constructorArgTypes[0] = subtype;
1750 constructorArgTypes[1] = subtype;
1751 constructorArgTypes[2] = TEXTOID;
1753 referenced.
classId = TypeRelationId;
1769 BOOTSTRAP_SUPERUSERID,
1771 F_FMGR_INTERNAL_VALIDATOR,
1779 PROVOLATILE_IMMUTABLE,
1781 constructorArgTypesVector,
1812 Oid multirangeOid,
Oid rangeOid,
Oid rangeArrayOid,
1818 Datum allParamTypes;
1823 referenced.
classId = TypeRelationId;
1824 referenced.
objectId = multirangeOid;
1834 BOOTSTRAP_SUPERUSERID,
1836 F_FMGR_INTERNAL_VALIDATOR,
1837 "multirange_constructor0",
1844 PROVOLATILE_IMMUTABLE,
1878 BOOTSTRAP_SUPERUSERID,
1880 F_FMGR_INTERNAL_VALIDATOR,
1881 "multirange_constructor1",
1888 PROVOLATILE_IMMUTABLE,
1916 BOOTSTRAP_SUPERUSERID,
1918 F_FMGR_INTERNAL_VALIDATOR,
1919 "multirange_constructor2",
1926 PROVOLATILE_IMMUTABLE,
1941 pfree(allParameterTypes);
1942 pfree(parameterModes);
1964 argList[0] = CSTRINGOID;
1965 argList[1] = OIDOID;
1966 argList[2] = INT4OID;
1974 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
1975 errmsg(
"type input function %s has multiple matches",
1984 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
1985 errmsg(
"function %s does not exist",
1992 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1993 errmsg(
"type input function %s must return type %s",
2008 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2009 errmsg(
"type input function %s should not be volatile",
2025 argList[0] = typeOid;
2030 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2031 errmsg(
"function %s does not exist",
2036 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2037 errmsg(
"type output function %s must return type %s",
2043 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2044 errmsg(
"type output function %s should not be volatile",
2062 argList[0] = INTERNALOID;
2063 argList[1] = OIDOID;
2064 argList[2] = INT4OID;
2072 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2073 errmsg(
"type receive function %s has multiple matches",
2082 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2083 errmsg(
"function %s does not exist",
2090 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2091 errmsg(
"type receive function %s must return type %s",
2097 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2098 errmsg(
"type receive function %s should not be volatile",
2114 argList[0] = typeOid;
2119 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2120 errmsg(
"function %s does not exist",
2125 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2126 errmsg(
"type send function %s must return type %s",
2132 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2133 errmsg(
"type send function %s should not be volatile",
2148 argList[0] = CSTRINGARRAYOID;
2153 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2154 errmsg(
"function %s does not exist",
2159 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2160 errmsg(
"typmod_in function %s must return type %s",
2166 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2167 errmsg(
"type modifier input function %s should not be volatile",
2182 argList[0] = INT4OID;
2187 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2188 errmsg(
"function %s does not exist",
2193 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2194 errmsg(
"typmod_out function %s must return type %s",
2200 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2201 errmsg(
"type modifier output function %s should not be volatile",
2216 argList[0] = INTERNALOID;
2221 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2222 errmsg(
"function %s does not exist",
2227 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2228 errmsg(
"type analyze function %s must return type %s",
2245 argList[0] = INTERNALOID;
2250 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2251 errmsg(
"function %s does not exist",
2256 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2257 errmsg(
"type subscripting function %s must return type %s",
2264 if (procOid == F_ARRAY_SUBSCRIPT_HANDLER)
2266 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2267 errmsg(
"user-defined types cannot use subscripting function %s",
2298 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2299 errmsg(
"operator class \"%s\" does not accept data type %s",
2310 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2311 errmsg(
"data type %s has no default operator class for access method \"%s\"",
2313 errhint(
"You must specify an operator class for the range type or define a default operator class for the subtype.")));
2331 argList[0] = typeOid;
2337 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2338 errmsg(
"function %s does not exist",
2343 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2344 errmsg(
"range canonical function %s must return range type",
2349 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2350 errmsg(
"range canonical function %s must be immutable",
2372 argList[0] = subtype;
2373 argList[1] = subtype;
2379 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2380 errmsg(
"function %s does not exist",
2385 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2386 errmsg(
"range subtype diff function %s must return type %s",
2388 "double precision")));
2392 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2393 errmsg(
"range subtype diff function %s must be immutable",
2419 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2420 errmsg(
"pg_type array OID value not set when in binary upgrade mode")));
2434 return type_array_oid;
2445 Oid type_multirange_oid;
2452 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2453 errmsg(
"pg_type multirange OID value not set when in binary upgrade mode")));
2467 return type_multirange_oid;
2478 Oid type_multirange_array_oid;
2485 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2486 errmsg(
"pg_type multirange array OID value not set when in binary upgrade mode")));
2500 return type_multirange_array_oid;
2584 Node *defaultExpr = NULL;
2585 Datum new_record[Natts_pg_type] = {0};
2586 bool new_record_nulls[Natts_pg_type] = {0};
2587 bool new_record_repl[Natts_pg_type] = {0};
2601 elog(
ERROR,
"cache lookup failed for type %u", domainoid);
2620 typTup->typbasetype,
2630 if (defaultExpr == NULL ||
2631 (
IsA(defaultExpr,
Const) && ((
Const *) defaultExpr)->constisnull))
2635 new_record_nulls[Anum_pg_type_typdefaultbin - 1] =
true;
2636 new_record_repl[Anum_pg_type_typdefaultbin - 1] =
true;
2637 new_record_nulls[Anum_pg_type_typdefault - 1] =
true;
2638 new_record_repl[Anum_pg_type_typdefault - 1] =
true;
2655 new_record_repl[Anum_pg_type_typdefaultbin - 1] =
true;
2657 new_record_repl[Anum_pg_type_typdefault - 1] =
true;
2663 new_record_nulls[Anum_pg_type_typdefaultbin - 1] =
true;
2664 new_record_repl[Anum_pg_type_typdefaultbin - 1] =
true;
2665 new_record_nulls[Anum_pg_type_typdefault - 1] =
true;
2666 new_record_repl[Anum_pg_type_typdefault - 1] =
true;
2670 new_record, new_record_nulls,
2723 elog(
ERROR,
"cache lookup failed for type %u", domainoid);
2730 if (typTup->typnotnull == notNull)
2746 typTup->typbasetype, typTup->typtypmod,
2747 constr,
NameStr(typTup->typname), NULL);
2758 elog(
ERROR,
"could not find not-null constraint on domain \"%s\"",
NameStr(typTup->typname));
2768 typTup->typnotnull = notNull;
2814 elog(
ERROR,
"cache lookup failed for type %u", domainoid);
2824 Anum_pg_constraint_conrelid,
2828 Anum_pg_constraint_contypid,
2832 Anum_pg_constraint_conname,
2845 if (construct->contype == CONSTRAINT_NOTNULL)
2851 conobj.
classId = ConstraintRelationId;
2867 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2868 errmsg(
"constraint \"%s\" of domain \"%s\" does not exist",
2872 (
errmsg(
"constraint \"%s\" of domain \"%s\" does not exist, skipping",
2918 elog(
ERROR,
"cache lookup failed for type %u", domainoid);
2925 elog(
ERROR,
"unrecognized node type: %d",
2926 (
int)
nodeTag(newConstraint));
2939 (
errcode(ERRCODE_SYNTAX_ERROR),
2940 errmsg(
"unique constraints not possible for domains")));
2945 (
errcode(ERRCODE_SYNTAX_ERROR),
2946 errmsg(
"primary key constraints not possible for domains")));
2951 (
errcode(ERRCODE_SYNTAX_ERROR),
2952 errmsg(
"exclusion constraints not possible for domains")));
2957 (
errcode(ERRCODE_SYNTAX_ERROR),
2958 errmsg(
"foreign key constraints not possible for domains")));
2966 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2967 errmsg(
"specifying constraint deferrability not supported for domains")));
2971 elog(
ERROR,
"unrecognized constraint subtype: %d",
2984 typTup->typbasetype, typTup->typtypmod,
2985 constr,
NameStr(typTup->typname), constrAddr);
3007 if (typTup->typnotnull)
3013 typTup->typbasetype, typTup->typtypmod,
3014 constr,
NameStr(typTup->typname), constrAddr);
3019 typTup->typnotnull =
true;
3063 elog(
ERROR,
"cache lookup failed for type %u", domainoid);
3074 Anum_pg_constraint_conrelid,
3078 Anum_pg_constraint_contypid,
3082 Anum_pg_constraint_conname,
3092 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3093 errmsg(
"constraint \"%s\" of domain \"%s\" does not exist",
3097 if (con->contype != CONSTRAINT_CHECK)
3099 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3100 errmsg(
"constraint \"%s\" of domain \"%s\" is not a check constraint",
3113 copy_con->convalidated =
true;
3179 (
errcode(ERRCODE_NOT_NULL_VIOLATION),
3180 errmsg(
"column \"%s\" of table \"%s\" contains null values",
3268 (
errcode(ERRCODE_CHECK_VIOLATION),
3269 errmsg(
"column \"%s\" of table \"%s\" contains values that violate the new constraint",
3342 Anum_pg_depend_refclassid,
3346 Anum_pg_depend_refobjid,
3362 if (pg_depend->classid == TypeRelationId)
3364 if (
get_typtype(pg_depend->objid) == TYPTYPE_DOMAIN)
3392 if (pg_depend->classid != RelationRelationId ||
3393 pg_depend->objsubid <= 0)
3397 foreach(rellist, result)
3433 if (rel->
rd_rel->relkind != RELKIND_RELATION &&
3434 rel->
rd_rel->relkind != RELKIND_MATVIEW)
3445 result =
lappend(result, rtc);
3457 if (pg_att->attisdropped || pg_att->atttypid != domainOid)
3468 while (ptr > 0 && rtc->
atts[ptr - 1] > pg_depend->objsubid)
3470 rtc->
atts[ptr] = rtc->
atts[ptr - 1];
3473 rtc->
atts[ptr] = pg_depend->objsubid;
3495 if (typTup->typtype != TYPTYPE_DOMAIN)
3497 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3498 errmsg(
"%s is not a domain",
3532 errmsg(
"constraint \"%s\" for domain \"%s\" already exists",
3533 constr->
conname, domainName)));
3555 domVal->
typeId = baseTypeOid;
3556 domVal->typeMod = typMod;
3582 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
3583 errmsg(
"cannot use table references in domain check constraint")));
3652 colname =
strVal(field1);
3653 if (strcmp(colname,
"value") == 0)
3659 return (
Node *) domVal;
3687 errmsg(
"constraint \"%s\" for domain \"%s\" already exists",
3688 constr->
conname, domainName)));
3746 const char *newTypeName =
stmt->newname;
3763 elog(
ERROR,
"cache lookup failed for type %u", typeOid);
3773 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3774 errmsg(
"%s is not a domain",
3782 if (typTup->typtype == TYPTYPE_COMPOSITE &&
3785 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3786 errmsg(
"%s is a table's row type",
3793 if (IsTrueArrayType(typTup))
3795 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3796 errmsg(
"cannot alter array type %s",
3798 errhint(
"You can alter type %s, which will alter the array type as well.",
3807 if (typTup->typtype == TYPTYPE_COMPOSITE)
3811 typTup->typnamespace);
3844 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3845 errmsg(
"type \"%s\" does not exist",
3856 if (objecttype ==
OBJECT_DOMAIN && typTup->typtype != TYPTYPE_DOMAIN)
3858 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3859 errmsg(
"%s is not a domain",
3867 if (typTup->typtype == TYPTYPE_COMPOSITE &&
3870 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3871 errmsg(
"%s is a table's row type",
3878 if (IsTrueArrayType(typTup))
3880 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3881 errmsg(
"cannot alter array type %s",
3883 errhint(
"You can alter type %s, which will alter the array type as well.",
3887 if (typTup->typtype == TYPTYPE_MULTIRANGE)
3893 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3894 errmsg(
"cannot alter multirange type %s",
3897 errhint(
"You can alter type %s, which will alter the multirange type as well.",
3905 if (typTup->typowner != newOwnerId)
3918 aclresult =
object_aclcheck(NamespaceRelationId, typTup->typnamespace,
3959 elog(
ERROR,
"cache lookup failed for type %u", typeOid);
3967 if (typTup->typtype == TYPTYPE_COMPOSITE)
3994 Datum repl_val[Natts_pg_type];
3995 bool repl_null[Natts_pg_type];
3996 bool repl_repl[Natts_pg_type];
4005 elog(
ERROR,
"cache lookup failed for type %u", typeOid);
4008 memset(repl_null,
false,
sizeof(repl_null));
4009 memset(repl_repl,
false,
sizeof(repl_repl));
4011 repl_repl[Anum_pg_type_typowner - 1] =
true;
4015 Anum_pg_type_typacl,
4022 typTup->typowner, newOwnerId);
4023 repl_repl[Anum_pg_type_typacl - 1] =
true;
4037 if (typTup->typtype == TYPTYPE_RANGE)
4043 (
errcode(ERRCODE_UNDEFINED_OBJECT),
4044 errmsg(
"could not find multirange type for data type %s",
4074 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
4075 errmsg(
"%s is not a domain",
4086 *oldschema = oldNspOid;
4119 if (ignoreDependent)
4122 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
4123 errmsg(
"cannot alter array type %s",
4125 errhint(
"You can alter type %s, which will alter the array type as well.",
4159 bool isImplicitArray,
4160 bool ignoreDependent,
4161 bool errorOnTableType,
4175 thisobj.
classId = TypeRelationId;
4186 elog(
ERROR,
"cache lookup failed for type %u", typeOid);
4189 oldNspOid = typform->typnamespace;
4190 arrayOid = typform->typarray;
4193 if (oldNspOid != nspOid)
4204 errmsg(
"type \"%s\" already exists in schema \"%s\"",
4211 (typform->typtype == TYPTYPE_COMPOSITE &&
4217 if (ignoreDependent)
4222 if (errorOnTableType)
4224 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
4225 errmsg(
"%s is a table's row type",
4228 errhint(
"Use %s instead.",
"ALTER TABLE")));
4231 if (oldNspOid != nspOid)
4236 typform->typnamespace = nspOid;
4264 nspOid,
false, objsMoved);
4269 if (typform->typtype == TYPTYPE_DOMAIN)
4278 if (oldNspOid != nspOid &&
4282 NamespaceRelationId, oldNspOid, nspOid) != 1)
4283 elog(
ERROR,
"could not change schema dependency for type \"%s\"",
4322 bool requireSuper =
false;
4336 memset(&atparams, 0,
sizeof(atparams));
4337 foreach(pl,
stmt->options)
4341 if (strcmp(defel->
defname,
"storage") == 0)
4346 atparams.
storage = TYPSTORAGE_PLAIN;
4348 atparams.
storage = TYPSTORAGE_EXTERNAL;
4350 atparams.
storage = TYPSTORAGE_EXTENDED;
4352 atparams.
storage = TYPSTORAGE_MAIN;
4355 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4356 errmsg(
"storage \"%s\" not recognized",
a)));
4362 if (atparams.
storage != TYPSTORAGE_PLAIN && typForm->typlen != -1)
4364 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4365 errmsg(
"fixed-size types must have storage PLAIN")));
4377 if (atparams.
storage != TYPSTORAGE_PLAIN &&
4378 typForm->typstorage == TYPSTORAGE_PLAIN)
4379 requireSuper =
true;
4380 else if (atparams.
storage == TYPSTORAGE_PLAIN &&
4381 typForm->typstorage != TYPSTORAGE_PLAIN)
4383 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4384 errmsg(
"cannot change type's storage to PLAIN")));
4388 else if (strcmp(defel->
defname,
"receive") == 0)
4390 if (defel->
arg != NULL)
4398 requireSuper =
true;
4400 else if (strcmp(defel->
defname,
"send") == 0)
4402 if (defel->
arg != NULL)
4410 requireSuper =
true;
4412 else if (strcmp(defel->
defname,
"typmod_in") == 0)
4414 if (defel->
arg != NULL)
4421 requireSuper =
true;
4423 else if (strcmp(defel->
defname,
"typmod_out") == 0)
4425 if (defel->
arg != NULL)
4432 requireSuper =
true;
4434 else if (strcmp(defel->
defname,
"analyze") == 0)
4436 if (defel->
arg != NULL)
4444 requireSuper =
true;
4446 else if (strcmp(defel->
defname,
"subscript") == 0)
4448 if (defel->
arg != NULL)
4456 requireSuper =
true;
4463 else if (strcmp(defel->
defname,
"input") == 0 ||
4464 strcmp(defel->
defname,
"output") == 0 ||
4465 strcmp(defel->
defname,
"internallength") == 0 ||
4466 strcmp(defel->
defname,
"passedbyvalue") == 0 ||
4467 strcmp(defel->
defname,
"alignment") == 0 ||
4468 strcmp(defel->
defname,
"like") == 0 ||
4469 strcmp(defel->
defname,
"category") == 0 ||
4470 strcmp(defel->
defname,
"preferred") == 0 ||
4471 strcmp(defel->
defname,
"default") == 0 ||
4472 strcmp(defel->
defname,
"element") == 0 ||
4473 strcmp(defel->
defname,
"delimiter") == 0 ||
4474 strcmp(defel->
defname,
"collatable") == 0)
4476 (
errcode(ERRCODE_SYNTAX_ERROR),
4477 errmsg(
"type attribute \"%s\" cannot be changed",
4481 (
errcode(ERRCODE_SYNTAX_ERROR),
4482 errmsg(
"type attribute \"%s\" not recognized",
4494 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4495 errmsg(
"must be superuser to alter a type")));
4513 if (typForm->typtype != TYPTYPE_BASE)
4515 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
4516 errmsg(
"%s is not a base type",
4522 if (IsTrueArrayType(typForm))
4524 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
4525 errmsg(
"%s is not a base type",
4570 bool nulls[Natts_pg_type];
4571 bool replaces[Natts_pg_type];
4582 memset(nulls, 0,
sizeof(nulls));
4583 memset(replaces, 0,
sizeof(replaces));
4587 replaces[Anum_pg_type_typstorage - 1] =
true;
4592 replaces[Anum_pg_type_typreceive - 1] =
true;
4597 replaces[Anum_pg_type_typsend - 1] =
true;
4602 replaces[Anum_pg_type_typmodin - 1] =
true;
4607 replaces[Anum_pg_type_typmodout - 1] =
true;
4612 replaces[Anum_pg_type_typanalyze - 1] =
true;
4617 replaces[Anum_pg_type_typsubscript - 1] =
true;
4622 values, nulls, replaces);
4644 if (!isImplicitArray &&
4656 elog(
ERROR,
"cache lookup failed for type %u", arrtypoid);
4658 memset(&arrparams, 0,
sizeof(arrparams));
4687 Anum_pg_type_typbasetype,
4702 if (domainForm->typtype != TYPTYPE_DOMAIN)
Acl * aclnewowner(const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId)
void check_can_set_role(Oid member, Oid role)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
void aclcheck_error_type(AclResult aclerr, Oid typeOid)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define OidIsValid(objectId)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
int defGetTypeLength(DefElem *def)
bool defGetBoolean(DefElem *def)
List * defGetQualifiedName(DefElem *def)
char * defGetString(DefElem *def)
void errorConflictingDefElem(DefElem *defel, ParseState *pstate)
TypeName * defGetTypeName(DefElem *def)
void performDeletion(const ObjectAddress *object, DropBehavior behavior, int flags)
bool object_address_present(const ObjectAddress *object, const ObjectAddresses *addrs)
ObjectAddresses * new_object_addresses(void)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
void free_object_addresses(ObjectAddresses *addrs)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
ExprState * ExecPrepareExpr(Expr *node, EState *estate)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
EState * CreateExecutorState(void)
void FreeExecutorState(EState *estate)
#define GetPerTupleExprContext(estate)
#define ResetExprContext(econtext)
static Datum ExecEvalExprSwitchContext(ExprState *state, ExprContext *econtext, bool *isNull)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Node * cookDefault(ParseState *pstate, Node *raw_default, Oid atttypid, int32 atttypmod, const char *attname, char attgenerated)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_copytuple(HeapTuple tuple)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Oid GetDefaultOpClass(Oid type_id, Oid am_id)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
void CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple, HeapTuple newtuple)
List * lappend(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
#define AccessExclusiveLock
Oid get_element_type(Oid typid)
Oid get_opclass_input_type(Oid opclass)
Oid get_multirange_range(Oid multirangeOid)
char * get_namespace_name(Oid nspid)
bool get_typisdefined(Oid typid)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
char get_rel_relkind(Oid relid)
Oid get_typcollation(Oid typid)
char func_volatile(Oid funcid)
char * get_func_name(Oid funcid)
Oid get_range_multirange(Oid rangeOid)
bool type_is_collatable(Oid typid)
int16 get_typlen(Oid typid)
char get_typtype(Oid typid)
Oid get_array_type(Oid typid)
Oid get_func_rettype(Oid funcid)
TypeName * makeTypeNameFromNameList(List *names)
void pfree(void *pointer)
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *relation, LOCKMODE lockmode, Oid *existing_relation_id)
Oid QualifiedNameGetCreationNamespace(const List *names, char **objname_p)
Oid LookupCreationNamespace(const char *nspname)
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Oid get_collation_oid(List *collname, bool missing_ok)
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
char * NameListToString(const List *names)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
#define InvokeObjectPostAlterHook(classId, objectId, subId)
const ObjectAddress InvalidObjectAddress
#define ObjectAddressSet(addr, class_id, object_id)
oidvector * buildoidvector(const Oid *oids, int n)
Oid get_opclass_oid(Oid amID, List *opclassname, bool missing_ok)
char * nodeToString(const void *obj)
Node * coerce_to_boolean(ParseState *pstate, Node *node, const char *constructName)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
void assign_expr_collations(ParseState *pstate, Node *expr)
Node * transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKind)
const char * func_signature_string(List *funcname, int nargs, List *argnames, const Oid *argtypes)
Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool missing_ok)
static bool isCompositeType(Oid typid)
int parser_errposition(ParseState *pstate, int location)
ParseState * make_parsestate(ParseState *parentParseState)
Type LookupTypeName(ParseState *pstate, const TypeName *typeName, int32 *typmod_p, bool missing_ok)
char * TypeNameToString(const TypeName *typeName)
Type typenameType(ParseState *pstate, const TypeName *typeName, int32 *typmod_p)
Oid typenameTypeId(ParseState *pstate, const TypeName *typeName)
@ CONSTR_ATTR_NOT_DEFERRABLE
FormData_pg_attribute * Form_pg_attribute
ObjectAddress CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, Oid incastid, Oid outcastid, char castcontext, char castmethod, DependencyType behavior)
char * ChooseConstraintName(const char *name1, const char *name2, const char *label, Oid namespaceid, List *others)
bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId, const char *conname)
Oid CreateConstraintEntry(const char *constraintName, Oid constraintNamespace, char constraintType, bool isDeferrable, bool isDeferred, bool isValidated, Oid parentConstrId, Oid relId, const int16 *constraintKey, int constraintNKeys, int constraintNTotalKeys, Oid domainId, Oid indexRelId, Oid foreignRelId, const int16 *foreignKey, const Oid *pfEqOp, const Oid *ppEqOp, const Oid *ffEqOp, int foreignNKeys, char foreignUpdateType, char foreignDeleteType, const int16 *fkDeleteSetCols, int numFkDeleteSetCols, char foreignMatchType, const Oid *exclOp, Node *conExpr, const char *conBin, bool conIsLocal, int conInhCount, bool conNoInherit, bool conPeriod, bool is_internal)
HeapTuple findDomainNotNullConstraint(Oid typid)
void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId, Oid newNspId, bool isType, ObjectAddresses *objsMoved)
FormData_pg_constraint * Form_pg_constraint
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
long changeDependencyFor(Oid classId, Oid objectId, Oid refClassId, Oid oldRefObjectId, Oid newRefObjectId)
FormData_pg_depend * Form_pg_depend
void RenameEnumLabel(Oid enumTypeOid, const char *oldVal, const char *newVal)
void EnumValuesDelete(Oid enumTypeOid)
void AddEnumLabel(Oid enumTypeOid, const char *newVal, const char *neighbor, bool newValIsAfter, bool skipIfExists)
void EnumValuesCreate(Oid enumTypeOid, List *vals)
static int list_length(const List *l)
ObjectAddress ProcedureCreate(const char *procedureName, Oid procNamespace, bool replace, bool returnsSet, Oid returnType, Oid proowner, Oid languageObjectId, Oid languageValidator, const char *prosrc, const char *probin, Node *prosqlbody, char prokind, bool security_definer, bool isLeakProof, bool isStrict, char volatility, char parallel, oidvector *parameterTypes, Datum allParameterTypes, Datum parameterModes, Datum parameterNames, List *parameterDefaults, Datum trftypes, Datum proconfig, Oid prosupport, float4 procost, float4 prorows)
void RangeCreate(Oid rangeTypeOid, Oid rangeSubType, Oid rangeCollation, Oid rangeSubOpclass, RegProcedure rangeCanonical, RegProcedure rangeSubDiff, Oid multirangeTypeOid)
void RangeDelete(Oid rangeTypeOid)
void changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId)
char * makeMultirangeTypeName(const char *rangeTypeName, Oid typeNamespace)
void GenerateTypeDependencies(HeapTuple typeTuple, Relation typeCatalog, Node *defaultExpr, void *typacl, char relationKind, bool isImplicitArray, bool isDependentType, bool makeExtensionDep, bool rebuild)
void RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
ObjectAddress TypeCreate(Oid newTypeOid, const char *typeName, Oid typeNamespace, Oid relationOid, char relationKind, Oid ownerId, int16 internalSize, char typeType, char typeCategory, bool typePreferred, char typDelim, Oid inputProcedure, Oid outputProcedure, Oid receiveProcedure, Oid sendProcedure, Oid typmodinProcedure, Oid typmodoutProcedure, Oid analyzeProcedure, Oid subscriptProcedure, Oid elementType, bool isImplicitArray, Oid arrayType, Oid baseType, const char *defaultTypeValue, char *defaultTypeBin, bool passedByValue, char alignment, char storage, int32 typeMod, int32 typNDims, bool typeNotNull, Oid typeCollation)
char * makeArrayTypeName(const char *typeName, Oid typeNamespace)
bool moveArrayTypeName(Oid typeOid, const char *typeName, Oid typeNamespace)
ObjectAddress TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
FormData_pg_type * Form_pg_type
int pg_strcasecmp(const char *s1, const char *s2)
void check_stack_depth(void)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
static Datum NameGetDatum(const NameData *X)
static Datum CStringGetDatum(const char *X)
static Datum CharGetDatum(char X)
void * stringToNode(const char *str)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetNumberOfAttributes(relation)
#define RelationGetRelationName(relation)
int errtablecol(Relation rel, int attnum)
char * deparse_expression(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Snapshot GetLatestSnapshot(void)
void UnregisterSnapshot(Snapshot snapshot)
Snapshot RegisterSnapshot(Snapshot snapshot)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
#define BTEqualStrategyNumber
#define ERRCODE_DUPLICATE_OBJECT
PreParseColumnRefHook p_pre_columnref_hook
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
#define SearchSysCacheCopy1(cacheId, key1)
#define SearchSysCacheExists2(cacheId, key1, key2)
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
static TableScanDesc table_beginscan(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key)
static void table_endscan(TableScanDesc scan)
static bool table_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
void AlterRelationNamespaceInternal(Relation classRel, Oid relOid, Oid oldNspOid, Oid newNspOid, bool hasDependEntry, ObjectAddresses *objsMoved)
void ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lockmode)
void find_composite_type_dependencies(Oid typeOid, Relation origRelation, const char *origTypeName)
ObjectAddress DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, ObjectAddress *typaddress, const char *queryString)
void RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bool is_index)
#define TupleDescAttr(tupdesc, i)
static Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
static bool slot_attisnull(TupleTableSlot *slot, int attnum)
ObjectAddress AlterDomainNotNull(List *names, bool notNull)
static Oid findTypeReceiveFunction(List *procname, Oid typeOid)
ObjectAddress DefineDomain(CreateDomainStmt *stmt)
Oid AssignTypeMultirangeOid(void)
Oid binary_upgrade_next_mrng_array_pg_type_oid
static void AlterTypeRecurse(Oid typeOid, bool isImplicitArray, HeapTuple tup, Relation catalog, AlterTypeRecurseParams *atparams)
static void checkEnumOwner(HeapTuple tup)
static void validateDomainCheckConstraint(Oid domainoid, const char *ccbin)
static Oid findTypeAnalyzeFunction(List *procname, Oid typeOid)
static Oid findRangeSubOpclass(List *opcname, Oid subtype)
Oid AlterTypeNamespace_oid(Oid typeOid, Oid nspOid, bool ignoreDependent, ObjectAddresses *objsMoved)
Oid binary_upgrade_next_mrng_pg_type_oid
ObjectAddress DefineType(ParseState *pstate, List *names, List *parameters)
static Oid findRangeSubtypeDiffFunction(List *procname, Oid subtype)
static Oid findTypeOutputFunction(List *procname, Oid typeOid)
ObjectAddress DefineEnum(CreateEnumStmt *stmt)
static void makeMultirangeConstructors(const char *name, Oid namespace, Oid multirangeOid, Oid rangeOid, Oid rangeArrayOid, Oid *castFuncOid)
static Oid findTypeSendFunction(List *procname, Oid typeOid)
static char * domainAddCheckConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid, int typMod, Constraint *constr, const char *domainName, ObjectAddress *constrAddr)
ObjectAddress AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
static Oid findRangeCanonicalFunction(List *procname, Oid typeOid)
ObjectAddress AlterDomainDropConstraint(List *names, const char *constrName, DropBehavior behavior, bool missing_ok)
void AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId)
ObjectAddress AlterEnum(AlterEnumStmt *stmt)
ObjectAddress AlterDomainAddConstraint(List *names, Node *newConstraint, ObjectAddress *constrAddr)
void RemoveTypeById(Oid typeOid)
ObjectAddress AlterDomainValidateConstraint(List *names, const char *constrName)
static Oid findTypeSubscriptingFunction(List *procname, Oid typeOid)
static Oid findTypeTypmodoutFunction(List *procname)
static Oid findTypeTypmodinFunction(List *procname)
ObjectAddress AlterDomainDefault(List *names, Node *defaultRaw)
Oid binary_upgrade_next_array_pg_type_oid
ObjectAddress RenameType(RenameStmt *stmt)
Oid AssignTypeArrayOid(void)
static Oid findTypeInputFunction(List *procname, Oid typeOid)
void checkDomainOwner(HeapTuple tup)
void AlterTypeOwner_oid(Oid typeOid, Oid newOwnerId, bool hasDependEntry)
static void makeRangeConstructors(const char *name, Oid namespace, Oid rangeOid, Oid subtype)
ObjectAddress AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype, Oid *oldschema)
static List * get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
ObjectAddress DefineCompositeType(RangeVar *typevar, List *coldeflist)
static void domainAddNotNullConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid, int typMod, Constraint *constr, const char *domainName, ObjectAddress *constrAddr)
Oid AssignTypeMultirangeArrayOid(void)
ObjectAddress AlterType(AlterTypeStmt *stmt)
Oid AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid, bool isImplicitArray, bool ignoreDependent, bool errorOnTableType, ObjectAddresses *objsMoved)
static void validateDomainNotNullConstraint(Oid domainoid)
ObjectAddress DefineRange(ParseState *pstate, CreateRangeStmt *stmt)
static Node * replace_domain_constraint_value(ParseState *pstate, ColumnRef *cref)
bool contain_var_clause(Node *node)
void CommandCounterIncrement(void)