@@ -27,43 +27,52 @@ SELECT COUNT(*) FROM test_exprs.hash_rel;
2727 5
2828(1 row)
2929
30+ \set VERBOSITY default
3031/* Try using constant expression */
3132SELECT create_hash_partitions('test_exprs.hash_rel', '1 + 1', 4);
32- ERROR: partitioning expression should reference table "hash_rel"
33- \set VERBOSITY default
33+ ERROR: failed to analyze partitioning expression "1 + 1"
34+ DETAIL: partitioning expression should reference table "hash_rel"
35+ CONTEXT: SQL statement "SELECT public.validate_expression(parent_relid, expression)"
36+ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERFORM
37+ SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
38+ expression,
39+ partition_data)"
40+ PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
41+ /* Try using multiple queries */
42+ SELECT create_hash_partitions('test_exprs.hash_rel',
43+ 'value, (select oid from pg_class limit 1)',
44+ 4);
45+ ERROR: failed to analyze partitioning expression "value, (select oid from pg_class limit 1)"
46+ DETAIL: subqueries are not allowed in partitioning expression
47+ CONTEXT: SQL statement "SELECT public.validate_expression(parent_relid, expression)"
48+ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERFORM
49+ SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
50+ expression,
51+ partition_data)"
52+ PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
3453/* Try using mutable expression */
3554SELECT create_hash_partitions('test_exprs.hash_rel', 'random()', 4);
36- ERROR: failed to analyze partitioning expression ( random())
55+ ERROR: failed to analyze partitioning expression " random()"
3756DETAIL: functions in partitioning expression must be marked IMMUTABLE
3857CONTEXT: SQL statement "SELECT public.validate_expression(parent_relid, expression)"
3958PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERFORM
4059SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
4160 expression,
4261 partition_data)"
4362PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
44- /* Check that 'pathman_hooks_enabled' is true (1 partition in plan) */
45- EXPLAIN (COSTS OFF) INSERT INTO test_exprs.canary_copy
46- SELECT * FROM test_exprs.canary WHERE val = 1;
47- QUERY PLAN
48- ----------------------------------
49- Insert on canary_copy
50- -> Append
51- -> Seq Scan on canary_0
52- Filter: (val = 1)
53- (4 rows)
54-
55- /* Try using missing columns */
63+ /* Try using broken parentheses */
5664SELECT create_hash_partitions('test_exprs.hash_rel', 'value * value2))', 4);
57- ERROR: failed to parse partitioning expression ( value * value2)))
65+ ERROR: failed to parse partitioning expression " value * value2))"
5866DETAIL: syntax error at or near ")"
5967QUERY: SELECT public.validate_expression(parent_relid, expression)
6068CONTEXT: PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERFORM
6169SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
6270 expression,
6371 partition_data)"
6472PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
73+ /* Try using missing columns */
6574SELECT create_hash_partitions('test_exprs.hash_rel', 'value * value3', 4);
66- ERROR: failed to analyze partitioning expression ( value * value3)
75+ ERROR: failed to analyze partitioning expression " value * value3"
6776DETAIL: column "value3" does not exist
6877HINT: Perhaps you meant to reference the column "hash_rel.value" or the column "hash_rel.value2".
6978QUERY: SELECT public.validate_expression(parent_relid, expression)
@@ -144,15 +153,22 @@ EXPLAIN (COSTS OFF) SELECT * FROM test_exprs.hash_rel WHERE (value * value2) = 5
144153CREATE TABLE test_exprs.range_rel (id SERIAL PRIMARY KEY, dt TIMESTAMP, txt TEXT);
145154INSERT INTO test_exprs.range_rel (dt, txt)
146155SELECT g, md5(g::TEXT) FROM generate_series('2015-01-01', '2020-04-30', '1 month'::interval) as g;
156+ \set VERBOSITY default
147157/* Try using constant expression */
148158SELECT create_range_partitions('test_exprs.range_rel', '''16 years''::interval',
149159 '15 years'::INTERVAL, '1 year'::INTERVAL, 10);
150- ERROR: partitioning expression should reference table "range_rel"
151- \set VERBOSITY default
160+ ERROR: failed to analyze partitioning expression "'16 years'::interval"
161+ DETAIL: partitioning expression should reference table "range_rel"
162+ CONTEXT: SQL statement "SELECT public.validate_expression(parent_relid, expression)"
163+ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERFORM
164+ SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
165+ expression,
166+ partition_data)"
167+ PL/pgSQL function create_range_partitions(regclass,text,anyelement,interval,integer,boolean) line 12 at PERFORM
152168/* Try using mutable expression */
153169SELECT create_range_partitions('test_exprs.range_rel', 'RANDOM()',
154170 '15 years'::INTERVAL, '1 year'::INTERVAL, 10);
155- ERROR: failed to analyze partitioning expression ( RANDOM())
171+ ERROR: failed to analyze partitioning expression " RANDOM()"
156172DETAIL: functions in partitioning expression must be marked IMMUTABLE
157173CONTEXT: SQL statement "SELECT public.validate_expression(parent_relid, expression)"
158174PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERFORM
0 commit comments