aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pl/plpgsql/src/expected/plpgsql_record.out6
-rw-r--r--src/pl/plpgsql/src/pl_exec.c11
-rw-r--r--src/pl/plpgsql/src/sql/plpgsql_record.sql1
3 files changed, 17 insertions, 1 deletions
diff --git a/src/pl/plpgsql/src/expected/plpgsql_record.out b/src/pl/plpgsql/src/expected/plpgsql_record.out
index 403c6358b93..cf6089cbb21 100644
--- a/src/pl/plpgsql/src/expected/plpgsql_record.out
+++ b/src/pl/plpgsql/src/expected/plpgsql_record.out
@@ -476,6 +476,12 @@ select sillyaddtwo(42);
44
(1 row)
+select sillyaddtwo(43);
+ sillyaddtwo
+-------------
+ 45
+(1 row)
+
-- check access to system columns in a record variable
create function sillytrig() returns trigger language plpgsql as
$$begin
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 2deb7c0b12a..d1775d36152 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -6858,7 +6858,16 @@ revalidate_rectypeid(PLpgSQL_rec *rec)
Assert(typ != NULL);
if (typ->tcache &&
typ->tcache->tupDesc_identifier == typ->tupdesc_id)
- return; /* known up-to-date */
+ {
+ /*
+ * Although *typ is known up-to-date, it's possible that rectypeid
+ * isn't, because *rec is cloned during each function startup from a
+ * copy that we don't have a good way to update. Hence, forcibly fix
+ * rectypeid before returning.
+ */
+ rec->rectypeid = typ->typoid;
+ return;
+ }
/*
* typcache entry has suffered invalidation, so re-look-up the type name
diff --git a/src/pl/plpgsql/src/sql/plpgsql_record.sql b/src/pl/plpgsql/src/sql/plpgsql_record.sql
index e93aeac5b9a..128846e6108 100644
--- a/src/pl/plpgsql/src/sql/plpgsql_record.sql
+++ b/src/pl/plpgsql/src/sql/plpgsql_record.sql
@@ -303,6 +303,7 @@ drop table mutable2;
select sillyaddtwo(42); -- fail
create table mutable2(f0 text, f1 int, f2 text);
select sillyaddtwo(42);
+select sillyaddtwo(43);
-- check access to system columns in a record variable