Commit 3decd150 authored by Tom Lane's avatar Tom Lane

Teach eval_const_expressions() to handle some more cases.

Add some infrastructure (mostly macros) to make it easier to write
typical cases for constant-expression simplification.  Add simplification
processing for ArrayRef, RowExpr, and ScalarArrayOpExpr node types,
which formerly went unsimplified even if all their inputs were constants.
Also teach it to simplify FieldSelect from a composite constant.
Make use of the new infrastructure to reduce the amount of code needed
for the existing ArrayExpr and ArrayCoerceExpr cases.

One existing test case changes output as a result of the fact that
RowExpr can now be folded to a constant.  All the new code is exercised
by existing test cases according to gcov, so I feel no need to add
additional tests.

Tom Lane, reviewed by Dmitry Dolgov

Discussion: https://postgr.es/m/3be3b82c-e29c-b674-2163-bf47d98817b1@iki.fi
parent 35c0754f
This diff is collapsed.
...@@ -307,10 +307,10 @@ ERROR: cannot compare dissimilar column types bigint and integer at record colu ...@@ -307,10 +307,10 @@ ERROR: cannot compare dissimilar column types bigint and integer at record colu
explain (costs off) explain (costs off)
select * from int8_tbl i8 select * from int8_tbl i8
where i8 in (row(123,456)::int8_tbl, '(4567890123456789,123)'); where i8 in (row(123,456)::int8_tbl, '(4567890123456789,123)');
QUERY PLAN QUERY PLAN
----------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Seq Scan on int8_tbl i8 Seq Scan on int8_tbl i8
Filter: (i8.* = ANY (ARRAY[ROW('123'::bigint, '456'::bigint)::int8_tbl, '(4567890123456789,123)'::int8_tbl])) Filter: (i8.* = ANY ('{"(123,456)","(4567890123456789,123)"}'::int8_tbl[]))
(2 rows) (2 rows)
select * from int8_tbl i8 select * from int8_tbl i8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment