pg_get_viewdef() and lateral references in COLUMNS of GRAPH_TABLE
Peter Eisentraut <peter@eisentraut.org>
Author:
Peter Eisentraut <peter@eisentraut.org>
Date: 2026-04-24T07:12:03Z
Releases:
19 (unreleased)
pg_get_viewdef() and lateral references in COLUMNS of GRAPH_TABLE Expressions in GRAPH_TABLE COLUMNS list may have lateral references. get_rule_expr() requires lateral namespaces to deparse such references. get_from_clause_item() does not pass them when processing the expressions in COLUMNS list causing ERROR "bogus varlevelsup: 0 offset 0". Fix get_from_clause_item() to pass input deparse_context containing lateral namespaces to get_rule_expr() instead of the dummy context. Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com> Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/CAHg%2BQDcLVa2iBnggkHxY4itZbXtDMfsYHEjnCUYe9hNbnxDi-w%40mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/ruleutils.c | modified | +2 −8 |
| src/test/regress/expected/graph_table.out | modified | +18 −8 |
| src/test/regress/sql/graph_table.sql | modified | +10 −2 |
Discussion
- Bug: pg_get_viewdef() fails on GRAPH_TABLE views with lateral column references 4 messages · 2026-04-18 → 2026-04-24