diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2024-11-25 18:08:58 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2024-11-25 18:09:10 -0500 |
commit | 97be02ad0015502fac0b788bc0a4739a398f41d5 (patch) | |
tree | 2b0994dcf885c74904579157114e6643ebfa32f1 /src/include/executor | |
parent | 718af10dab446c2ae73fe027a9f65be69bcf2980 (diff) |
Fix NULLIF()'s handling of read-write expanded objects.
If passed a read-write expanded object pointer, the EEOP_NULLIF
code would hand that same pointer to the equality function
and then (unless equality was reported) also return the same
pointer as its value. This is no good, because a function that
receives a read-write expanded object pointer is fully entitled
to scribble on or even delete the object, thus corrupting the
NULLIF output. (This problem is likely unobservable with the
equality functions provided in core Postgres, but it's easy to
demonstrate with one coded in plpgsql.)
To fix, make sure the pointer passed to the equality function
is read-only. We can still return the original read-write
pointer as the NULLIF result, allowing optimization of later
operations.
Per bug #18722 from Alexander Lakhin. This has been wrong
since we invented expanded objects, so back-patch to all
supported branches.
Discussion: https://postgr.es/m/18722-fd9e645448cc78b4@postgresql.org
Diffstat (limited to 'src/include/executor')
-rw-r--r-- | src/include/executor/execExpr.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/executor/execExpr.h b/src/include/executor/execExpr.h index d983a9a7fed..ef1fa37716d 100644 --- a/src/include/executor/execExpr.h +++ b/src/include/executor/execExpr.h @@ -356,6 +356,7 @@ typedef struct ExprEvalStep /* faster to access without additional indirection: */ PGFunction fn_addr; /* actual call address */ int nargs; /* number of arguments */ + bool make_ro; /* make arg0 R/O (used only for NULLIF) */ } func; /* for EEOP_BOOL_*_STEP */ |