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",
802 baseColl = baseType->typcollation;
803 if (
stmt->collClause)
806 domaincoll = baseColl;
811 (
errcode(ERRCODE_DATATYPE_MISMATCH),
812 errmsg(
"collations are not supported by type %s",
817 byValue = baseType->typbyval;
820 alignment = baseType->typalign;
823 storage = baseType->typstorage;
826 internalLength = baseType->typlen;
829 category = baseType->typcategory;
832 delimiter = baseType->typdelim;
835 inputProcedure = F_DOMAIN_IN;
836 outputProcedure = baseType->typoutput;
837 receiveProcedure = F_DOMAIN_RECV;
838 sendProcedure = baseType->typsend;
843 analyzeProcedure = baseType->typanalyze;
853 Anum_pg_type_typdefault, &isnull);
859 Anum_pg_type_typdefaultbin, &isnull);
867 foreach(listptr, schema)
872 elog(
ERROR,
"unrecognized node type: %d",
885 errmsg(
"multiple default expressions"),
913 if (defaultExpr == NULL ||
915 ((
Const *) defaultExpr)->constisnull))
918 defaultValueBin = NULL;
937 defaultValueBin = NULL;
947 errmsg(
"conflicting NULL/NOT NULL constraints"),
951 errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
952 errmsg(
"redundant NOT NULL constraint definition"),
957 errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
958 errmsg(
"not-null constraints for domains cannot be marked NO INHERIT"),
965 if (nullDefined && typNotNull)
968 errmsg(
"conflicting NULL/NOT NULL constraints"),
984 errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
985 errmsg(
"check constraints for domains cannot be marked NO INHERIT"),
996 errmsg(
"unique constraints not possible for domains"),
1002 (
errcode(ERRCODE_SYNTAX_ERROR),
1003 errmsg(
"primary key constraints not possible for domains"),
1009 (
errcode(ERRCODE_SYNTAX_ERROR),
1010 errmsg(
"exclusion constraints not possible for domains"),
1016 (
errcode(ERRCODE_SYNTAX_ERROR),
1017 errmsg(
"foreign key constraints not possible for domains"),
1026 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1027 errmsg(
"specifying constraint deferrability not supported for domains"),
1034 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1035 errmsg(
"specifying GENERATED not supported for domains"),
1042 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1043 errmsg(
"specifying constraint enforceability not supported for domains"),
1097 alignment = (alignment == TYPALIGN_DOUBLE) ? TYPALIGN_DOUBLE : TYPALIGN_INT;
1117 F_ARRAY_SUBSCRIPT_HANDLER,
1126 TYPSTORAGE_EXTENDED,
1132 pfree(domainArrayName);
1137 foreach(listptr, schema)
1147 basetypeoid, basetypeMod,
1148 constr, domainName, NULL);
1153 basetypeoid, basetypeMod,
1154 constr, domainName, NULL);
1184 char *enumArrayName;
1213 errmsg(
"type \"%s\" already exists", enumName)));
1280 F_ARRAY_SUBSCRIPT_HANDLER,
1289 TYPSTORAGE_EXTENDED,
1295 pfree(enumArrayName);
1297 return enumTypeAddr;
1318 elog(
ERROR,
"cache lookup failed for type %u", enum_type_oid);
1334 stmt->newValNeighbor,
stmt->newValIsAfter,
1335 stmt->skipIfNewValExists);
1358 if (typTup->typtype != TYPTYPE_ENUM)
1360 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
1361 errmsg(
"%s is not an enum",
1385 char *rangeArrayName;
1386 char *multirangeTypeName = NULL;
1387 char *multirangeArrayName;
1391 Oid multirangeArrayOid;
1393 List *rangeSubOpclassName =
NIL;
1394 List *rangeCollationName =
NIL;
1395 List *rangeCanonicalName =
NIL;
1396 List *rangeSubtypeDiffName =
NIL;
1397 Oid rangeSubOpclass;
1439 errmsg(
"type \"%s\" already exists", typeName)));
1448 foreach(lc,
stmt->params)
1452 if (strcmp(defel->
defname,
"subtype") == 0)
1459 else if (strcmp(defel->
defname,
"subtype_opclass") == 0)
1461 if (rangeSubOpclassName !=
NIL)
1465 else if (strcmp(defel->
defname,
"collation") == 0)
1467 if (rangeCollationName !=
NIL)
1471 else if (strcmp(defel->
defname,
"canonical") == 0)
1473 if (rangeCanonicalName !=
NIL)
1477 else if (strcmp(defel->
defname,
"subtype_diff") == 0)
1479 if (rangeSubtypeDiffName !=
NIL)
1483 else if (strcmp(defel->
defname,
"multirange_type_name") == 0)
1485 if (multirangeTypeName != NULL)
1489 &multirangeTypeName);
1493 (
errcode(ERRCODE_SYNTAX_ERROR),
1494 errmsg(
"type attribute \"%s\" not recognized",
1501 (
errcode(ERRCODE_SYNTAX_ERROR),
1502 errmsg(
"type attribute \"subtype\" is required")));
1506 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1507 errmsg(
"range subtype cannot be %s",
1516 if (rangeCollationName !=
NIL)
1523 if (rangeCollationName !=
NIL)
1525 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
1526 errmsg(
"range collation specified but subtype does not support collation")));
1531 if (rangeCanonicalName !=
NIL)
1535 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1536 errmsg(
"cannot specify a canonical function without a pre-created shell type"),
1537 errhint(
"Create the type as a shell type, then create its canonicalization function, then do a full CREATE TYPE.")));
1544 if (rangeSubtypeDiffName !=
NIL)
1551 &subtyplen, &subtypbyval, &subtypalign);
1554 alignment = (subtypalign == TYPALIGN_DOUBLE) ? TYPALIGN_DOUBLE : TYPALIGN_INT;
1590 TYPSTORAGE_EXTENDED,
1599 if (multirangeTypeName)
1619 errmsg(
"type \"%s\" already exists", multirangeTypeName)));
1625 multirangeNamespace = typeNamespace;
1632 multirangeNamespace,
1647 F_MULTIRANGE_TYPANALYZE,
1662 Assert(multirangeOid == mltrngaddress.objectId);
1665 RangeCreate(typoid, rangeSubtype, rangeCollation, rangeSubOpclass,
1666 rangeCanonical, rangeSubtypeDiff, multirangeOid);
1691 F_ARRAY_SUBSCRIPT_HANDLER,
1700 TYPSTORAGE_EXTENDED,
1706 pfree(rangeArrayName);
1713 multirangeArrayName,
1714 multirangeNamespace,
1730 F_ARRAY_SUBSCRIPT_HANDLER,
1751 multirangeOid, typoid, rangeArrayOid,
1756 COERCION_CODE_EXPLICIT, COERCION_METHOD_FUNCTION,
1759 pfree(multirangeArrayName);
1775 Oid rangeOid,
Oid subtype)
1777 static const char *
const prosrc[2] = {
"range_constructor2",
1778 "range_constructor3"};
1779 static const int pronargs[2] = {2, 3};
1781 Oid constructorArgTypes[3];
1786 constructorArgTypes[0] = subtype;
1787 constructorArgTypes[1] = subtype;
1788 constructorArgTypes[2] = TEXTOID;
1790 referenced.
classId = TypeRelationId;
1806 BOOTSTRAP_SUPERUSERID,
1808 F_FMGR_INTERNAL_VALIDATOR,
1816 PROVOLATILE_IMMUTABLE,
1818 constructorArgTypesVector,
1850 Oid multirangeOid,
Oid rangeOid,
Oid rangeArrayOid,
1856 Datum allParamTypes;
1861 referenced.
classId = TypeRelationId;
1862 referenced.
objectId = multirangeOid;
1872 BOOTSTRAP_SUPERUSERID,
1874 F_FMGR_INTERNAL_VALIDATOR,
1875 "multirange_constructor0",
1882 PROVOLATILE_IMMUTABLE,
1917 BOOTSTRAP_SUPERUSERID,
1919 F_FMGR_INTERNAL_VALIDATOR,
1920 "multirange_constructor1",
1927 PROVOLATILE_IMMUTABLE,
1956 BOOTSTRAP_SUPERUSERID,
1958 F_FMGR_INTERNAL_VALIDATOR,
1959 "multirange_constructor2",
1966 PROVOLATILE_IMMUTABLE,
1982 pfree(allParameterTypes);
1983 pfree(parameterModes);
2005 argList[0] = CSTRINGOID;
2006 argList[1] = OIDOID;
2007 argList[2] = INT4OID;
2015 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2016 errmsg(
"type input function %s has multiple matches",
2025 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2026 errmsg(
"function %s does not exist",
2033 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2034 errmsg(
"type input function %s must return type %s",
2049 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2050 errmsg(
"type input function %s should not be volatile",
2066 argList[0] = typeOid;
2071 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2072 errmsg(
"function %s does not exist",
2077 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2078 errmsg(
"type output function %s must return type %s",
2084 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2085 errmsg(
"type output function %s should not be volatile",
2103 argList[0] = INTERNALOID;
2104 argList[1] = OIDOID;
2105 argList[2] = INT4OID;
2113 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2114 errmsg(
"type receive function %s has multiple matches",
2123 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2124 errmsg(
"function %s does not exist",
2131 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2132 errmsg(
"type receive function %s must return type %s",
2138 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2139 errmsg(
"type receive function %s should not be volatile",
2155 argList[0] = typeOid;
2160 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2161 errmsg(
"function %s does not exist",
2166 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2167 errmsg(
"type send function %s must return type %s",
2173 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2174 errmsg(
"type send function %s should not be volatile",
2189 argList[0] = CSTRINGARRAYOID;
2194 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2195 errmsg(
"function %s does not exist",
2200 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2201 errmsg(
"typmod_in function %s must return type %s",
2207 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2208 errmsg(
"type modifier input function %s should not be volatile",
2223 argList[0] = INT4OID;
2228 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2229 errmsg(
"function %s does not exist",
2234 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2235 errmsg(
"typmod_out function %s must return type %s",
2241 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2242 errmsg(
"type modifier output function %s should not be volatile",
2257 argList[0] = INTERNALOID;
2262 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2263 errmsg(
"function %s does not exist",
2268 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2269 errmsg(
"type analyze function %s must return type %s",
2286 argList[0] = INTERNALOID;
2291 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2292 errmsg(
"function %s does not exist",
2297 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2298 errmsg(
"type subscripting function %s must return type %s",
2305 if (procOid == F_ARRAY_SUBSCRIPT_HANDLER)
2307 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2308 errmsg(
"user-defined types cannot use subscripting function %s",
2339 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2340 errmsg(
"operator class \"%s\" does not accept data type %s",
2351 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2352 errmsg(
"data type %s has no default operator class for access method \"%s\"",
2354 errhint(
"You must specify an operator class for the range type or define a default operator class for the subtype.")));
2372 argList[0] = typeOid;
2378 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2379 errmsg(
"function %s does not exist",
2384 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2385 errmsg(
"range canonical function %s must return range type",
2390 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2391 errmsg(
"range canonical function %s must be immutable",
2413 argList[0] = subtype;
2414 argList[1] = subtype;
2420 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2421 errmsg(
"function %s does not exist",
2426 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2427 errmsg(
"range subtype diff function %s must return type %s",
2429 "double precision")));
2433 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2434 errmsg(
"range subtype diff function %s must be immutable",
2460 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2461 errmsg(
"pg_type array OID value not set when in binary upgrade mode")));
2475 return type_array_oid;
2486 Oid type_multirange_oid;
2493 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2494 errmsg(
"pg_type multirange OID value not set when in binary upgrade mode")));
2508 return type_multirange_oid;
2519 Oid type_multirange_array_oid;
2526 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2527 errmsg(
"pg_type multirange array OID value not set when in binary upgrade mode")));
2541 return type_multirange_array_oid;
2625 Node *defaultExpr = NULL;
2626 Datum new_record[Natts_pg_type] = {0};
2627 bool new_record_nulls[Natts_pg_type] = {0};
2628 bool new_record_repl[Natts_pg_type] = {0};
2642 elog(
ERROR,
"cache lookup failed for type %u", domainoid);
2661 typTup->typbasetype,
2671 if (defaultExpr == NULL ||
2672 (
IsA(defaultExpr,
Const) && ((
Const *) defaultExpr)->constisnull))
2676 new_record_nulls[Anum_pg_type_typdefaultbin - 1] =
true;
2677 new_record_repl[Anum_pg_type_typdefaultbin - 1] =
true;
2678 new_record_nulls[Anum_pg_type_typdefault - 1] =
true;
2679 new_record_repl[Anum_pg_type_typdefault - 1] =
true;
2696 new_record_repl[Anum_pg_type_typdefaultbin - 1] =
true;
2698 new_record_repl[Anum_pg_type_typdefault - 1] =
true;
2704 new_record_nulls[Anum_pg_type_typdefaultbin - 1] =
true;
2705 new_record_repl[Anum_pg_type_typdefaultbin - 1] =
true;
2706 new_record_nulls[Anum_pg_type_typdefault - 1] =
true;
2707 new_record_repl[Anum_pg_type_typdefault - 1] =
true;
2711 new_record, new_record_nulls,
2764 elog(
ERROR,
"cache lookup failed for type %u", domainoid);
2771 if (typTup->typnotnull == notNull)
2787 typTup->typbasetype, typTup->typtypmod,
2788 constr,
NameStr(typTup->typname), NULL);
2799 elog(
ERROR,
"could not find not-null constraint on domain \"%s\"",
NameStr(typTup->typname));
2809 typTup->typnotnull = notNull;
2855 elog(
ERROR,
"cache lookup failed for type %u", domainoid);
2865 Anum_pg_constraint_conrelid,
2869 Anum_pg_constraint_contypid,
2873 Anum_pg_constraint_conname,
2886 if (construct->contype == CONSTRAINT_NOTNULL)
2892 conobj.
classId = ConstraintRelationId;
2908 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2909 errmsg(
"constraint \"%s\" of domain \"%s\" does not exist",
2913 (
errmsg(
"constraint \"%s\" of domain \"%s\" does not exist, skipping",
2959 elog(
ERROR,
"cache lookup failed for type %u", domainoid);
2966 elog(
ERROR,
"unrecognized node type: %d",
2967 (
int)
nodeTag(newConstraint));
2982 typTup->typbasetype, typTup->typtypmod,
2983 constr,
NameStr(typTup->typname), constrAddr);
3005 if (typTup->typnotnull)
3011 typTup->typbasetype, typTup->typtypmod,
3012 constr,
NameStr(typTup->typname), constrAddr);
3017 typTup->typnotnull =
true;
3061 elog(
ERROR,
"cache lookup failed for type %u", domainoid);
3072 Anum_pg_constraint_conrelid,
3076 Anum_pg_constraint_contypid,
3080 Anum_pg_constraint_conname,
3090 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3091 errmsg(
"constraint \"%s\" of domain \"%s\" does not exist",
3095 if (con->contype != CONSTRAINT_CHECK)
3097 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3098 errmsg(
"constraint \"%s\" of domain \"%s\" is not a check constraint",
3116 copy_con->convalidated =
true;
3182 (
errcode(ERRCODE_NOT_NULL_VIOLATION),
3183 errmsg(
"column \"%s\" of table \"%s\" contains null values",
3277 (
errcode(ERRCODE_CHECK_VIOLATION),
3278 errmsg(
"column \"%s\" of table \"%s\" contains values that violate the new constraint",
3351 Anum_pg_depend_refclassid,
3355 Anum_pg_depend_refobjid,
3371 if (pg_depend->classid == TypeRelationId)
3373 if (
get_typtype(pg_depend->objid) == TYPTYPE_DOMAIN)
3401 if (pg_depend->classid != RelationRelationId ||
3402 pg_depend->objsubid <= 0)
3406 foreach(rellist, result)
3442 if (rel->
rd_rel->relkind != RELKIND_RELATION &&
3443 rel->
rd_rel->relkind != RELKIND_MATVIEW)
3454 result =
lappend(result, rtc);
3466 if (pg_att->attisdropped || pg_att->atttypid != domainOid)
3477 while (ptr > 0 && rtc->
atts[ptr - 1] > pg_depend->objsubid)
3479 rtc->
atts[ptr] = rtc->
atts[ptr - 1];
3482 rtc->
atts[ptr] = pg_depend->objsubid;
3504 if (typTup->typtype != TYPTYPE_DOMAIN)
3506 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3507 errmsg(
"%s is not a domain",
3541 errmsg(
"constraint \"%s\" for domain \"%s\" already exists",
3542 constr->
conname, domainName)));
3564 domVal->
typeId = baseTypeOid;
3565 domVal->typeMod = typMod;
3591 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
3592 errmsg(
"cannot use table references in domain check constraint")));
3662 colname =
strVal(field1);
3663 if (strcmp(colname,
"value") == 0)
3669 return (
Node *) domVal;
3697 errmsg(
"constraint \"%s\" for domain \"%s\" already exists",
3698 constr->
conname, domainName)));
3757 const char *newTypeName =
stmt->newname;
3774 elog(
ERROR,
"cache lookup failed for type %u", typeOid);
3784 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3785 errmsg(
"%s is not a domain",
3793 if (typTup->typtype == TYPTYPE_COMPOSITE &&
3796 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3797 errmsg(
"%s is a table's row type",
3804 if (IsTrueArrayType(typTup))
3806 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3807 errmsg(
"cannot alter array type %s",
3809 errhint(
"You can alter type %s, which will alter the array type as well.",
3818 if (typTup->typtype == TYPTYPE_COMPOSITE)
3822 typTup->typnamespace);
3855 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3856 errmsg(
"type \"%s\" does not exist",
3867 if (objecttype ==
OBJECT_DOMAIN && typTup->typtype != TYPTYPE_DOMAIN)
3869 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3870 errmsg(
"%s is not a domain",
3878 if (typTup->typtype == TYPTYPE_COMPOSITE &&
3881 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3882 errmsg(
"%s is a table's row type",
3889 if (IsTrueArrayType(typTup))
3891 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3892 errmsg(
"cannot alter array type %s",
3894 errhint(
"You can alter type %s, which will alter the array type as well.",
3898 if (typTup->typtype == TYPTYPE_MULTIRANGE)
3904 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3905 errmsg(
"cannot alter multirange type %s",
3908 errhint(
"You can alter type %s, which will alter the multirange type as well.",
3916 if (typTup->typowner != newOwnerId)
3929 aclresult =
object_aclcheck(NamespaceRelationId, typTup->typnamespace,
3970 elog(
ERROR,
"cache lookup failed for type %u", typeOid);
3978 if (typTup->typtype == TYPTYPE_COMPOSITE)
4005 Datum repl_val[Natts_pg_type];
4006 bool repl_null[Natts_pg_type];
4007 bool repl_repl[Natts_pg_type];
4016 elog(
ERROR,
"cache lookup failed for type %u", typeOid);
4019 memset(repl_null,
false,
sizeof(repl_null));
4020 memset(repl_repl,
false,
sizeof(repl_repl));
4022 repl_repl[Anum_pg_type_typowner - 1] =
true;
4026 Anum_pg_type_typacl,
4033 typTup->typowner, newOwnerId);
4034 repl_repl[Anum_pg_type_typacl - 1] =
true;
4048 if (typTup->typtype == TYPTYPE_RANGE)
4054 (
errcode(ERRCODE_UNDEFINED_OBJECT),
4055 errmsg(
"could not find multirange type for data type %s",
4085 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
4086 errmsg(
"%s is not a domain",
4097 *oldschema = oldNspOid;
4130 if (ignoreDependent)
4133 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
4134 errmsg(
"cannot alter array type %s",
4136 errhint(
"You can alter type %s, which will alter the array type as well.",
4170 bool isImplicitArray,
4171 bool ignoreDependent,
4172 bool errorOnTableType,
4186 thisobj.
classId = TypeRelationId;
4197 elog(
ERROR,
"cache lookup failed for type %u", typeOid);
4200 oldNspOid = typform->typnamespace;
4201 arrayOid = typform->typarray;
4204 if (oldNspOid != nspOid)
4215 errmsg(
"type \"%s\" already exists in schema \"%s\"",
4222 (typform->typtype == TYPTYPE_COMPOSITE &&
4228 if (ignoreDependent)
4233 if (errorOnTableType)
4235 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
4236 errmsg(
"%s is a table's row type",
4239 errhint(
"Use %s instead.",
"ALTER TABLE")));
4242 if (oldNspOid != nspOid)
4247 typform->typnamespace = nspOid;
4275 nspOid,
false, objsMoved);
4280 if (typform->typtype == TYPTYPE_DOMAIN)
4289 if (oldNspOid != nspOid &&
4293 NamespaceRelationId, oldNspOid, nspOid) != 1)
4294 elog(
ERROR,
"could not change schema dependency for type \"%s\"",
4333 bool requireSuper =
false;
4347 memset(&atparams, 0,
sizeof(atparams));
4348 foreach(pl,
stmt->options)
4352 if (strcmp(defel->
defname,
"storage") == 0)
4357 atparams.
storage = TYPSTORAGE_PLAIN;
4359 atparams.
storage = TYPSTORAGE_EXTERNAL;
4361 atparams.
storage = TYPSTORAGE_EXTENDED;
4363 atparams.
storage = TYPSTORAGE_MAIN;
4366 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4367 errmsg(
"storage \"%s\" not recognized",
a)));
4373 if (atparams.
storage != TYPSTORAGE_PLAIN && typForm->typlen != -1)
4375 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4376 errmsg(
"fixed-size types must have storage PLAIN")));
4388 if (atparams.
storage != TYPSTORAGE_PLAIN &&
4389 typForm->typstorage == TYPSTORAGE_PLAIN)
4390 requireSuper =
true;
4391 else if (atparams.
storage == TYPSTORAGE_PLAIN &&
4392 typForm->typstorage != TYPSTORAGE_PLAIN)
4394 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4395 errmsg(
"cannot change type's storage to PLAIN")));
4399 else if (strcmp(defel->
defname,
"receive") == 0)
4401 if (defel->
arg != NULL)
4409 requireSuper =
true;
4411 else if (strcmp(defel->
defname,
"send") == 0)
4413 if (defel->
arg != NULL)
4421 requireSuper =
true;
4423 else if (strcmp(defel->
defname,
"typmod_in") == 0)
4425 if (defel->
arg != NULL)
4432 requireSuper =
true;
4434 else if (strcmp(defel->
defname,
"typmod_out") == 0)
4436 if (defel->
arg != NULL)
4443 requireSuper =
true;
4445 else if (strcmp(defel->
defname,
"analyze") == 0)
4447 if (defel->
arg != NULL)
4455 requireSuper =
true;
4457 else if (strcmp(defel->
defname,
"subscript") == 0)
4459 if (defel->
arg != NULL)
4467 requireSuper =
true;
4474 else if (strcmp(defel->
defname,
"input") == 0 ||
4475 strcmp(defel->
defname,
"output") == 0 ||
4476 strcmp(defel->
defname,
"internallength") == 0 ||
4477 strcmp(defel->
defname,
"passedbyvalue") == 0 ||
4478 strcmp(defel->
defname,
"alignment") == 0 ||
4479 strcmp(defel->
defname,
"like") == 0 ||
4480 strcmp(defel->
defname,
"category") == 0 ||
4481 strcmp(defel->
defname,
"preferred") == 0 ||
4482 strcmp(defel->
defname,
"default") == 0 ||
4483 strcmp(defel->
defname,
"element") == 0 ||
4484 strcmp(defel->
defname,
"delimiter") == 0 ||
4485 strcmp(defel->
defname,
"collatable") == 0)
4487 (
errcode(ERRCODE_SYNTAX_ERROR),
4488 errmsg(
"type attribute \"%s\" cannot be changed",
4492 (
errcode(ERRCODE_SYNTAX_ERROR),
4493 errmsg(
"type attribute \"%s\" not recognized",
4505 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4506 errmsg(
"must be superuser to alter a type")));
4524 if (typForm->typtype != TYPTYPE_BASE)
4526 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
4527 errmsg(
"%s is not a base type",
4533 if (IsTrueArrayType(typForm))
4535 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
4536 errmsg(
"%s is not a base type",
4581 bool nulls[Natts_pg_type];
4582 bool replaces[Natts_pg_type];
4593 memset(nulls, 0,
sizeof(nulls));
4594 memset(replaces, 0,
sizeof(replaces));
4598 replaces[Anum_pg_type_typstorage - 1] =
true;
4603 replaces[Anum_pg_type_typreceive - 1] =
true;
4608 replaces[Anum_pg_type_typsend - 1] =
true;
4613 replaces[Anum_pg_type_typmodin - 1] =
true;
4618 replaces[Anum_pg_type_typmodout - 1] =
true;
4623 replaces[Anum_pg_type_typanalyze - 1] =
true;
4628 replaces[Anum_pg_type_typsubscript - 1] =
true;
4633 values, nulls, replaces);
4655 if (!isImplicitArray &&
4667 elog(
ERROR,
"cache lookup failed for type %u", arrtypoid);
4669 memset(&arrparams, 0,
sizeof(arrparams));
4698 Anum_pg_type_typbasetype,
4713 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 OidIsValid(objectId)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
TypeName * defGetTypeName(DefElem *def)
int defGetTypeLength(DefElem *def)
char * defGetString(DefElem *def)
bool defGetBoolean(DefElem *def)
List * defGetQualifiedName(DefElem *def)
void errorConflictingDefElem(DefElem *defel, ParseState *pstate)
void performDeletion(const ObjectAddress *object, DropBehavior behavior, int flags)
bool object_address_present(const ObjectAddress *object, const ObjectAddresses *addrs)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
ObjectAddresses * new_object_addresses(void)
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)
void FreeExecutorState(EState *estate)
EState * CreateExecutorState(void)
#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)
Assert(PointerIsAligned(start, uint64))
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)
static void * GETSTRUCT(const HeapTupleData *tuple)
Oid GetDefaultOpClass(Oid type_id, Oid am_id)
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *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
#define ShareUpdateExclusiveLock
Oid get_element_type(Oid typid)
Oid get_opclass_input_type(Oid opclass)
Oid get_multirange_range(Oid multirangeOid)
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)
char * get_namespace_name(Oid nspid)
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)
char * NameListToString(const List *names)
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)
#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)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
Node * coerce_to_boolean(ParseState *pstate, Node *node, const char *constructName)
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)
char * TypeNameToString(const TypeName *typeName)
Type LookupTypeName(ParseState *pstate, const TypeName *typeName, int32 *typmod_p, bool missing_ok)
Type typenameType(ParseState *pstate, const TypeName *typeName, int32 *typmod_p)
Oid typenameTypeId(ParseState *pstate, const TypeName *typeName)
@ CONSTR_ATTR_NOT_DEFERRABLE
@ CONSTR_ATTR_NOT_ENFORCED
FormData_pg_attribute * Form_pg_attribute
ObjectAddress CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, Oid incastid, Oid outcastid, char castcontext, char castmethod, DependencyType behavior)
Oid CreateConstraintEntry(const char *constraintName, Oid constraintNamespace, char constraintType, bool isDeferrable, bool isDeferred, bool isEnforced, 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, int16 conInhCount, bool conNoInherit, bool conPeriod, bool is_internal)
bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId, const char *conname)
HeapTuple findDomainNotNullConstraint(Oid typid)
void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId, Oid newNspId, bool isType, ObjectAddresses *objsMoved)
char * ChooseConstraintName(const char *name1, const char *name2, const char *label, Oid namespaceid, List *others)
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, List *trfoids, 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)
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)
bool moveArrayTypeName(Oid typeOid, const char *typeName, Oid typeNamespace)
ObjectAddress TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
char * makeMultirangeTypeName(const char *rangeTypeName, Oid typeNamespace)
char * makeArrayTypeName(const char *typeName, Oid typeNamespace)
FormData_pg_type * Form_pg_type
int pg_strcasecmp(const char *s1, const char *s2)
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)
void check_stack_depth(void)
#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 void table_endscan(TableScanDesc scan)
static bool table_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
static TableScanDesc table_beginscan(Relation rel, Snapshot snapshot, int nkeys, ScanKeyData *key)
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)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int 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)
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 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 DefineDomain(ParseState *pstate, CreateDomainStmt *stmt)
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 void validateDomainCheckConstraint(Oid domainoid, const char *ccbin, LOCKMODE lockmode)
static Node * replace_domain_constraint_value(ParseState *pstate, ColumnRef *cref)
bool contain_var_clause(Node *node)
void CommandCounterIncrement(void)