Re: Row pattern recognition

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: assam258(at)gmail(dot)com
Cc: Tatsuo Ishii <ishii(at)postgresql(dot)org>, zsolt(dot)parragi(at)percona(dot)com, sjjang112233(at)gmail(dot)com, vik(at)postgresfriends(dot)org, er(at)xs4all(dot)nl, jacob(dot)champion(at)enterprisedb(dot)com, david(dot)g(dot)johnston(at)gmail(dot)com, peter(at)eisentraut(dot)org, li(dot)evan(dot)chao(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Row pattern recognition
Date: 2026-10-08 08:34:32
Message-ID: CACJufxFWHp9Nb9CuLoHOGMVmV78cZeHk5piAyDFON3sr-XMQvQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 6, 2026 at 11:25 AM Henson Choi <assam258(at)gmail(dot)com> wrote:
>
> Thank you for the v54-0001 refactoring.
>
> Worse: when a navigation call is inside an offset. A navigation call
> in the offset position is already the mistake; what is inside it is
> secondary. Before, the caret was on that call. Now the inner call is
> checked first, so the error is about its argument and the caret is on
> that argument. The message no longer says that the offset cannot
> contain a navigation operation; when the inner call has no column
> reference it asks for one, and adding one only leads to the run-time
> constant error.
>
> Before:
> ERROR: row pattern navigation offset cannot contain a row pattern navigation operation
> LINE 6: DEFINE A AS PREV(val, FIRST(1)) > 0)
> ^
> After:
> ERROR: argument of row pattern navigation operation must include at least one column reference
> LINE 6: DEFINE A AS PREV(val, FIRST(1)) > 0)
> ^

There is a different way to intrepert this.
If we first process FIRST, the error message saying
ERROR: argument of row pattern navigation operation must include at
least one column reference

If we first process PREV, then
ERROR: row pattern navigation offset cannot contain a row pattern
navigation operation

My patch uses a bottom-up approach.
DEFINE A AS PREV(val, FIRST(1)) > 0)
first process expression (FIRST(1))

Different ways of processing the navigation yield different error
messages, and therefore the error position also differs.
So i think this should be ok.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message wenhui qiu 2026-10-08 08:50:16 Re: "failed to build any N-way joins" from a five-relation query
Previous Message Chao Li 2026-10-08 08:33:22 Re: pg_resetwal: add --cluster-state option