]> granicus.if.org Git - postgresql/commitdiff
Copy name when cloning FKs recurses to partitions
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 3 Apr 2019 18:32:53 +0000 (15:32 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 3 Apr 2019 18:35:54 +0000 (15:35 -0300)
We were passing a string owned by a syscache entry, which was released
before recursing.  Fix by pstrdup'ing the string.

Per buildfarm member prion.

src/backend/commands/tablecmds.c

index 978b6bec44a19518ccd5d0dbef1dc45ccbe1244e..58eb7e1d8e83f0d8489045ba63f01e9190da6247 100644 (file)
@@ -8619,7 +8619,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
                                                                         "fkey",
                                                                         RelationGetNamespace(partRel), NIL);
                else
-                       fkconstraint->conname = NameStr(constrForm->conname);
+                       fkconstraint->conname = pstrdup(NameStr(constrForm->conname));
                fkconstraint->fk_upd_action = constrForm->confupdtype;
                fkconstraint->fk_del_action = constrForm->confdeltype;
                fkconstraint->deferrable = constrForm->condeferrable;