@@ -83,6 +83,8 @@ static Constraint *make_constraint_common(char *name, Node *raw_expr);
83
83
static Value make_string_value_struct (char * str );
84
84
static Value make_int_value_struct (int int_val );
85
85
86
+ static RangeVar * makeRangeVarFromRelid (Oid relid );
87
+
86
88
87
89
/*
88
90
* ---------------------------------------
@@ -1426,6 +1428,40 @@ make_int_value_struct(int int_val)
1426
1428
return val ;
1427
1429
}
1428
1430
1431
+ void
1432
+ drop_check_constraint (Oid relid ,AttrNumber attnum )
1433
+ {
1434
+ char * constr_name ;
1435
+ AlterTableStmt * stmt ;
1436
+ AlterTableCmd * cmd ;
1437
+
1438
+ /* Build a correct name for this constraint */
1439
+ constr_name = build_check_constraint_name_relid_internal (relid ,attnum );
1440
+
1441
+ stmt = makeNode (AlterTableStmt );
1442
+ stmt -> relation = makeRangeVarFromRelid (relid );
1443
+ stmt -> relkind = OBJECT_TABLE ;
1444
+
1445
+ cmd = makeNode (AlterTableCmd );
1446
+ cmd -> subtype = AT_DropConstraint ;
1447
+ cmd -> name = constr_name ;
1448
+ cmd -> behavior = DROP_RESTRICT ;
1449
+ cmd -> missing_ok = true;
1450
+
1451
+ stmt -> cmds = list_make1 (cmd );
1452
+
1453
+ AlterTable (relid ,ShareUpdateExclusiveLock ,stmt );
1454
+ }
1455
+
1456
+ static RangeVar *
1457
+ makeRangeVarFromRelid (Oid relid )
1458
+ {
1459
+ char * relname = get_rel_name (relid );
1460
+ char * namespace = get_namespace_name (get_rel_namespace (relid ));
1461
+
1462
+ return makeRangeVar (namespace ,relname ,-1 );
1463
+ }
1464
+
1429
1465
1430
1466
/*
1431
1467
* ---------------------