Address PostgreSQL 10's planned stmt changes

PostgreSQL appears to now stash the PlannedStmt somewhere within
ProcessUtility itself (per Marco), which results in a use-after-free
bug if we keep our old behavior of overriding the PlannedStmt's utility
statement with a copy with baked-in schema names.

The quickest fix is to just avoid this behavior altogether for
PostgreSQL 10. Because this area of code needs some attention anyhow
(i.e. we're not always doing the right things wrt schema name lookups
for our utility statements), Marco suggested this fix until we get to
a more comprehensive correction covering other utility commands.
pull/1439/head
Jason Petersen 2017-05-30 12:19:27 -06:00
parent 87d1928f0c
commit 38f25020e3
No known key found for this signature in database
GPG Key ID: 9F1D3510D110ABA9
1 changed files with 11 additions and 3 deletions

View File

@ -326,10 +326,18 @@ multi_ProcessUtility10(PlannedStmt *pstmt,
{ {
if (IsA(parsetree, IndexStmt)) if (IsA(parsetree, IndexStmt))
{ {
/* copy parse tree since we might scribble on it to fix the schema name */ /*
parsetree = copyObject(parsetree); * copy parse tree since we might scribble on it to fix the schema name
* FIXME: PostgreSQL 10 changes caching behavior and breaks this approach,
* so for that version we do assign back the modified tree.
*/
Node *parsetreeCopy = copyObject(parsetree);
ddlJobs = PlanIndexStmt((IndexStmt *) parsetree, queryString); ddlJobs = PlanIndexStmt((IndexStmt *) parsetreeCopy, queryString);
#if (PG_VERSION_NUM < 100000)
parsetree = parsetreeCopy;
#endif
} }
if (IsA(parsetree, DropStmt)) if (IsA(parsetree, DropStmt))