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

Commit8bb4874

Browse files
committed
restrict system attributes in partitioning expression
1 parent9c4dd49 commit8bb4874

File tree

5 files changed

+36
-18
lines changed

5 files changed

+36
-18
lines changed

‎expected/pathman_calamity.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,21 @@ SELECT build_range_condition('calamity.part_test', 'val', NULL, 10);/* OK */
280280
(1 row)
281281

282282
/* check function validate_interval_value() */
283-
SELECT validate_interval_value(1::REGCLASS, 'expr', 2, '1 mon', 'cooked_expr');/* not ok */
283+
SELECT validate_interval_value(1::REGCLASS, 'expr', 2, '1 mon', 'cooked_expr');/* not ok */
284284
ERROR: relation "1" does not exist
285-
SELECT validate_interval_value(NULL, 'expr', 2, '1 mon', 'cooked_expr');/* not ok */
285+
SELECT validate_interval_value(NULL, 'expr', 2, '1 mon', 'cooked_expr');/* not ok */
286286
ERROR: 'partrel' should not be NULL
287-
SELECT validate_interval_value('pg_class', NULL, 2, '1 mon', 'cooked_expr');/* not ok */
287+
SELECT validate_interval_value('pg_class', NULL, 2, '1 mon', 'cooked_expr');/* not ok */
288288
ERROR: 'expression' should not be NULL
289-
SELECT validate_interval_value('pg_class', 'oid', NULL, '1 mon', 'cooked_expr');/* not ok */
289+
SELECT validate_interval_value('pg_class', 'relname', NULL, '1 mon', 'cooked_expr');/* not ok */
290290
ERROR: 'parttype' should not be NULL
291-
SELECT validate_interval_value('pg_class', 'oid', 1, 'HASH', NULL);/* not ok */
291+
SELECT validate_interval_value('pg_class', 'relname', 1, 'HASH', NULL);/* not ok */
292292
ERROR: interval should be NULL for HASH partitioned table
293-
SELECT validate_interval_value('pg_class', 'expr', 2, '1 mon', NULL);/* not ok */
293+
SELECT validate_interval_value('pg_class', 'expr', 2, '1 mon', NULL);/* not ok */
294294
ERROR: failed to analyze partitioning expression "expr"
295-
SELECT validate_interval_value('pg_class', 'expr', 2, NULL, 'cooked_expr');/* not ok */
295+
SELECT validate_interval_value('pg_class', 'expr', 2, NULL, 'cooked_expr');/* not ok */
296296
ERROR: unrecognized token: "cooked_expr"
297-
SELECT validate_interval_value('pg_class', 'EXPR', 1, 'HASH', NULL);/* not ok */
297+
SELECT validate_interval_value('pg_class', 'EXPR', 1, 'HASH', NULL);/* not ok */
298298
ERROR: failed to analyze partitioning expression "EXPR"
299299
/* check function validate_relname() */
300300
SELECT validate_relname('calamity.part_test');

‎expected/pathman_expressions.out

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,17 @@ SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
235235
expression,
236236
partition_data)"
237237
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
238-
/* Try using multiple queries */
238+
/* Try using system attributes */
239+
SELECT create_hash_partitions('test_exprs.hash_rel', 'xmin', 4);
240+
ERROR: failed to analyze partitioning expression "xmin"
241+
DETAIL: system attributes are not supported
242+
CONTEXT: SQL statement "SELECT public.validate_expression(parent_relid, expression)"
243+
PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERFORM
244+
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
245+
expression,
246+
partition_data)"
247+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
248+
/* Try using subqueries */
239249
SELECT create_hash_partitions('test_exprs.hash_rel',
240250
'value, (select oid from pg_class limit 1)',
241251
4);

‎sql/pathman_calamity.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ SELECT build_range_condition('calamity.part_test', 'val', 10, NULL);/* OK */
132132
SELECT build_range_condition('calamity.part_test','val',NULL,10);/* OK*/
133133

134134
/* check function validate_interval_value()*/
135-
SELECT validate_interval_value(1::REGCLASS,'expr',2,'1 mon','cooked_expr');/* not ok*/
136-
SELECT validate_interval_value(NULL,'expr',2,'1 mon','cooked_expr');/* not ok*/
137-
SELECT validate_interval_value('pg_class',NULL,2,'1 mon','cooked_expr');/* not ok*/
138-
SELECT validate_interval_value('pg_class','oid',NULL,'1 mon','cooked_expr');/* not ok*/
139-
SELECT validate_interval_value('pg_class','oid',1,'HASH',NULL);/* not ok*/
140-
SELECT validate_interval_value('pg_class','expr',2,'1 mon',NULL);/* not ok*/
141-
SELECT validate_interval_value('pg_class','expr',2,NULL,'cooked_expr');/* not ok*/
142-
SELECT validate_interval_value('pg_class','EXPR',1,'HASH',NULL);/* not ok*/
135+
SELECT validate_interval_value(1::REGCLASS,'expr',2,'1 mon','cooked_expr');/* not ok*/
136+
SELECT validate_interval_value(NULL,'expr',2,'1 mon','cooked_expr');/* not ok*/
137+
SELECT validate_interval_value('pg_class',NULL,2,'1 mon','cooked_expr');/* not ok*/
138+
SELECT validate_interval_value('pg_class','relname',NULL,'1 mon','cooked_expr');/* not ok*/
139+
SELECT validate_interval_value('pg_class','relname',1,'HASH',NULL);/* not ok*/
140+
SELECT validate_interval_value('pg_class','expr',2,'1 mon',NULL);/* not ok*/
141+
SELECT validate_interval_value('pg_class','expr',2,NULL,'cooked_expr');/* not ok*/
142+
SELECT validate_interval_value('pg_class','EXPR',1,'HASH',NULL);/* not ok*/
143143

144144
/* check function validate_relname()*/
145145
SELECT validate_relname('calamity.part_test');

‎sql/pathman_expressions.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ SELECT COUNT(*) FROM test_exprs.hash_rel;
9494
/* Try using constant expression*/
9595
SELECT create_hash_partitions('test_exprs.hash_rel','1 + 1',4);
9696

97-
/* Try using multiple queries*/
97+
/* Try using system attributes*/
98+
SELECT create_hash_partitions('test_exprs.hash_rel','xmin',4);
99+
100+
/* Try using subqueries*/
98101
SELECT create_hash_partitions('test_exprs.hash_rel',
99102
'value, (select oid from pg_class limit 1)',
100103
4);

‎src/relation_info.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,11 @@ cook_partitioning_expression(const Oid relid,
731731
AttrNumberattnum=expr_attr+FirstLowInvalidHeapAttributeNumber;
732732
HeapTuplehtup;
733733

734+
/* Check that there's no system attributes in expression */
735+
if (attnum<InvalidAttrNumber)
736+
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
737+
errmsg("system attributes are not supported")));
738+
734739
htup=SearchSysCache2(ATTNUM,
735740
ObjectIdGetDatum(relid),
736741
Int16GetDatum(attnum));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp