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

Commit17a72db

Browse files
committed
clean up
1 parent32bab2d commit17a72db

File tree

4 files changed

+87
-91
lines changed

4 files changed

+87
-91
lines changed

‎src/hooks.c‎

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -833,9 +833,9 @@ pathman_process_utility_hook(Node *parsetree,
833833
caseT_AlterTableStmt:
834834
/* Override standard ALTER COLUMN TYPE statement if needed */
835835
if (is_pathman_related_alter_column_type(parsetree,
836-
&relation_oid,
837-
&attr_number,
838-
&part_type))
836+
&relation_oid,
837+
&attr_number,
838+
&part_type))
839839
{
840840
if (part_type==PT_HASH)
841841
ereport(ERROR,
@@ -860,35 +860,6 @@ pathman_process_utility_hook(Node *parsetree,
860860
default:
861861
;/* skip */
862862
}
863-
// <<<<<<< HEAD
864-
// =======
865-
866-
// /* Override standard RENAME statement if needed */
867-
// else if (is_pathman_related_table_rename(parsetree,
868-
// &relation_oid))
869-
// {
870-
// PathmanRenameConstraint(relation_oid,
871-
// (const RenameStmt *) parsetree);
872-
// }
873-
874-
// /* Override standard ALTER COLUMN TYPE statement if needed */
875-
// else if (is_pathman_related_alter_column_type(parsetree,
876-
// &relation_oid,
877-
// &attr_number,
878-
// &part_type))
879-
// {
880-
// if (part_type == PT_HASH)
881-
// ereport(ERROR,
882-
// (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
883-
// errmsg("cannot change type of column \"%s\""
884-
// " of table \"%s\" partitioned by HASH",
885-
// get_attname(relation_oid, attr_number),
886-
// get_rel_name(relation_oid))));
887-
888-
// /* Don't forget to invalidate parsed partitioning expression */
889-
// pathman_config_invalidate_parsed_expression(relation_oid);
890-
// }
891-
// >>>>>>> rel_future_beta
892863
}
893864

894865
/* Call hooks set by other extensions if needed */

‎src/include/compat/debug_compat_features.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#defineENABLE_PGPRO_PATCHES
1313

1414
/* PgPro exclusive features */
15-
//#define ENABLE_EXPAND_RTE_HOOK
16-
//#define ENABLE_RELATION_TAGS
1715
#defineENABLE_PATHMAN_AWARE_COPY_WIN32
1816

1917
/* Hacks for vanilla */

‎src/pl_range_funcs.c‎

Lines changed: 84 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ static void modify_range_constraint(Oid partition_relid,
7272
constBound*upper);
7373
staticchar*get_qualified_rel_name(Oidrelid);
7474
staticvoiddrop_table_by_oid(Oidrelid);
75+
staticOidsplit_range_partitions_internal(Oidparent,Oidpartition,
76+
Datumvalue,Oidvalue_type,
77+
RangeVar*new_partition_rv,
78+
char*new_partition_ts);
7579
staticboolinterval_is_trivial(Oidatttype,
7680
Datuminterval,
7781
Oidinterval_type);
@@ -787,34 +791,36 @@ merge_range_partitions_internal(Oid parent, Oid *parts, uint32 nparts)
787791
Datum
788792
split_range_partitions(PG_FUNCTION_ARGS)
789793
{
790-
Oidpartition=PG_GETARG_OID(0);
791-
Datumvalue=PG_GETARG_DATUM(1);
792-
Oidvalue_type=get_fn_expr_argtype(fcinfo->flinfo,1);
793-
Oidnew_partition;
794+
Oidparent_relid,
795+
partition_relid,
796+
new_partition_relid;
797+
Datumvalue;
798+
Oidvalue_type;
794799

795800
/* Optional: name & tablespace */
796801
RangeVar*new_partition_rv=NULL;
797-
char*new_partition_ts=NULL;
802+
char*new_partition_ts;
798803

799-
constPartRelationInfo*prel;
800-
Oidparent;
801-
Oidexpr_type;
802-
char*expr_cstr;
803-
RangeEntry*rentry=NULL;
804-
FmgrInfocmp_finfo;
805-
Boundfake_value_bound;
806-
RangeEntry*ranges;
807-
Boundmin,max;
808-
809-
List*ri_constr,
810-
*ri_relids;
811-
char*bound;
812-
inti;
813804
PartParentSearchparent_search;
814805

815-
// AttrNumber attnum;
816-
char*query;
806+
/* Partition's oid */
807+
if (!PG_ARGISNULL(0))
808+
{
809+
partition_relid=PG_GETARG_OID(0);
810+
}
811+
elseereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
812+
errmsg("'partition_relid' should not be NULL")));
813+
814+
/* Split value */
815+
if (!PG_ARGISNULL(1))
816+
{
817+
value=PG_GETARG_DATUM(1);
818+
value_type=get_fn_expr_argtype(fcinfo->flinfo,1);
819+
}
820+
elseereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
821+
errmsg("'value' should not be NULL")));
817822

823+
/* New partition's name (optional) */
818824
if (!PG_ARGISNULL(2))
819825
{
820826
List*qualified_name;
@@ -825,14 +831,54 @@ split_range_partitions(PG_FUNCTION_ARGS)
825831
new_partition_rv=makeRangeVarFromNameList(qualified_name);
826832
}
827833

828-
if (!PG_ARGISNULL(3))
829-
new_partition_ts=TextDatumGetCString(PG_GETARG_TEXT_P(3));
834+
/* New partition's tablesplace (optional) */
835+
new_partition_ts= !PG_ARGISNULL(3) ?
836+
TextDatumGetCString(PG_GETARG_TEXT_P(3)) :
837+
NULL;
830838

831839
/* Get parent's relid */
832-
parent=get_parent_of_partition(partition,&parent_search);
840+
parent_relid=get_parent_of_partition(partition_relid,&parent_search);
833841
if (parent_search!=PPS_ENTRY_PART_PARENT)
834842
elog(ERROR,"relation \"%s\" is not a partition",
835-
get_rel_name_or_relid(partition));
843+
get_rel_name_or_relid(partition_relid));
844+
845+
/* Perform split */
846+
new_partition_relid=split_range_partitions_internal(parent_relid,
847+
partition_relid,
848+
value,
849+
value_type,
850+
new_partition_rv,
851+
new_partition_ts);
852+
853+
PG_RETURN_OID(new_partition_relid);
854+
}
855+
856+
staticOid
857+
split_range_partitions_internal(Oidparent,Oidpartition,
858+
Datumvalue,Oidvalue_type,
859+
RangeVar*new_partition_rv,
860+
char*new_partition_ts)
861+
{
862+
constPartRelationInfo*prel;
863+
Oidexpr_type;
864+
char*expr_cstr;
865+
Oidcollid;
866+
867+
RangeEntry*ranges,
868+
*rentry=NULL;
869+
870+
FmgrInfocmp_finfo;
871+
Boundmin,
872+
max,
873+
fake_value_bound;
874+
875+
Oidnew_partition;
876+
List*ri_constr,
877+
*ri_relids;
878+
char*bound;
879+
inti;
880+
881+
char*query;
836882

837883
/* Lock parent and partition */
838884
prevent_relation_modification_internal(partition);
@@ -846,6 +892,7 @@ split_range_partitions(PG_FUNCTION_ARGS)
846892
ranges=PrelGetRangesArray(prel);
847893
expr_cstr=pstrdup(prel->expr_cstr);
848894
expr_type=prel->ev_type;
895+
collid=prel->ev_collid;
849896

850897
/* Look for the specified partition's range */
851898
for (i=0;i<PrelChildrenCount(prel);i++)
@@ -860,11 +907,15 @@ split_range_partitions(PG_FUNCTION_ARGS)
860907
min=CopyBound(&rentry->min,prel->ev_byval,prel->ev_len);
861908
max=CopyBound(&rentry->max,prel->ev_byval,prel->ev_len);
862909

863-
/* Ensure that value belongs to the range */
864910
fill_type_cmp_fmgr_info(&cmp_finfo,expr_type,expr_type);
865-
fake_value_bound=MakeBound(perform_type_cast(value,value_type,expr_type,NULL));
866-
if (cmp_bounds(&cmp_finfo,prel->ev_collid,&fake_value_bound,&min)<0
867-
||cmp_bounds(&cmp_finfo,prel->ev_collid,&fake_value_bound,&max) >=0)
911+
fake_value_bound=MakeBound(perform_type_cast(value,
912+
value_type,
913+
expr_type,
914+
NULL));
915+
916+
/* Ensure that value belongs to the range */
917+
if (cmp_bounds(&cmp_finfo,collid,&fake_value_bound,&min)<0
918+
||cmp_bounds(&cmp_finfo,collid,&fake_value_bound,&max) >=0)
868919
{
869920
elog(ERROR,
870921
"specified value does not fit into the range [%s, %s)",
@@ -884,16 +935,6 @@ split_range_partitions(PG_FUNCTION_ARGS)
884935
new_partition_ts,
885936
ri_constr,ri_relids);
886937

887-
/* get_pathman_relation_info() will refresh this entry */
888-
invalidate_pathman_relation_info(parent,NULL);
889-
890-
prel=get_pathman_relation_info(parent);
891-
shout_if_prel_is_invalid(parent,prel,PT_RANGE);
892-
893-
// attname = get_attname(prel->key, prel->attnum);
894-
// attnum = get_attnum(partition, attname);
895-
896-
/* Copy data */
897938
bound=build_range_condition_internal(partition,
898939
expr_cstr,
899940
&fake_value_bound,
@@ -906,30 +947,29 @@ split_range_partitions(PG_FUNCTION_ARGS)
906947
/* Prevent RI triggers from complaining during data migration */
907948
disable_ri_triggers();
908949

950+
/* Migrate data */
909951
query=psprintf("WITH part_data AS ( "
910952
"DELETE FROM %s WHERE %s RETURNING *) "
911953
"INSERT INTO %s SELECT * FROM part_data",
912954
get_qualified_rel_name(partition),
913955
bound,
914956
get_qualified_rel_name(new_partition));
915957
SPI_exec(query,0);
916-
917958
enable_ri_triggers();
959+
SPI_finish();
918960

919-
/* Alter constraint */
961+
/* Alter constraintfor the original partition*/
920962
modify_range_constraint(partition,
921963
expr_cstr,
922964
expr_type,
923965
&min,
924966
&fake_value_bound);
925967

926-
SPI_finish();
927968

928969
/* get_pathman_relation_info() will refresh this entry */
929970
invalidate_pathman_relation_info(parent,NULL);
930971

931-
// PG_RETURN_VOID();
932-
PG_RETURN_OID(new_partition);
972+
returnnew_partition;
933973
}
934974

935975
/*

‎src/ref_integrity.c‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,27 +1639,14 @@ createPartitionForeignKeyTriggers(Oid partition,
16391639
{
16401640
HeapTupleindexTuple;
16411641
RelationchildRel;
1642-
// Oidparent,
16431642
OidindexOid;
1644-
// PartParentSearchparent_search;
1645-
// PartRelationInfo *prel;
16461643
ObjectAddressconstrAddress;
16471644
ObjectAddressindexAddress;
16481645

16491646
/*
16501647
* Foreign key can be created for only single attribute key. So first thing
16511648
* we must check is that partitioning key is a single column
16521649
*/
1653-
// parent = get_parent_of_partition(partition, &parent_search);
1654-
// if (parent_search != PPS_ENTRY_PART_PARENT)
1655-
// ereport(ERROR, (errmsg("relation %s is not a partition",
1656-
// get_rel_name_or_relid(partition))));
1657-
// prel = get_pathman_relation_info(parent);
1658-
// shout_if_prel_is_invalid(parent, prel, PT_ANY);
1659-
1660-
// if ((attnum = VarGetAttnum(prel->expr)) == InvalidOid)
1661-
// ereport(ERROR, (errmsg(ERROR_SINGLE_COLUMN_KEY,
1662-
// get_rel_name_or_relid(parent))));
16631650

16641651
/* Lock partition so no one deletes rows until we're done */
16651652
childRel=heap_open(partition,ShareRowExclusiveLock);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp