postgresql/src/backend
Tom Lane fe9b7b2fe5 Fix plpgsql to re-look-up composite type names at need.
Commit 4b93f5799 rearranged things in plpgsql to make it cope better with
composite types changing underneath it intra-session.  However, I failed to
consider the case of a composite type being dropped and recreated entirely.
In my defense, the previous coding didn't consider that possibility at all
either --- but it would accidentally work so long as you didn't change the
type's field list, because the built-at-compile-time list of component
variables would then still match the type's new definition.  The new
coding, however, occasionally tries to re-look-up the type by OID, and
then fails to find the dropped type.

To fix this, we need to save the TypeName struct, and then redo the type
OID lookup from that.  Of course that's expensive, so we don't want to do
it every time we need the type OID.  This can be fixed in the same way that
4b93f5799 dealt with changes to composite types' definitions: keep an eye
on the type's typcache entry to see if its tupledesc has been invalidated.
(Perhaps, at some point, this mechanism should be generalized so it can
work for non-composite types too; but for now, plpgsql only tries to
cope with intra-session redefinitions of composites.)

I'm slightly hesitant to back-patch this into v11, because it changes
the contents of struct PLpgSQL_type as well as the signature of
plpgsql_build_datatype(), so in principle it could break code that is
poking into the innards of plpgsql.  However, the only popular extension
of that ilk is pldebugger, and it doesn't seem to be affected.  Since
this is a regression for people who were relying on the old behavior,
it seems worth taking the small risk of causing compatibility issues.

Per bug #15913 from Daniel Fiori.  Back-patch to v11 where 4b93f5799
came in.

Discussion: https://postgr.es/m/15913-a7e112e16dedcffc@postgresql.org
2019-08-15 15:21:47 -04:00
..
access Remove block number field from nbtree stack. 2019-08-14 11:32:35 -07:00
bootstrap Fix inconsistencies and typos in the tree 2019-07-16 13:23:53 +09:00
catalog Fix inconsistencies and typos in the tree, take 10 2019-08-13 13:53:41 +09:00
commands Use a hash table to de-duplicate NOTIFY events faster. 2019-08-15 12:22:12 -04:00
executor Fix inconsistencies and typos in the tree, take 10 2019-08-13 13:53:41 +09:00
foreign Update copyright for 2019 2019-01-02 12:44:25 -05:00
jit Avoid macro clash with LLVM 9. 2019-07-29 10:23:55 +12:00
lib Fix inconsistencies in the code 2019-07-08 13:15:09 +09:00
libpq Fix inconsistencies and typos in the tree, take 10 2019-08-13 13:53:41 +09:00
main initdb: Remove obsolete locale handling 2019-08-14 06:51:13 +02:00
nodes Rationalize use of list_concat + list_copy combinations. 2019-08-12 11:20:18 -04:00
optimizer Don't constraint-exclude partitioned tables as much 2019-08-13 10:26:04 -04:00
parser Rationalize use of list_concat + list_copy combinations. 2019-08-12 11:20:18 -04:00
partitioning Don't constraint-exclude partitioned tables as much 2019-08-13 10:26:04 -04:00
po Translation updates 2019-06-17 15:30:20 +02:00
port Fix inconsistencies and typos in the tree, take 10 2019-08-13 13:53:41 +09:00
postmaster Fix inconsistencies and typos in the tree, take 10 2019-08-13 13:53:41 +09:00
regex Fix inconsistencies and typos in the tree, take 9 2019-08-05 12:14:58 +09:00
replication Fix inconsistencies and typos in the tree, take 10 2019-08-13 13:53:41 +09:00
rewrite Rationalize use of list_concat + list_copy combinations. 2019-08-12 11:20:18 -04:00
snowball Sync our Snowball stemmer dictionaries with current upstream 2019-07-04 13:26:48 +02:00
statistics Use column collation for extended statistics 2019-07-20 16:37:37 +02:00
storage Fix inconsistencies and typos in the tree, take 10 2019-08-13 13:53:41 +09:00
tcop Revert "Add log_statement_sample_rate parameter" 2019-08-04 23:38:27 +02:00
tsearch Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
utils Fix plpgsql to re-look-up composite type names at need. 2019-08-15 15:21:47 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
nls.mk Translation updates 2019-05-20 16:00:53 +02:00