Skip to content

Commit fdf87ed

Browse files
committed
Fix failure-to-copy bug in commit 6f6b99d.
The previous coding of get_qual_for_list() was careful to copy everything it was using from the input data structure. The new version missed making a copy of pass-by-ref datum values that it's inserting into Consts. This is not optional, however, as revealed by buildfarm failures on machines running -DRELCACHE_FORCE_RELEASE: we're copying from a relcache entry that could go away before the required lifespan of our output expression. I'm pretty sure -DCLOBBER_CACHE_ALWAYS machines won't like this either, but none of them have reported in yet.
1 parent e56dd7c commit fdf87ed

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend/catalog/partition.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,12 +1559,18 @@ get_qual_for_list(Relation parent, PartitionBoundSpec *spec)
15591559
{
15601560
Const *val;
15611561

1562-
/* Construct const from datum */
1562+
/*
1563+
* Construct Const from known-not-null datum. We must be careful
1564+
* to copy the value, because our result has to be able to outlive
1565+
* the relcache entry we're copying from.
1566+
*/
15631567
val = makeConst(key->parttypid[0],
15641568
key->parttypmod[0],
15651569
key->parttypcoll[0],
15661570
key->parttyplen[0],
1567-
*boundinfo->datums[i],
1571+
datumCopy(*boundinfo->datums[i],
1572+
key->parttypbyval[0],
1573+
key->parttyplen[0]),
15681574
false, /* isnull */
15691575
key->parttypbyval[0]);
15701576

0 commit comments

Comments
 (0)