Skip to content

Commit 241f2dd

Browse files
author
Maksim Milyutin
committed
Fix regression test on runtime_append node
1 parent 6d968d2 commit 241f2dd

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

expected/pathman_runtime_nodes.out

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ create or replace function test.pathman_test_2() returns text as $$
6464
declare
6565
plan jsonb;
6666
num int;
67+
c text;
6768
begin
6869
plan = test.pathman_test('select * from test.runtime_test_1 where id = any (select * from test.run_values limit 4)');
6970

@@ -82,11 +83,15 @@ begin
8283
select count(*) from jsonb_array_elements_text(plan->0->'Plan'->'Plans'->1->'Plans') into num;
8384
perform test.pathman_equal(num::text, '4', 'expected 4 child plans for custom scan');
8485

85-
for i in 0..3 loop
86-
perform test.pathman_equal((plan->0->'Plan'->'Plans'->1->'Plans'->i->'Relation Name')::text,
87-
format('"runtime_test_1_%s"', pathman.get_hash_part_idx(hashint4(i + 1), 6)),
88-
'wrong partition');
86+
execute 'select string_agg(y.z, '','') from
87+
(select (x->''Relation Name'')::text as z from
88+
jsonb_array_elements($1->0->''Plan''->''Plans''->1->''Plans'') x
89+
order by x->''Relation Name'') y'
90+
into c using plan;
91+
perform test.pathman_equal(c, '"runtime_test_1_2","runtime_test_1_3","runtime_test_1_4","runtime_test_1_5"',
92+
'wrong partitions');
8993

94+
for i in 0..3 loop
9095
num = plan->0->'Plan'->'Plans'->1->'Plans'->i->'Actual Loops';
9196
perform test.pathman_equal(num::text, '1', 'expected 1 loop');
9297
end loop;

sql/pathman_runtime_nodes.sql

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ create or replace function test.pathman_test_2() returns text as $$
7171
declare
7272
plan jsonb;
7373
num int;
74+
c text;
7475
begin
7576
plan = test.pathman_test('select * from test.runtime_test_1 where id = any (select * from test.run_values limit 4)');
7677

@@ -89,11 +90,15 @@ begin
8990
select count(*) from jsonb_array_elements_text(plan->0->'Plan'->'Plans'->1->'Plans') into num;
9091
perform test.pathman_equal(num::text, '4', 'expected 4 child plans for custom scan');
9192

92-
for i in 0..3 loop
93-
perform test.pathman_equal((plan->0->'Plan'->'Plans'->1->'Plans'->i->'Relation Name')::text,
94-
format('"runtime_test_1_%s"', pathman.get_hash_part_idx(hashint4(i + 1), 6)),
95-
'wrong partition');
93+
execute 'select string_agg(y.z, '','') from
94+
(select (x->''Relation Name'')::text as z from
95+
jsonb_array_elements($1->0->''Plan''->''Plans''->1->''Plans'') x
96+
order by x->''Relation Name'') y'
97+
into c using plan;
98+
perform test.pathman_equal(c, '"runtime_test_1_2","runtime_test_1_3","runtime_test_1_4","runtime_test_1_5"',
99+
'wrong partitions');
96100

101+
for i in 0..3 loop
97102
num = plan->0->'Plan'->'Plans'->1->'Plans'->i->'Actual Loops';
98103
perform test.pathman_equal(num::text, '1', 'expected 1 loop');
99104
end loop;

src/include/compat/pg_compat.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ extern void create_plain_partial_paths(PlannerInfo *root,
215215
extern Datum exprResult;
216216
extern ExprDoneCond isDone;
217217
static inline void
218+
dummy_handler() { }
219+
static inline void
218220
not_signle_result_handler()
219221
{
220222
elog(ERROR, ERR_PART_ATTR_MULTIPLE_RESULTS);

src/pg_pathman.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,11 +1153,8 @@ extract_const(Param *param,
11531153
{
11541154
ExprState *estate = ExecInitExpr((Expr *) param, NULL);
11551155
bool isnull;
1156-
#if PG_VERSION_NUM >= 100000
1157-
Datum value = ExecEvalExpr(estate, context->econtext, &isnull);
1158-
#else
1159-
Datum value = ExecEvalExpr(estate, context->econtext, &isnull, NULL);
1160-
#endif
1156+
Datum value = ExecEvalExprCompat(estate, context->econtext, &isnull,
1157+
dummy_handler);
11611158

11621159
return makeConst(param->paramtype, param->paramtypmod,
11631160
param->paramcollid, get_typlen(param->paramtype),

0 commit comments

Comments
 (0)