Re: Behavior of PL/pgSQL function following drop and re-create of a table that it uses

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bryn Llewellyn <bryn(at)yugabyte(dot)com>, pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Behavior of PL/pgSQL function following drop and re-create of a table that it uses
Date: 2023-03-08 04:56:25
Message-ID: CAKFQuwbhwM1OyzEp=JkW2KfsVGE6CDwMMMJjrX34HS_6rsErEQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Mar 7, 2023 at 9:49 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> > So I found where this difference in behavior is at least explicitly
> noted:
>
> >/*
> > * If it's a named composite type (or domain over one), find the typcache
> > * entry and record the current tupdesc ID, so we can detect changes
> > * (including drops). We don't currently support on-the-fly replacement
> > * of non-composite types, else we might want to do this for them too.
> > */
>
> I'm not quite sure that that's related, really. That code is concerned
> with detecting changes to an already-identified type (that is, type
> OID NNN has different details now than it did before). It seemed to
> me that Bryn's question was more about reacting to cases where a given
> string of source code would resolve to a different type OID than it
> did a moment ago.

Sorta, and now I see why %TYPE doesn't work but %ROWTYPE does - a change in
the former is necessarily a new OID while a change to the later will have
the same OID but a different internal structure that the type reference
compiled into the function can leverage to be resolve its structure at
runtime.

Of course, I went from almost clueless to this answer in just over an hour
so it is possible I'm wrong. But it seems to fit so far.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bryn Llewellyn 2023-03-08 05:19:34 Re: Behavior of PL/pgSQL function following drop and re-create of a table that it uses
Previous Message Tom Lane 2023-03-08 04:49:15 Re: Behavior of PL/pgSQL function following drop and re-create of a table that it uses