Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit43fefff

Browse files
committed
clean code (function drop_check_constraint())
1 parent5dc7251 commit43fefff

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

‎src/partition_creation.c

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,32 @@ copy_foreign_keys(Oid parent_relid, Oid partition_oid)
10951095
* -----------------------------
10961096
*/
10971097

1098+
/* Drop pg_pathman's check constraint by 'relid' and 'attnum' */
1099+
void
1100+
drop_check_constraint(Oidrelid,AttrNumberattnum)
1101+
{
1102+
char*constr_name;
1103+
AlterTableStmt*stmt;
1104+
AlterTableCmd*cmd;
1105+
1106+
/* Build a correct name for this constraint */
1107+
constr_name=build_check_constraint_name_relid_internal(relid,attnum);
1108+
1109+
stmt=makeNode(AlterTableStmt);
1110+
stmt->relation=makeRangeVarFromRelid(relid);
1111+
stmt->relkind=OBJECT_TABLE;
1112+
1113+
cmd=makeNode(AlterTableCmd);
1114+
cmd->subtype=AT_DropConstraint;
1115+
cmd->name=constr_name;
1116+
cmd->behavior=DROP_RESTRICT;
1117+
cmd->missing_ok= true;
1118+
1119+
stmt->cmds=list_make1(cmd);
1120+
1121+
AlterTable(relid,ShareUpdateExclusiveLock,stmt);
1122+
}
1123+
10981124
/* Build RANGE check constraint expression tree */
10991125
Node*
11001126
build_raw_range_check_tree(char*attname,
@@ -1383,31 +1409,6 @@ make_int_value_struct(int int_val)
13831409
returnval;
13841410
}
13851411

1386-
void
1387-
drop_check_constraint(Oidrelid,AttrNumberattnum)
1388-
{
1389-
char*constr_name;
1390-
AlterTableStmt*stmt;
1391-
AlterTableCmd*cmd;
1392-
1393-
/* Build a correct name for this constraint */
1394-
constr_name=build_check_constraint_name_relid_internal(relid,attnum);
1395-
1396-
stmt=makeNode(AlterTableStmt);
1397-
stmt->relation=makeRangeVarFromRelid(relid);
1398-
stmt->relkind=OBJECT_TABLE;
1399-
1400-
cmd=makeNode(AlterTableCmd);
1401-
cmd->subtype=AT_DropConstraint;
1402-
cmd->name=constr_name;
1403-
cmd->behavior=DROP_RESTRICT;
1404-
cmd->missing_ok= true;
1405-
1406-
stmt->cmds=list_make1(cmd);
1407-
1408-
AlterTable(relid,ShareUpdateExclusiveLock,stmt);
1409-
}
1410-
14111412
staticRangeVar*
14121413
makeRangeVarFromRelid(Oidrelid)
14131414
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp