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

Function AlterDomainValidateConstraint

src/backend/commands/typecmds.c:3151–3251  ·  view source on GitHub ↗

* AlterDomainValidateConstraint * * Implements the ALTER DOMAIN .. VALIDATE CONSTRAINT statement. */

Source from the content-addressed store, hash-verified

3149 * Implements the ALTER DOMAIN .. VALIDATE CONSTRAINT statement.
3150 */
3151ObjectAddress
3152AlterDomainValidateConstraint(List *names, const char *constrName)
3153{
3154 TypeName *typename;
3155 Oid domainoid;
3156 Relation typrel;
3157 Relation conrel;
3158 HeapTuple tup;
3159 Form_pg_constraint con;
3160 Form_pg_constraint copy_con;
3161 char *conbin;
3162 SysScanDesc scan;
3163 Datum val;
3164 bool isnull;
3165 HeapTuple tuple;
3166 HeapTuple copyTuple;
3167 ScanKeyData skey[3];
3168 ObjectAddress address;
3169
3170 /* Make a TypeName so we can use standard type lookup machinery */
3171 typename = makeTypeNameFromNameList(names);
3172 domainoid = typenameTypeId(NULL, typename);
3173
3174 /* Look up the domain in the type table */
3175 typrel = table_open(TypeRelationId, AccessShareLock);
3176
3177 tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(domainoid));
3178 if (!HeapTupleIsValid(tup))
3179 elog(ERROR, "cache lookup failed for type %u", domainoid);
3180
3181 /* Check it's a domain and check user has permission for ALTER DOMAIN */
3182 checkDomainOwner(tup);
3183
3184 /*
3185 * Find and check the target constraint
3186 */
3187 conrel = table_open(ConstraintRelationId, RowExclusiveLock);
3188
3189 ScanKeyInit(&skey[0],
3190 Anum_pg_constraint_conrelid,
3191 BTEqualStrategyNumber, F_OIDEQ,
3192 ObjectIdGetDatum(InvalidOid));
3193 ScanKeyInit(&skey[1],
3194 Anum_pg_constraint_contypid,
3195 BTEqualStrategyNumber, F_OIDEQ,
3196 ObjectIdGetDatum(domainoid));
3197 ScanKeyInit(&skey[2],
3198 Anum_pg_constraint_conname,
3199 BTEqualStrategyNumber, F_NAMEEQ,
3200 CStringGetDatum(constrName));
3201
3202 scan = systable_beginscan(conrel, ConstraintRelidTypidNameIndexId, true,
3203 NULL, 3, skey);
3204
3205 /* There can be at most one matching row */
3206 if (!HeapTupleIsValid(tuple = systable_getnext(scan)))
3207 ereport(ERROR,
3208 (errcode(ERRCODE_UNDEFINED_OBJECT),

Callers 1

ProcessUtilitySlowFunction · 0.85

Calls 15

makeTypeNameFromNameListFunction · 0.85
typenameTypeIdFunction · 0.85
table_openFunction · 0.85
SearchSysCache1Function · 0.85
ObjectIdGetDatumFunction · 0.85
checkDomainOwnerFunction · 0.85
ScanKeyInitFunction · 0.85
CStringGetDatumFunction · 0.85
systable_beginscanFunction · 0.85
systable_getnextFunction · 0.85
TypeNameToStringFunction · 0.85
SysCacheGetAttrFunction · 0.85

Tested by

no test coverage detected