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

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Re: BUG #16702: inline code and function : when use dynamic name for rowtype, there is some bug!
Дата
Msg-id CAKFQuwYUuxmFUarSWWPV5ZfG8Mgf2MOy9CdV4Bpme2ScT0yf9A@mail.gmail.com
обсуждение исходный текст
Ответ на Re:Re: BUG #16702: inline code and function : when use dynamic name for rowtype, there is some bug!  (德哥 <digoal@126.com>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint
Следующее
От: Heath Lord
Дата:
Сообщение: Re: REL_13_STABLE Windows 10 Regression Failures