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

Commit6a1f3a5

Browse files
committed
Merge branch 'rel_future_expressions' of github.com:postgrespro/pg_pathman into rel_future_expressions
2 parents38fa150 +2b91a49 commit6a1f3a5

15 files changed

+148
-106
lines changed

‎expected/pathman_basic.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,16 +1461,16 @@ INSERT INTO test.range_rel (dt) VALUES ('2015-06-01');
14611461
*/
14621462
ALTER TABLE test.range_rel DROP COLUMN data;
14631463
SELECT * FROM pathman.pathman_config;
1464-
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
1465-
----------------+---------+----------+----------------+-------------------------------------------------------------------------------------------------------------------------+---------+----------
1466-
test.range_rel | dt | 2 | @ 10 days | {VAR :varno 1 :varattno 2 :vartype 1114 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 2 :location 8} | 1114 | f
1464+
partrel | attname | parttype | range_interval | expression_p | atttype
1465+
----------------+---------+----------+----------------+-------------------------------------------------------------------------------------------------------------------------+---------
1466+
test.range_rel | dt | 2 | @ 10 days | {VAR :varno 1 :varattno 2 :vartype 1114 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 2 :location 8} | 1114
14671467
(1 row)
14681468

14691469
DROP TABLE test.range_rel CASCADE;
14701470
NOTICE: drop cascades to 20 other objects
14711471
SELECT * FROM pathman.pathman_config;
1472-
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
1473-
---------+---------+----------+----------------+--------------+---------+----------
1472+
partrel | attname | parttype | range_interval | expression_p | atttype
1473+
---------+---------+----------+----------------+--------------+---------
14741474
(0 rows)
14751475

