Re: Re: BUG #16702: inline code and function : when use dynamic name for rowtype, there is some bug! - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: Re: BUG #16702: inline code and function : when use dynamic name for rowtype, there is some bug!
Date
Msg-id CAKFQuwYUuxmFUarSWWPV5ZfG8Mgf2MOy9CdV4Bpme2ScT0yf9A@mail.gmail.com
Whole thread Raw
In response to Re:Re: BUG #16702: inline code and function : when use dynamic name for rowtype, there is some bug!  (德哥 <digoal@126.com>)
List pgsql-bugs
On Mon, Nov 9, 2020 at 6:50 AM 德哥 <digoal@126.com> wrote:

but the execution behavior is biased, either do not replace the value of the variable during the execution, but directly use the table name corresponding to the variable name.


I've lost something in translation.  There is no bias (not sure what that means in this context) or variability/ambiguity here.  The thing in front of %RowType is always an identifier - specifically, a table.  That your function also has a variable of the same name is immaterial to PostgreSQL since none of the variables in the function are ever considered when it is expecting/required-to-have an identifier to fulfill the syntax.  This is well-defined in PostgreSQL pl/pgsql and so the observed behavior is not buggy.

"select tbl%rowtype into a%rowtype" is effectively (cast tbl%rowtype as a%rowtype) which is a well-defined and the user is responsible for ensuring the two rowtypes are compatible. "tbl" and "a" are compatible, "b" and "a" are not, which your original post demonstrates.

David J.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint
Next
From: Heath Lord
Date:
Subject: Re: REL_13_STABLE Windows 10 Regression Failures