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

Commit55321b2

Browse files
committed
wrote a C version of merge_range_partitions() function
1 parent194f29f commit55321b2

File tree

10 files changed

+305
-61
lines changed

10 files changed

+305
-61
lines changed

‎hash.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ BEGIN
3838
INSERT INTO @extschema@.pathman_config (partrel, attname, parttype)
3939
VALUES (parent_relid, attribute,1);
4040

41+
IF array_length(relnames)!= partitions_count THEN
42+
RAISE EXCEPTION'Partition names array size must be equal the partitions count';
43+
END IF;
44+
45+
IF array_length(tablespaces)!= partitions_count THEN
46+
RAISE EXCEPTION'Partition tablespaces array size must be equal the partitions count';
47+
END IF;
48+
4149
/* Create partitions*/
4250
PERFORM @extschema@.create_hash_partitions_internal(parent_relid,
4351
attribute,

‎range.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,13 @@ END
681681
$$ LANGUAGE plpgsql;
682682

683683

684+
CREATEOR REPLACE FUNCTION @extschema@.merge_range_partitions(
685+
parentREGCLASS,
686+
partitionsREGCLASS[])
687+
RETURNS VOIDAS'pg_pathman','merge_range_partitions'
688+
LANGUAGE C STRICT;
689+
690+
684691
/*
685692
* Append new partition.
686693
*/

‎src/init.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -910,23 +910,6 @@ cmp_range_entries(const void *p1, const void *p2, void *arg)
910910
FmgrInfo*flinfo= (FmgrInfo*)arg;
911911

912912
returncmp_bounds(flinfo,&v1->min,&v2->min);
913-
914-
// /* If range is half open */
915-
// if (IsInfinite(&v1->min))
916-
// {
917-
// // if (IsInfinite(&v2->min))
918-
// // return Int32GetDatum(0);
919-
// return Int32GetDatum(-1);
920-
// }
921-
// if (IsInfinite(&v2->min))
922-
// {
923-
// return Int32GetDatum(1);
924-
// }
925-
926-
// /* Else if range is closed */
927-
// return OidFunctionCall2(cmp_proc_oid,
928-
// BoundGetValue(&v1->min),
929-
// BoundGetValue(&v2->min));
930913
}
931914

932915
/*

‎src/partition_creation.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ static Constraint *make_constraint_common(char *name, Node *raw_expr);
8383
staticValuemake_string_value_struct(char*str);
8484
staticValuemake_int_value_struct(intint_val);
8585

86+
staticRangeVar*makeRangeVarFromRelid(Oidrelid);
87+
8688

8789
/*
8890
* ---------------------------------------
@@ -1426,6 +1428,40 @@ make_int_value_struct(int int_val)
14261428
returnval;
14271429
}
14281430

1431+
void
1432+
drop_check_constraint(Oidrelid,AttrNumberattnum)
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+
staticRangeVar*
1457+
makeRangeVarFromRelid(Oidrelid)
1458+
{
1459+
char*relname=get_rel_name(relid);
1460+
char*namespace=get_namespace_name(get_rel_namespace(relid));
1461+
1462+
returnmakeRangeVar(namespace,relname,-1);
1463+
}
1464+
14291465

14301466
/*
14311467
* ---------------------

‎src/partition_creation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ Node * build_raw_hash_check_tree(char *attname,
7474
uint32part_idx,
7575
uint32part_count,Oidvalue_type);
7676

77+
voiddrop_check_constraint(Oidrelid,AttrNumberattnum);
78+
7779

7880
/* Partitioning callback type */
7981
typedefenum

‎src/pl_funcs.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -779,25 +779,7 @@ prevent_relation_modification(PG_FUNCTION_ARGS)
779779
{
780780
Oidrelid=PG_GETARG_OID(0);
781781

782-
/*
783-
* Check that isolation level is READ COMMITTED.
784-
* Else we won't be able to see new rows
785-
* which could slip through locks.
786-
*/
787-
if (!xact_is_level_read_committed())
788-
ereport(ERROR,
789-
(errmsg("Cannot perform blocking partitioning operation"),
790-
errdetail("Expected READ COMMITTED isolation level")));
791-
792-
/*
793-
* Check if table is being modified
794-
* concurrently in a separate transaction.
795-
*/
796-
if (!xact_lock_rel_exclusive(relid, true))
797-
ereport(ERROR,
798-
(errmsg("Cannot perform blocking partitioning operation"),
799-
errdetail("Table \"%s\" is being modified concurrently",
800-
get_rel_name_or_relid(relid))));
782+
(void)prevent_relation_modification_internal(relid);
801783

802784
PG_RETURN_VOID();
803785
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp