ERROR: PlaceHolderVar found where not expected

Поиск
Список
Период
Сортировка
От Richard Guo
Тема ERROR: PlaceHolderVar found where not expected
Дата
Msg-id CAMbWs48Mmvm-acGevXuwpB=g5JMqVSL6i9z5UaJyLGJqa-XPAA@mail.gmail.com
обсуждение исходный текст
Ответы Re: ERROR: PlaceHolderVar found where not expected  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
I came across an ERROR as $subject with query below.

create table t (a int, b int);
create statistics if not exists t_s0 (dependencies, ndistinct) on a, b from t;
insert into t values(1,1);
analyze t;

SELECT * FROM t LEFT JOIN (select true as c0) s0 ON true INNER JOIN (select true as c0) s1 ON s0.c0 INNER JOIN (select true as c0) s2 ON s0.c0;

This is due to that we use 0 flags for pull_var_clause in
dependency_is_compatible_expression, assuming that the 'clause_expr'
cannot contain Aggrefs, WindowFuncs or PlaceHolderVars.  This should be
an oversight as we can see that it's possible to find PHVs here.  We can
fix it by

--- a/src/backend/statistics/dependencies.c
+++ b/src/backend/statistics/dependencies.c
@@ -1316,7 +1316,7 @@ dependency_is_compatible_expression(Node *clause, Index relid, List *statlist, N
    if (IsA(clause_expr, RelabelType))
        clause_expr = (Node *) ((RelabelType *) clause_expr)->arg;

-   vars = pull_var_clause(clause_expr, 0);
+   vars = pull_var_clause(clause_expr, PVC_RECURSE_PLACEHOLDERS);

But I'm not sure if Aggrefs and WindowFuncs are possible to be found
here.

This issue can be seen on 14, 15 and master.

Thanks
Richard

В списке pgsql-bugs по дате отправления:

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #17839: Heap-buffer overflow on float8_to_char with invalid template
Следующее
От: Tom Lane
Дата:
Сообщение: Re: ERROR: PlaceHolderVar found where not expected