MCPcopy Create free account
hub / github.com/apache/cloudberry / transformTableConstraint

Function transformTableConstraint

src/backend/parser/parse_utilcmd.c:983–1054  ·  view source on GitHub ↗

* transformTableConstraint * transform a Constraint node within CREATE TABLE or ALTER TABLE */

Source from the content-addressed store, hash-verified

981 * transform a Constraint node within CREATE TABLE or ALTER TABLE
982 */
983static void
984transformTableConstraint(CreateStmtContext *cxt, Constraint *constraint)
985{
986 switch (constraint->contype)
987 {
988 case CONSTR_PRIMARY:
989 if (cxt->isforeign)
990 ereport(ERROR,
991 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
992 errmsg("primary key constraints are not supported on foreign tables"),
993 parser_errposition(cxt->pstate,
994 constraint->location)));
995 cxt->ixconstraints = lappend(cxt->ixconstraints, constraint);
996 break;
997
998 case CONSTR_UNIQUE:
999 if (cxt->isforeign)
1000 ereport(ERROR,
1001 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1002 errmsg("unique constraints are not supported on foreign tables"),
1003 parser_errposition(cxt->pstate,
1004 constraint->location)));
1005 cxt->ixconstraints = lappend(cxt->ixconstraints, constraint);
1006 break;
1007
1008 case CONSTR_EXCLUSION:
1009 if (cxt->isforeign)
1010 ereport(ERROR,
1011 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1012 errmsg("exclusion constraints are not supported on foreign tables"),
1013 parser_errposition(cxt->pstate,
1014 constraint->location)));
1015 if (cxt->ispartitioned)
1016 ereport(ERROR,
1017 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1018 errmsg("exclusion constraints are not supported on partitioned tables"),
1019 parser_errposition(cxt->pstate,
1020 constraint->location)));
1021 cxt->ixconstraints = lappend(cxt->ixconstraints, constraint);
1022 break;
1023
1024 case CONSTR_CHECK:
1025 cxt->ckconstraints = lappend(cxt->ckconstraints, constraint);
1026 break;
1027
1028 case CONSTR_FOREIGN:
1029 if (cxt->isforeign)
1030 ereport(ERROR,
1031 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1032 errmsg("foreign key constraints are not supported on foreign tables"),
1033 parser_errposition(cxt->pstate,
1034 constraint->location)));
1035 cxt->fkconstraints = lappend(cxt->fkconstraints, constraint);
1036 break;
1037
1038 case CONSTR_NULL:
1039 case CONSTR_NOTNULL:
1040 case CONSTR_DEFAULT:

Callers 2

transformCreateStmtFunction · 0.85
transformAlterTableStmtFunction · 0.85

Calls 4

parser_errpositionFunction · 0.85
lappendFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected