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

Commitbba1535

Browse files
committed
Merge branch 'picky_nodes' into merge_concurrent
2 parentsd7665c3 +951cde1 commitbba1535

File tree

13 files changed

+515
-171
lines changed

13 files changed

+515
-171
lines changed

‎expected/pg_pathman.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ SELECT pathman.enable_auto('test.range_rel');
12731273
INSERT INTO test.range_rel (dt) VALUES ('2015-06-01');
12741274
DROP TABLE test.range_rel CASCADE;
12751275
NOTICE: drop cascades to 20 other objects
1276-
SELECTpartrel, attname, parttype, range_interval FROM pathman.pathman_config;
1276+
SELECT* FROM pathman.pathman_config;
12771277
partrel | attname | parttype | range_interval
12781278
---------+---------+----------+----------------
12791279
(0 rows)
@@ -1457,7 +1457,7 @@ SELECT pathman.create_partitions_from_range('test."RangeRel"', 'dt', '2015-01-01
14571457

14581458
DROP TABLE test."RangeRel" CASCADE;
14591459
NOTICE: drop cascades to 5 other objects
1460-
SELECTpartrel, attname, parttype, range_interval FROM pathman.pathman_config;
1460+
SELECT* FROM pathman.pathman_config;
14611461
partrel | attname | parttype | range_interval
14621462
--------------------+---------+----------+----------------
14631463
test.num_range_rel | id | 2 | 1000

‎hash.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ BEGIN
7575
END IF;
7676

7777
RETURN partitions_count;
78+
79+
EXCEPTION WHEN others THEN
80+
RAISE EXCEPTION'%', SQLERRM;
7881
END
7982
$$ LANGUAGE plpgsql
8083
SET client_min_messages= WARNING;

‎init.sql

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
*range_interval - base interval for RANGE partitioning as string
1919
*/
2020
CREATETABLEIF NOT EXISTS @extschema@.pathman_config (
21-
idSERIALPRIMARY KEY,
22-
partrelREGCLASSNOT NULL,
21+
partrelREGCLASSNOT NULLPRIMARY KEY,
2322
attnameTEXTNOT NULL,
2423
parttypeINTEGERNOT NULL,
2524
range_intervalTEXT,
@@ -309,8 +308,18 @@ $$
309308
DECLARE
310309
v_recRECORD;
311310
is_referencedBOOLEAN;
311+
rel_persistenceCHAR;
312312

313313
BEGIN
314+
/* Ignore temporary tables*/
315+
SELECT relpersistenceFROMpg_catalog.pg_class
316+
WHEREoid= p_relation INTO rel_persistence;
317+
318+
IF rel_persistence='t'::CHAR THEN
319+
RAISE EXCEPTION'Temporary table "%" cannot be partitioned',
320+
quote_ident(p_relation::TEXT);
321+
END IF;
322+
314323
IF EXISTS (SELECT*FROM @extschema@.pathman_config
315324
WHERE partrel= p_relation) THEN
316325
RAISE EXCEPTION'Relation "%" has already been partitioned', p_relation;
@@ -320,7 +329,7 @@ BEGIN
320329
RAISE EXCEPTION'Partitioning key''%'' must be NOT NULL', p_attribute;
321330
END IF;
322331

323-
/* Check if there are foreign keysreference to the relation*/
332+
/* Check if there are foreign keysthat reference the relation*/
324333
FOR v_recIN (SELECT*
325334
FROM pg_constraintWHERE confrelid= p_relation::regclass::oid)
326335
LOOP
@@ -469,12 +478,9 @@ CREATE OR REPLACE FUNCTION @extschema@.drop_triggers(
469478
parent_relidREGCLASS)
470479
RETURNS VOIDAS
471480
$$
472-
DECLARE
473-
funcnameTEXT;
474-
475481
BEGIN
476-
funcname := @extschema@.build_update_trigger_func_name(parent_relid);
477-
EXECUTE format('DROP FUNCTION IF EXISTS %s() CASCADE', funcname);
482+
EXECUTE format('DROP FUNCTION IF EXISTS %s() CASCADE',
483+
@extschema@.build_update_trigger_func_name(parent_relid));
478484
END
479485
$$ LANGUAGE plpgsql;
480486

@@ -545,12 +551,14 @@ EXECUTE PROCEDURE @extschema@.pathman_ddl_trigger_func();
545551

546552

547553
/*
548-
*Check if regclass is date or timestamp
554+
*Attach partitioned table
549555
*/
550-
CREATEOR REPLACE FUNCTION @extschema@.is_date_type(
551-
typidREGTYPE)
552-
RETURNSBOOLEANAS'pg_pathman','is_date_type'
553-
LANGUAGE C STRICT;
556+
CREATEOR REPLACE FUNCTION @extschema@.add_to_pathman_config(
557+
parent_relidREGCLASS,
558+
attnameTEXT,
559+
range_intervalTEXT DEFAULTNULL)
560+
RETURNSBOOLEANAS'pg_pathman','add_to_pathman_config'
561+
LANGUAGE C;
554562

555563

556564
CREATEOR REPLACE FUNCTION @extschema@.on_create_partitions(
@@ -569,6 +577,21 @@ RETURNS VOID AS 'pg_pathman', 'on_partitions_removed'
569577
LANGUAGE C STRICT;
570578

571579

580+
/*
581+
* Get parent of pg_pathman's partition.
582+
*/
583+
CREATEOR REPLACE FUNCTION @extschema@.get_parent_of_partition(REGCLASS)
584+
RETURNS REGCLASSAS'pg_pathman','get_parent_of_partition_pl'
585+
LANGUAGE C STRICT;
586+
587+
/*
588+
* Check if regclass is date or timestamp
589+
*/
590+
CREATEOR REPLACE FUNCTION @extschema@.is_date_type(
591+
typidREGTYPE)
592+
RETURNSBOOLEANAS'pg_pathman','is_date_type'
593+
LANGUAGE C STRICT;
594+
572595
/*
573596
* Checks if attribute is nullable
574597
*/
@@ -617,10 +640,3 @@ LANGUAGE C STRICT;
617640
CREATEOR REPLACE FUNCTION @extschema@.debug_capture()
618641
RETURNS VOIDAS'pg_pathman','debug_capture'
619642
LANGUAGE C STRICT;
620-
621-
/*
622-
* Get parent of pg_pathman's partition.
623-
*/
624-
CREATEOR REPLACE FUNCTION @extschema@.get_parent_of_partition(REGCLASS)
625-
RETURNS REGCLASSAS'pg_pathman','get_parent_of_partition_pl'
626-
LANGUAGE C STRICT;

‎range.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ BEGIN
971971
WHEREoid= p_partition INTO rel_persistence;
972972

973973
IF rel_persistence='t'::CHAR THEN
974-
RAISE EXCEPTION'Temporary table\"%\" cannot be used as a partition',
974+
RAISE EXCEPTION'Temporary table"%" cannot be used as a partition',
975975
quote_ident(p_partition::TEXT);
976976
END IF;
977977

‎src/hooks.c

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
227227
rte->inh= true;/* we must restore 'inh' flag! */
228228

229229
children=PrelGetChildrenArray(prel);
230-
ranges=list_make1_irange(make_irange(0,PrelChildrenCount(prel)-1, false));
230+
ranges=list_make1_irange(make_irange(0,PrelLastChild(prel), false));
231231

232232
/* Make wrappers over restrictions and collect final rangeset */
233233
InitWalkerContext(&context,prel,NULL, false);
@@ -361,15 +361,8 @@ pg_pathman_enable_assign_hook(bool newval, void *extra)
361361
elog(DEBUG2,"pg_pathman_enable_assign_hook() [newval = %s] triggered",
362362
newval ?"true" :"false");
363363

364-
if (initialization_needed)
365-
{
366-
elog(DEBUG2,"pg_pathman is not yet initialized, "
367-
"pg_pathman.enable is set to false");
368-
return;
369-
}
370-
371364
/* Return quickly if nothing has changed */
372-
if (newval== (pg_pathman_enable&&
365+
if (newval== (pg_pathman_init_state.pg_pathman_enable&&
373366
pg_pathman_enable_runtimeappend&&
374367
pg_pathman_enable_runtime_merge_append&&
375368
pg_pathman_enable_partition_filter))
@@ -465,23 +458,9 @@ pathman_post_parse_analysis_hook(ParseState *pstate, Query *query)
465458
if (IsPathmanReady())
466459
finish_delayed_invalidation();
467460

468-
elog(DEBUG2,"post_parse: %d %d %u [%u]",
469-
IsPathmanEnabled(),
470-
initialization_needed,
471-
get_pathman_schema(),
472-
MyProcPid);
473-
474-
/* DEBUG!!!! */
475-
// static int parse_sleep = 10;
476-
// if (IsPathmanEnabled() &&
477-
// initialization_needed &&
478-
// get_pathman_schema() == InvalidOid)
479-
// sleep(parse_sleep);
480-
/* -------------------- */
481-
482461
/* Load config if pg_pathman exists & it's still necessary */
483462
if (IsPathmanEnabled()&&
484-
initialization_needed&&
463+
!IsPathmanInitialized()&&
485464
/* Now evaluate the most expensive clause */
486465
get_pathman_schema()!=InvalidOid)
487466
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp