Skip to content

Commit 8eda1a5

Browse files
committed
Extra checks for temp relations access during function creation/deletion.
Fixes rangefuncs and portals regression tests.
1 parent 87d0276 commit 8eda1a5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/backend/catalog/namespace.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,19 @@ RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode,
406406
oldRelId = relId;
407407
}
408408

409+
/*
410+
* MTM-CRUTCH: It's possible to create DDL statements that are checking
411+
* for relation existense but do not open them. So in case of temp relation
412+
* we won't call relation_open() and hence will not set MyXactAccessedTempRel.
413+
*
414+
* To skip replication of such DDL do dummy open/close here.
415+
*/
416+
if (OidIsValid(relId))
417+
{
418+
Relation r = try_relation_open(relId, NoLock);
419+
relation_close(r, NoLock);
420+
}
421+
409422
if (!OidIsValid(relId) && !missing_ok)
410423
{
411424
if (relation->schemaname)

src/backend/commands/functioncmds.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,10 @@ RemoveFunctionById(Oid funcOid)
11201120
Relation relation;
11211121
HeapTuple tup;
11221122
bool isagg;
1123+
Oid language_oid;
1124+
HeapTuple languageTuple;
1125+
Form_pg_language languageStruct;
1126+
Oid languageValidator;
11231127

11241128
/*
11251129
* Delete the pg_proc tuple.
@@ -1132,6 +1136,18 @@ RemoveFunctionById(Oid funcOid)
11321136

11331137
isagg = ((Form_pg_proc) GETSTRUCT(tup))->proisagg;
11341138

1139+
/*
1140+
* MTM-CRUTCH: We need to know wheteher our function had
1141+
* accessed temp relation or not. So validate function body
1142+
* again -- that will set MyXactAccessedTempRel.
1143+
*/
1144+
language_oid = ((Form_pg_proc) GETSTRUCT(tup))->prolang;
1145+
languageTuple = SearchSysCache1(LANGOID, language_oid);
1146+
languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
1147+
languageValidator = languageStruct->lanvalidator;
1148+
OidFunctionCall1(languageValidator, ObjectIdGetDatum(funcOid));
1149+
ReleaseSysCache(languageTuple);
1150+
11351151
simple_heap_delete(relation, &tup->t_self);
11361152

11371153
ReleaseSysCache(tup);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy