minor fix for CloneRowTriggersToPartition

Started by Amit Langoteover 7 years ago2 messages
#1Amit Langote
Langote_Amit_f8@lab.ntt.co.jp
1 attachment(s)

Hi.

I think we should apply the attached patch so that a CreateTriggerStmt
that CloneRowTriggersToPartition creates for a partition doesn't contain
pointers that point to the information in the parent table's relcache,
which may go stale before the pointers in question are used.

Thanks,
Amit

Attachments:

pstrdup-string-from-relcache.patchtext/plain; charset=UTF-8; name=pstrdup-string-from-relcache.patchDownload
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index fe4265d4bb..9b1194d15f 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -14560,7 +14560,8 @@ CloneRowTriggersToPartition(Relation parent, Relation partition)
 
 				col = TupleDescAttr(parent->rd_att,
 									trigForm->tgattr.values[i] - 1);
-				cols = lappend(cols, makeString(NameStr(col->attname)));
+				cols = lappend(cols,
+							   makeString(pstrdup(NameStr(col->attname))));
 			}
 		}
 
#2Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Amit Langote (#1)
Re: minor fix for CloneRowTriggersToPartition

Amit Langote wrote:

Hi.

I think we should apply the attached patch so that a CreateTriggerStmt
that CloneRowTriggersToPartition creates for a partition doesn't contain
pointers that point to the information in the parent table's relcache,
which may go stale before the pointers in question are used.

Thanks for catching that! Pushed.

--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services