14761476
/* Check overlaps */
@@ -1632,9 +1632,9 @@ SELECT pathman.create_partitions_from_range('test."RangeRel"', 'dt', '2015-01-01
16321632
DROP TABLE test."RangeRel" CASCADE;
16331633
NOTICE: drop cascades to 5 other objects
16341634
SELECT * FROM pathman.pathman_config;
1635-
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
1636-
--------------------+---------+----------+----------------+------------------------------------------------------------------------------------------------------------------------+---------+----------
1637-
test.num_range_rel | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 23 | f
1635+
partrel | attname | parttype | range_interval | expression_p | atttype
1636+
--------------------+---------+----------+----------------+------------------------------------------------------------------------------------------------------------------------+---------
1637+
test.num_range_rel | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 23
16381638
(1 row)
16391639

16401640
CREATE TABLE test."RangeRel" (

‎expected/pathman_calamity.out

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,31 @@ SELECT drop_partitions('calamity.part_test', true);
221221
(1 row)
222222

223223
DELETE FROM calamity.part_test;
224+
/* check function build_hash_condition() */
225+
SELECT build_hash_condition('int4', 'val', 10, 1);
226+
build_hash_condition
227+
-------------------------------------------------
228+
public.get_hash_part_idx(hashint4(val), 10) = 1
229+
(1 row)
230+
231+
SELECT build_hash_condition('text', 'val', 10, 1);
232+
build_hash_condition
233+
-------------------------------------------------
234+
public.get_hash_part_idx(hashtext(val), 10) = 1
235+
(1 row)
236+
237+
SELECT build_hash_condition('int4', 'val', 1, 1);
238+
ERROR: 'partition_index' must be lower than 'partitions_count'
239+
SELECT build_hash_condition('int4', 'val', 10, 20);
240+
ERROR: 'partition_index' must be lower than 'partitions_count'
241+
SELECT build_hash_condition('text', 'val', 10, NULL) IS NULL;
242+
?column?
243+
----------
244+
t
245+
(1 row)
246+
247+
SELECT build_hash_condition('calamity.part_test', 'val', 10, 1);
248+
ERROR: no hash function for type calamity.part_test
224249
/* check function build_range_condition() */
225250
SELECT build_range_condition(NULL, 'val', 10, 20);/* not ok */
226251
ERROR: 'partition_relid' should not be NULL
@@ -245,15 +270,15 @@ SELECT build_range_condition('calamity.part_test', 'val', NULL, 10);/* OK */
245270
(1 row)
246271

247272
/* check function validate_interval_value() */
248-
SELECT validate_interval_value(NULL, 2, '1 mon');/* not ok */
273+
SELECT validate_interval_value(NULL, 2, '1 mon');/* not ok */
249274
ERROR: 'atttype' should not be NULL
250-
SELECT validate_interval_value(1186, NULL, '1 mon');/* not ok */
275+
SELECT validate_interval_value('interval'::regtype, NULL, '1 mon');/* not ok */
251276
ERROR: 'parttype' should not be NULL
252-
SELECT validate_interval_value(23, 2, '1 mon');/* not ok */
277+
SELECT validate_interval_value('int4'::regtype, 2, '1 mon');/* not ok */
253278
ERROR: invalid input syntax for integer: "1 mon"
254-
SELECT validate_interval_value(1186, 1, '1 mon');/* not ok */
279+
SELECT validate_interval_value('interval'::regtype, 1, '1 mon');/* not ok */
255280
ERROR: interval should be NULL for HASH partitioned table
256-
SELECT validate_interval_value(1186, 2, NULL);/* OK */
281+
SELECT validate_interval_value('interval'::regtype, 2, NULL);/* OK */
257282
validate_interval_value
258283
-------------------------
259284
t

‎expected/pathman_column_type.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ SELECT context, entries FROM pathman_cache_stats ORDER BY context;
3131

3232
/* change column's type (should flush caches) */
3333
ALTER TABLE test_column_type.test ALTER val TYPE NUMERIC;
34-
/* check thatupd_expr is true */
34+
/* check thatparsed expression was cleared */
3535
SELECT * FROM pathman_config;
36-
partrel | attname | parttype | range_interval |expression_p| atttype | upd_expr
37-
-----------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------+----------
38-
test_column_type.test | val | 2 | 10 |{VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8}|23 | t
36+
partrel | attname | parttype | range_interval | expression_p | atttype
37+
-----------------------+---------+----------+----------------+--------------+---------
38+
test_column_type.test | val | 2 | 10 ||
3939
(1 row)
4040

4141
/* make sure that everything works properly */
@@ -44,11 +44,11 @@ SELECT * FROM test_column_type.test;
4444
-----
4545
(0 rows)
4646

47-
/* check that expression, atttype is changedand upd_expr is false*/
47+
/* check that expression, atttype is changed */
4848
SELECT * FROM pathman_config;
49-
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
50-
-----------------------+---------+----------+----------------+-------------------------------------------------------------------------------------------------------------------------+---------+----------
51-
test_column_type.test | val | 2 | 10 | {VAR :varno 1 :varattno 1 :vartype 1700 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 1700 | f
49+
partrel | attname | parttype | range_interval | expression_p | atttype
50+
-----------------------+---------+----------+----------------+-------------------------------------------------------------------------------------------------------------------------+---------
51+
test_column_type.test | val | 2 | 10 | {VAR :varno 1 :varattno 1 :vartype 1700 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 1700
5252
(1 row)
5353

5454
SELECT context, entries FROM pathman_cache_stats ORDER BY context;

‎expected/pathman_interval.out

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ SELECT set_interval('test_interval.abc', 1000);
3838

3939
INSERT INTO test_interval.abc VALUES (250);
4040
SELECT * FROM pathman_config;
41-
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
42-
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------+----------
43-
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 21 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 21 | f
41+
partrel | attname | parttype | range_interval | expression_p | atttype
42+
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------
43+
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 21 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 21
4444
(1 row)
4545

4646
DROP TABLE test_interval.abc CASCADE;
@@ -81,9 +81,9 @@ SELECT set_interval('test_interval.abc', 1000);
8181

8282
INSERT INTO test_interval.abc VALUES (250);
8383
SELECT * FROM pathman_config;
84-
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
85-
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------+----------
86-
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 23 | f
84+
partrel | attname | parttype | range_interval | expression_p | atttype
85+
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------
86+
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 23
8787
(1 row)
8888

8989
DROP TABLE test_interval.abc CASCADE;
@@ -124,9 +124,9 @@ SELECT set_interval('test_interval.abc', 1000);
124124

125125
INSERT INTO test_interval.abc VALUES (250);
126126
SELECT * FROM pathman_config;
127-
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
128-
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------+----------
129-
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 20 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 20 | f
127+
partrel | attname | parttype | range_interval | expression_p | atttype
128+
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------
129+
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 20 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 20
130130
(1 row)
131131

132132
DROP TABLE test_interval.abc CASCADE;
@@ -157,9 +157,9 @@ SELECT set_interval('test_interval.abc', '1 month'::INTERVAL);
157157
(1 row)
158158

159159
SELECT * FROM pathman_config;
160-
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
161-
-------------------+---------+----------+----------------+-------------------------------------------------------------------------------------------------------------------------+---------+----------
162-
test_interval.abc | dt | 2 | @ 1 mon | {VAR :varno 1 :varattno 1 :vartype 1082 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 1082 | f
160+
partrel | attname | parttype | range_interval | expression_p | atttype
161+
-------------------+---------+----------+----------------+-------------------------------------------------------------------------------------------------------------------------+---------
162+
test_interval.abc | dt | 2 | @ 1 mon | {VAR :varno 1 :varattno 1 :vartype 1082 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 1082
163163
(1 row)
164164

165165
DROP TABLE test_interval.abc CASCADE;

‎expected/pathman_permissions.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ NOTICE: sequence "user1_table_seq" does not exist, skipping
3232
/* Should be able to see */
3333
SET ROLE user2;
3434
SELECT * FROM pathman_config;
35-
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
36-
-------------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------+----------
37-
permissions.user1_table | id | 2 | 10 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 23 | f
35+
partrel | attname | parttype | range_interval | expression_p | atttype
36+
-------------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------
37+
permissions.user1_table | id | 2 | 10 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 23
3838
(1 row)
3939

4040
SELECT * FROM pathman_config_params;

‎hash.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,14 @@ LANGUAGE C;
173173
CREATEOR REPLACE FUNCTION @extschema@.get_hash_part_idx(INT4, INT4)
174174
RETURNSINTEGERAS'pg_pathman','get_hash_part_idx'
175175
LANGUAGE C STRICT;
176+
177+
/*
178+
* Build hash condition for a CHECK CONSTRAINT
179+
*/
180+
CREATEOR REPLACE FUNCTION @extschema@.build_hash_condition(
181+
attribute_typeREGTYPE,
182+
attributeTEXT,
183+
partitions_countINT4,
184+
partition_indexINT4)
185+
RETURNSTEXTAS'pg_pathman','build_hash_condition'
186+
LANGUAGE C STRICT;

‎init.sql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ CREATE TABLE IF NOT EXISTS @extschema@.pathman_config (
3636
attnameTEXTNOT NULL,/* expression*/
3737
parttypeINTEGERNOT NULL,
3838
range_intervalTEXT,
39-
expression_pTEXTNOT NULL,/* parsed expression (until plan)*/
40-
atttypeOIDNOT NULL,/* expression type*/
41-
upd_exprBOOL DEFAULT FALSE,/* update expression on next refresh?*/
39+
expression_pTEXT,/* parsed expression (until plan)*/
40+
atttypeOID,/* expression type*/
4241

4342
/* check for allowed part types*/
4443
CONSTRAINT pathman_config_parttype_checkCHECK (parttypeIN (1,2)),

‎sql/pathman_calamity.sql

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ SELECT set_interval('calamity.part_test', 'abc'::text);/* not ok */
110110
SELECT drop_partitions('calamity.part_test', true);
111111
DELETEFROMcalamity.part_test;
112112

113+
/* check function build_hash_condition()*/
114+
SELECT build_hash_condition('int4','val',10,1);
115+
SELECT build_hash_condition('text','val',10,1);
116+
SELECT build_hash_condition('int4','val',1,1);
117+
SELECT build_hash_condition('int4','val',10,20);
118+
SELECT build_hash_condition('text','val',10,NULL) ISNULL;
119+
SELECT build_hash_condition('calamity.part_test','val',10,1);
113120

114121
/* check function build_range_condition()*/
115122
SELECT build_range_condition(NULL,'val',10,20);/* not ok*/
@@ -119,11 +126,11 @@ SELECT build_range_condition('calamity.part_test', 'val', 10, NULL);/* OK */
119126
SELECT build_range_condition('calamity.part_test','val',NULL,10);/* OK*/
120127

121128
/* check function validate_interval_value()*/
122-
SELECT validate_interval_value(NULL,2,'1 mon');/* not ok*/
123-
SELECT validate_interval_value(1186,NULL,'1 mon');/* not ok*/
124-
SELECT validate_interval_value(23,2,'1 mon');/* not ok*/
125-
SELECT validate_interval_value(1186,1,'1 mon');/* not ok*/
126-
SELECT validate_interval_value(1186,2,NULL);/* OK*/
129+
SELECT validate_interval_value(NULL,2,'1 mon');/* not ok*/
130+
SELECT validate_interval_value('interval'::regtype,NULL,'1 mon');/* not ok*/
131+
SELECT validate_interval_value('int4'::regtype,2,'1 mon');/* not ok*/
132+
SELECT validate_interval_value('interval'::regtype,1,'1 mon');/* not ok*/
133+
SELECT validate_interval_value('interval'::regtype,2,NULL);/* OK*/
127134

128135
/* check function validate_relname()*/
129136
SELECT validate_relname('calamity.part_test');

‎sql/pathman_column_type.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ SELECT context, entries FROM pathman_cache_stats ORDER BY context;
2020
/* change column's type (should flush caches)*/
2121
ALTERTABLEtest_column_type.test ALTER val TYPENUMERIC;
2222

23-
/* check thatupd_expr is true*/
23+
/* check thatparsed expression was cleared*/
2424
SELECT*FROM pathman_config;
2525

2626
/* make sure that everything works properly*/
2727
SELECT*FROMtest_column_type.test;
2828

29-
/* check that expression, atttype is changedand upd_expr is false*/
29+
/* check that expression, atttype is changed*/
3030
SELECT*FROM pathman_config;
3131

3232
SELECT context, entriesFROM pathman_cache_statsORDER BY context;

‎src/include/pathman.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,13 @@
4444
* Definitions for the "pathman_config" table.
4545
*/
4646
#definePATHMAN_CONFIG"pathman_config"
47-
#defineNatts_pathman_config7
47+
#defineNatts_pathman_config6
4848
#defineAnum_pathman_config_partrel1/* partitioned relation (regclass) */
4949
#defineAnum_pathman_config_expression2/* partition expression (original) */
5050
#defineAnum_pathman_config_parttype3/* partitioning type (1|2) */
5151
#defineAnum_pathman_config_range_interval4/* interval for RANGE pt. (text) */
5252
#defineAnum_pathman_config_expression_p5/* parsed partition expression (text) */
5353
#defineAnum_pathman_config_atttype6/* partitioned atttype */
54-
#defineAnum_pathman_config_upd_expression7/* expression needs update */
5554

5655
/* type modifier (typmod) for 'range_interval' */
5756
#definePATHMAN_CONFIG_interval_typmod-1

‎src/include/relation_info.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,10 @@ PrelLastChild(const PartRelationInfo *prel)
237237
}
238238

239239

240-
PartRelationInfo*create_pathman_relation_info(Oidrelid);
241240
constPartRelationInfo*refresh_pathman_relation_info(Oidrelid,
242241
Datum*values,
243242
boolallow_incomplete);
244-
voidinvalidate_pathman_relation_info(Oidrelid,bool*found);
243+
PartRelationInfo*invalidate_pathman_relation_info(Oidrelid,bool*found);
245244
voidremove_pathman_relation_info(Oidrelid);
246245
constPartRelationInfo*get_pathman_relation_info(Oidrelid);
247246
constPartRelationInfo*get_pathman_relation_info_after_lock(Oidrelid,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp