Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5a00f1a

Browse files
committed
Simplify the code
1 parent 4bbef1d commit 5a00f1a

File tree

1 file changed

+5
-44
lines changed

1 file changed

+5
-44
lines changed

src/pl_range_funcs.c

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,10 @@ static void modify_range_constraint(Oid partition_relid,
7373
const Bound *lower,
7474
const Bound *upper);
7575
static char *get_qualified_rel_name(Oid relid);
76-
static void drop_table_by_oid(Oid relid, bool concurrent);
76+
static void drop_table_by_oid(Oid relid);
7777
static bool interval_is_trivial(Oid atttype,
7878
Datum interval,
7979
Oid interval_type);
80-
static void remove_inheritance(Oid parent_relid, Oid partition_relid);
81-
8280

8381
/*
8482
* -----------------------------
@@ -740,9 +738,6 @@ merge_range_partitions_internal(Oid parent_relid, Oid *parts, uint32 nparts)
740738
NULL,
741739
NULL);
742740

743-
/* should be invalidated */
744-
//Assert(!prel->valid);
745-
746741
/* Make new relation visible */
747742
CommandCounterIncrement();
748743

@@ -767,22 +762,11 @@ merge_range_partitions_internal(Oid parent_relid, Oid *parts, uint32 nparts)
767762

768763
SPI_finish();
769764

770-
/*
771-
* Now detach these partitions.
772-
* this would get AccessExclusiveLock.
773-
*/
774-
for (i = 0; i < nparts; i++)
775-
remove_inheritance(parent_relid, parts[i]);
776-
777765
/* Now we can drop the partitions */
778766
for (i = 0; i < nparts; i++)
779767
{
780-
/*
781-
* we should get AccessExclusiveLock anyway, because logic of
782-
* ALTER TABLE .. NO INHERIT that we did before could change
783-
*/
784768
LockRelationOid(parts[i], AccessExclusiveLock);
785-
drop_table_by_oid(parts[i], false);
769+
drop_table_by_oid(parts[i]);
786770
}
787771
}
788772

@@ -844,7 +828,7 @@ drop_range_partition_expand_next(PG_FUNCTION_ARGS)
844828
}
845829

846830
/* Finally drop this partition */
847-
drop_table_by_oid(relid, false);
831+
drop_table_by_oid(relid);
848832

849833
PG_RETURN_VOID();
850834
}
@@ -1263,7 +1247,7 @@ get_qualified_rel_name(Oid relid)
12631247
* Drop table using it's Oid
12641248
*/
12651249
static void
1266-
drop_table_by_oid(Oid relid, bool concurrent)
1250+
drop_table_by_oid(Oid relid)
12671251
{
12681252
DropStmt *n = makeNode(DropStmt);
12691253
const char *relname = get_qualified_rel_name(relid);
@@ -1275,30 +1259,7 @@ drop_table_by_oid(Oid relid, bool concurrent)
12751259
n->arguments = NIL;
12761260
#endif
12771261
n->behavior = DROP_RESTRICT; /* default behavior */
1278-
n->concurrent = concurrent;
1262+
n->concurrent = false;
12791263

12801264
RemoveRelations(n);
12811265
}
1282-
1283-
/* Remove inheritance for partition */
1284-
static void
1285-
remove_inheritance(Oid parent_relid, Oid partition_relid)
1286-
{
1287-
AlterTableStmt *stmt = makeNode(AlterTableStmt);
1288-
AlterTableCmd *cmd = makeNode(AlterTableCmd);
1289-
LOCKMODE lockmode;
1290-
1291-
stmt->relation = makeRangeVarFromNameList(
1292-
stringToQualifiedNameList(get_qualified_rel_name(partition_relid)));
1293-
stmt->relkind = OBJECT_TABLE;
1294-
stmt->cmds = list_make1(cmd);
1295-
stmt->missing_ok = false;
1296-
1297-
cmd->subtype = AT_DropInherit;
1298-
cmd->def = (Node *) makeRangeVarFromNameList(
1299-
stringToQualifiedNameList(get_qualified_rel_name(parent_relid)));
1300-
1301-
lockmode = AlterTableGetLockLevel(stmt->cmds);
1302-
LockRelationOid(partition_relid, lockmode);
1303-
AlterTable(partition_relid, lockmode, stmt);
1304-
}

0 commit comments

Comments
 (0)