Re: [Bug] Add the missing RTE_GRAPH_TABLE case to transformLockingClause()

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: [Bug] Add the missing RTE_GRAPH_TABLE case to transformLockingClause()
Date: 2026-05-13 05:27:13
Message-ID: CAExHW5sQ5CfQeO4QXQaArRpD5FrUK_ndDAqHiQFg04DaC-+NaQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, May 7, 2026 at 1:07 PM SATYANARAYANA NARLAPURAM
<satyanarlapuram(at)gmail(dot)com> wrote:
>
> Hi Hackers,
>
> Add the missing RTE_GRAPH_TABLE case to transformLockingClause(). Without this four
> row-locking strengths applied to a GRAPH_TABLE alias triggers not give a user friendly
> error message.
>
> Repro:
>
> CREATE TABLE v(id int PRIMARY KEY, vname text);
> CREATE PROPERTY GRAPH g VERTEX TABLES (v);
> SELECT * FROM GRAPH_TABLE(g MATCH (a) COLUMNS (a.vname)) gt
> FOR UPDATE OF gt;
> -- ERROR: unrecognized RTE type: 8
>
> Attached a patch that returns ERRCODE_FEATURE_NOT_SUPPORTED "FOR ... cannot be
> applied to a GRAPH_TABLE" with a position pointer, matching the convention used by
> the function/tablefunc etc.

In a fully matured SQL/PGQ support, a row mark on GRAPH_TABLE should
be pushed down to the resulting subqueries in rewriteGraphTable(). I
see this similar to how the row mark is pushed down into views during
the rewrite phase. I don't think the code changes will be massive, it
will be a matter of invoking markQueryForLocking() on the query that
replaces the graph pattern in rewriteGraphTable(). I am not sure
whether we want to do that now when stabilizing the feature. Peter,
what do you think?

If we decide to not to support it, the code changes look on the right
path. We need to update the following comment which appears earlier in
the function to mention GRAPH_TABLE, /* ignore JOIN, SPECIAL,
FUNCTION, VALUES, CTE RTEs */. I think it will be better to specify
that this restriction is temporary in the comments at both the places;
but that's arguable.

> Patch includes tests for all four locking strengths.
> Since the code path looks simple we can just keep one of them as well and trim other
> tests. Thoughts?

I don't think we need all the four tests, but we need a test for
locking clause without relation since that takes a different code
path.

--
Best Wishes,
Ashutosh Bapat

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-05-13 05:31:01 Re: Fix unsafe PlannedStmt access in pg_stat_statements
Previous Message shveta malik 2026-05-13 05:24:20 Re: Parallel Apply