Skip to content

Commit

Permalink
Fix qp_with_clause testcase without asserts (#13878)
Browse files Browse the repository at this point in the history
- Fix off-by-one error in 71dd8b0239
- Add optimizer_trace_fallback to catch issue in non-assert build
  • Loading branch information
dgkimura authored and foreyes committed Nov 28, 2024
1 parent 111a7bc commit dce4491
Show file tree
Hide file tree
Showing 4 changed files with 11,215 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2844,7 +2844,7 @@ CExpressionPreprocessor::PexprTransposeSelectAndProject(CMemoryPool *mp,
exprhdl.Attach(pprojexpr);
exprhdl.DeriveProps(nullptr /*pdpctxt*/);

if (exprhdl.Arity() > 0 && exprhdl.DeriveHasNonScalarFunction(1))
if (exprhdl.Arity() > 1 && exprhdl.DeriveHasNonScalarFunction(1))
{
// Bail if project expression contains a set-returning function
pdrgpexpr->Release();
Expand Down
4 changes: 4 additions & 0 deletions src/test/regress/expected/qp_with_clause.out
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ NOTICE: table "country" does not exist, skipping
DROP TABLE IF EXISTS countrylanguage cascade;
NOTICE: table "countrylanguage" does not exist, skipping
--end_ignore
SET optimizer_trace_fallback=on;
BEGIN;
--SET client_encoding = 'LATIN1';
CREATE TABLE city (
Expand Down Expand Up @@ -614,6 +615,7 @@ where e1.code = e2.code order by e2.COUNTRY,e1.language LIMIT 20;
GIB | Gibraltar | Gibraltar | English | t | 88.9 | GIB | Gibraltar | Gibraltar | English | t | 88.9
(20 rows)

SET optimizer_trace_fallback=off;
-- query 2 using multiple CTEs with same names as tables.
with country as
(select country.code,country.name COUNTRY, city.name CAPITAL, language, isofficial, percentage
Expand Down Expand Up @@ -655,6 +657,7 @@ order by COUNTRY,percentage1 LIMIT 20;-- queries using same name for CTEs and th
GIB | Gibraltar | Gibraltar | English | t | 88.9 | Gibraltar
(20 rows)

SET optimizer_trace_fallback=on;
-- query1
with c1 as
(select country.code,country.name COUNTRY, city.name CAPITAL, language, isofficial, percentage
Expand Down Expand Up @@ -11129,3 +11132,4 @@ NOTICE: drop cascades to table countrylanguage
NOTICE: drop cascades to table country
NOTICE: drop cascades to table city
-- end_ignore
RESET optimizer_trace_fallback;
Loading

0 comments on commit dce4491

Please sign in to comment.