postgresql/src/test/regress/expected
Tom Lane 9bc33ef5ec Prevent dangling-pointer access when update trigger returns old tuple.
A before-update row trigger may choose to return the "new" or "old" tuple
unmodified.  ExecBRUpdateTriggers failed to consider the second
possibility, and would proceed to free the "old" tuple even if it was the
one returned, leading to subsequent access to already-deallocated memory.
In debug builds this reliably leads to an "invalid memory alloc request
size" failure; in production builds it might accidentally work, but data
corruption is also possible.

This is a very old bug.  There are probably a couple of reasons it hasn't
been noticed up to now.  It would be more usual to return NULL if one
wanted to suppress the update action; returning "old" is significantly less
efficient since the update will occur anyway.  Also, none of the standard
PLs would ever cause this because they all returned freshly-manufactured
tuples even if they were just copying "old".  But commit 4b93f5799 changed
that for plpgsql, making it possible to see the bug with a plpgsql trigger.
Still, this is certainly legal behavior for a trigger function, so it's
ExecBRUpdateTriggers's fault not plpgsql's.

It seems worth creating a test case that exercises returning "old" directly
with a C-language trigger; testing this through plpgsql seems unreliable
because its behavior might change again.

Report and fix by Rushabh Lathia; regression test case by me.
Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAGPqQf1P4pjiNPrMof=P_16E-DFjt457j+nH2ex3=nBTew7tXw@mail.gmail.com
2018-02-27 13:27:38 -05:00
..
.gitignore Add a SECURITY LABEL command. 2010-09-27 20:55:27 -04:00
abstime.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
advisory_lock.out Add transaction-level advisory locks. 2011-02-18 14:05:12 +09:00
aggregates.out Fix improper repetition of previous results from a hashed aggregate. 2016-08-24 14:37:51 -04:00
alter_generic.out Refactor ALTER some-obj RENAME implementation 2013-01-21 12:06:41 -03:00
alter_table.out Fix crash when columns have been added to the end of a view. 2017-10-27 17:10:21 -04:00
arrays.out Fix handling of empty arrays in array_fill(). 2017-01-05 11:33:51 -05:00
bit.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
bitmapops.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
boolean.out Clean up references to SQL92 2013-04-20 11:04:41 -04:00
box.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
btree_index.out Fix breakage of bitmap scan plan creation for special index operators such 2008-11-20 19:52:54 +00:00
case.out Fix instability in parallel regression tests. 2016-08-25 09:57:37 -04:00
char.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
char_1.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
char_2.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
circle.out Add a bunch of new error location reports to parse-analysis error messages. 2008-09-01 20:42:46 +00:00
cluster.out Reduce messages about implicit indexes and sequences to DEBUG1. 2012-07-04 20:35:29 -04:00
collate.linux.utf8.out Avoid using unsafe search_path settings during dump and restore. 2018-02-26 10:18:22 -05:00
collate.out Avoid using unsafe search_path settings during dump and restore. 2018-02-26 10:18:22 -05:00
combocid.out Fix locking a tuple updated by an aborted (sub)transaction 2016-09-09 15:54:29 -03:00
comments.out Implement nested block comments in the backend and in psql. 2000-07-14 15:43:57 +00:00
conversion.out Support hex-string input and output for type BYTEA. 2009-08-04 16:08:37 +00:00
copy2.out Fix null-pointer-deref crash while doing COPY IN with check constraints. 2015-02-15 23:26:46 -05:00
copyselect.out Reduce messages about implicit indexes and sequences to DEBUG1. 2012-07-04 20:35:29 -04:00
create_aggregate.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
create_cast.out Improve psql's tabular display of wrapped-around data by inserting markers 2009-11-22 05:20:41 +00:00
create_function_3.out Remove whitespace from end of lines 2012-05-15 22:19:41 +03:00
create_index.out Reset the proper GUC in create_index test. 2017-01-18 16:33:59 -05:00
create_misc.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
create_operator.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
create_table.out Reduce messages about implicit indexes and sequences to DEBUG1. 2012-07-04 20:35:29 -04:00
create_table_like.out Update messages, comments and documentation for materialized views. 2013-07-05 15:26:46 -04:00
create_type.out Fix dependency, when changing a function's argument/return type. 2017-06-16 11:46:11 +03:00
create_view.out Ensure that pg_get_ruledef()'s output matches pg_get_viewdef()'s. 2017-07-24 15:16:31 -04:00
date.out Extend the date type to support infinity and -infinity, analogously to 2008-10-14 17:12:33 +00:00
delete.out Reduce messages about implicit indexes and sequences to DEBUG1. 2012-07-04 20:35:29 -04:00
dependency.out Rework internals of changing a type's ownership 2015-12-21 19:49:15 -03:00
domain.out Fix handling of container types in find_composite_type_dependencies. 2017-08-09 17:03:10 -04:00
drop_if_exists.out Fix DROP OPERATOR FAMILY IF EXISTS. 2011-10-21 09:12:23 -04:00
enum.out Allow adding values to an enum type created in the current transaction. 2012-12-01 14:27:30 -05:00
equivclass.out Fix some more problems with nested append relations. 2014-10-01 19:30:30 -04:00
errors.out Be more clear when a new column name collides with a system column name. 2012-01-26 12:44:30 -05:00
event_trigger.out Remove quotes around SQL statement in error message 2013-04-11 12:00:09 -03:00
float4-exp-three-digits.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
float4.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
float8-exp-three-digits-win32.out Revert "Add some regression test cases for denormalized float8 input." 2012-02-04 15:52:09 -05:00
float8-small-is-zero.out Revert "Add some regression test cases for denormalized float8 input." 2012-02-04 15:52:09 -05:00
float8-small-is-zero_1.out Revert "Add some regression test cases for denormalized float8 input." 2012-02-04 15:52:09 -05:00
float8.out Revert "Add some regression test cases for denormalized float8 input." 2012-02-04 15:52:09 -05:00
foreign_data.out Again match pg_user_mappings to information_schema.user_mapping_options. 2017-08-07 07:09:31 -07:00
foreign_key.out Check for pending trigger events on far end when dropping an FK constraint. 2016-11-25 13:44:48 -05:00
functional_deps.out Reduce messages about implicit indexes and sequences to DEBUG1. 2012-07-04 20:35:29 -04:00
geometry.out Rewrite the planner's handling of materialized plan types so that there is 2009-09-12 22:12:09 +00:00
geometry_1.out Rewrite the planner's handling of materialized plan types so that there is 2009-09-12 22:12:09 +00:00
geometry_2.out Rewrite the planner's handling of materialized plan types so that there is 2009-09-12 22:12:09 +00:00
guc.out Don't fail for bad GUCs in CREATE FUNCTION with check_function_bodies off. 2013-09-03 18:32:23 -04:00
hash_index.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
horology.out Fix some odd behaviors when using a SQL-style simple GMT offset timezone. 2013-11-01 12:13:23 -04:00
hs_standby_allowed.out Fix breakages of hot standby regression test. 2014-06-06 18:46:32 +09:00
hs_standby_check.out Allow read only connections during recovery, known as Hot Standby. 2009-12-19 01:32:45 +00:00
hs_standby_disallowed.out Fix breakages of hot standby regression test. 2014-06-06 18:46:32 +09:00
hs_standby_functions.out Update standbycheck test output with new ERROR message changes. No changes 2010-05-02 12:28:43 +00:00
inet.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
inherit.out Handle OID column inheritance correctly in ALTER TABLE ... INHERIT. 2017-01-04 18:00:12 -05:00
insert.out When a row fails a not-null constraint, show row's contents in errdetail. 2011-11-29 18:29:18 -05:00
int2.out Improve handling of INT_MIN / -1 and related cases. 2012-11-19 12:24:25 -05:00
int4.out Improve handling of INT_MIN / -1 and related cases. 2012-11-19 12:24:25 -05:00
int8-exp-three-digits.out Improve handling of INT_MIN / -1 and related cases. 2012-11-19 12:24:25 -05:00
int8.out Improve handling of INT_MIN / -1 and related cases. 2012-11-19 12:24:25 -05:00
interval.out Fix interval_transform so it doesn't throw away non-no-op casts. 2016-12-27 15:43:54 -05:00
join.out Fix planner failures with overlapping mergejoin clauses in an outer join. 2018-02-23 13:47:33 -05:00
json.out Make json{b}_populate_recordset() use the right tuple descriptor. 2017-11-06 10:29:42 -05:00
json_encoding.out Factor out encoding specific tests for json 2015-10-07 22:19:38 -04:00
json_encoding_1.out Factor out encoding specific tests for json 2015-10-07 22:19:38 -04:00
limit.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
lseg.out Add a bunch of new error location reports to parse-analysis error messages. 2008-09-01 20:42:46 +00:00
macaddr.out Add bitwise AND, OR, and NOT operators for macaddr data type. 2012-01-19 15:25:14 -05:00
matview.out Remove useless and rather expensive stanza in matview regression test. 2017-05-03 19:37:01 -04:00
money.out Fix precision and rounding issues in money multiplication and division. 2017-05-21 13:05:17 -04:00
name.out Add a "USING" clause to DELETE, which is equivalent to the FROM clause 2005-04-07 01:51:41 +00:00
namespace.out Fix parse location tracking for lists that can be empty. 2012-10-04 17:15:29 -04:00
numeric.out Fix behavior when converting a float infinity to numeric. 2017-09-27 17:05:54 -04:00
numeric_big.out Update numeric_big regress test for 7.0. This has apparently been 2000-03-30 07:13:20 +00:00
numerology.out Remove the special cases to prevent minus-zero results in float4 and float8 2009-02-18 19:23:26 +00:00
numerology_1.out Remove the special cases to prevent minus-zero results in float4 and float8 2009-02-18 19:23:26 +00:00
oid.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
oidjoins.out Update oidjoins regression test to match git HEAD. 2011-11-14 20:28:38 -05:00
opr_sanity.out SP-GiST support of the range adjacent operator -|- 2013-03-08 15:03:19 +02:00
path.out Add a bunch of new error location reports to parse-analysis error messages. 2008-09-01 20:42:46 +00:00
plancache.out Change plan caching to honor, not resist, changes in search_path. 2013-01-25 14:14:41 -05:00
plpgsql.out Fix typos in comments. 2017-02-06 11:34:28 +02:00
point.out Fix gist_box_same and gist_point_consistent to handle fuzziness correctly. 2013-02-08 18:03:17 -05:00
polygon.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
polymorphism.out Fix ruleutils pretty-printing to not generate trailing whitespace. 2013-11-11 13:36:42 -05:00
portals.out Fix failure to set ActiveSnapshot while rewinding a cursor. 2014-05-07 14:25:13 -04:00
portals_p2.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
prepare.out Improve psql's tabular display of wrapped-around data by inserting markers 2009-11-22 05:20:41 +00:00
prepared_xacts.out Remove unnecessary dependency on statement_timeout in prepared_xacts test. 2017-03-13 16:47:00 -04:00
prepared_xacts_1.out Remove unnecessary dependency on statement_timeout in prepared_xacts test. 2017-03-13 16:47:00 -04:00
privileges.out Add security checks to selectivity estimation functions 2017-05-08 09:19:23 -04:00
psql.out Create a psql command \gset to store query results into psql variables. 2013-02-02 17:06:38 -05:00
random.out Improve random regression tests to fail less frequently. 2004-03-15 15:46:25 +00:00
rangefuncs.out Fix mishandling of FieldSelect-on-whole-row-Var in nested lateral queries. 2014-10-20 12:23:48 -04:00
rangetypes.out Fix typcache's failure to treat ranges as container types. 2017-10-20 17:12:27 -04:00
regex.out Fix some regex issues with out-of-range characters and large char ranges. 2016-02-08 10:25:40 -05:00
reltime.out Add a bunch of new error location reports to parse-analysis error messages. 2008-09-01 20:42:46 +00:00
returning.out Reduce messages about implicit indexes and sequences to DEBUG1. 2012-07-04 20:35:29 -04:00
rowtypes.out Fix assorted fallout from IS [NOT] NULL patch. 2016-07-28 16:09:15 -04:00
rules.out Avoid using unsafe search_path settings during dump and restore. 2018-02-26 10:18:22 -05:00
sanity_check.out Fix two bugs in merging of inherited CHECK constraints. 2016-10-08 19:29:28 -04:00
select.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
select_distinct.out Alter some gratuitous uses of "ANSI" when "SQL standard" might have been 2009-07-11 21:15:32 +00:00
select_distinct_on.out Fix assertion failure when a SELECT DISTINCT ON expression is volatile. 2009-09-12 00:04:59 +00:00
select_having.out Add a bunch of new error location reports to parse-analysis error messages. 2008-09-01 20:42:46 +00:00
select_having_1.out Add a bunch of new error location reports to parse-analysis error messages. 2008-09-01 20:42:46 +00:00
select_having_2.out Add a bunch of new error location reports to parse-analysis error messages. 2008-09-01 20:42:46 +00:00
select_implicit.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
select_implicit_1.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
select_implicit_2.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
select_into.out Fix CREATE MATVIEW/CREATE TABLE AS ... WITH NO DATA to not plan the query. 2016-06-27 15:57:21 -04:00
select_views.out Improve ruleutils.c's heuristics for dealing with rangetable aliases. 2012-09-21 19:03:10 -04:00
select_views_1.out Improve ruleutils.c's heuristics for dealing with rangetable aliases. 2012-09-21 19:03:10 -04:00
sequence.out Fix longstanding crash-safety bug with newly-created-or-reset sequences. 2012-07-25 17:42:23 -04:00
sequence_1.out Fix longstanding crash-safety bug with newly-created-or-reset sequences. 2012-07-25 17:42:23 -04:00
stats.out Prevent index-only scans in stats regression test. 2011-10-08 23:45:58 -04:00
strings.out Fix regexp_matches() handling of zero-length matches. 2013-07-31 11:31:26 -04:00
subselect.out Repair failure with SubPlans in multi-row VALUES lists. 2017-11-25 14:15:48 -05:00
temp.out Reduce messages about implicit indexes and sequences to DEBUG1. 2012-07-04 20:35:29 -04:00
text.out Extend format() to handle field width and left/right alignment. 2013-03-14 22:56:56 -04:00
time.out Add a bunch of new error location reports to parse-analysis error messages. 2008-09-01 20:42:46 +00:00
timestamp.out Fix to_char(), to_date(), and to_timestamp() to handle negative/BC 2012-08-07 13:34:44 -04:00
timestamptz.out Fix timestamptz regression test to still work with latest IANA zone data. 2017-03-09 17:20:11 -05:00
timetz.out Add a bunch of new error location reports to parse-analysis error messages. 2008-09-01 20:42:46 +00:00
tinterval.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
transactions.out Fix subtransaction cleanup after an outer-subtransaction portal fails. 2015-09-04 13:36:50 -04:00
triggers.out Prevent dangling-pointer access when update trigger returns old tuple. 2018-02-27 13:27:38 -05:00
truncate.out Reduce messages about implicit indexes and sequences to DEBUG1. 2012-07-04 20:35:29 -04:00
tsdicts.out Spelling fixes 2017-03-14 13:45:45 -04:00
tsearch.out Ensure that a tsquery like '!foo' matches empty tsvectors. 2017-01-26 12:17:47 -05:00
tstypes.out Ensure that a tsquery like '!foo' matches empty tsvectors. 2017-01-26 12:17:47 -05:00
txid.out Handle duplicate XIDs in txid_snapshot. 2014-05-15 18:30:53 +03:00
type_sanity.out Fix CVE-2013-0255 properly. 2013-02-13 16:20:01 -05:00
typed_table.out Reduce messages about implicit indexes and sequences to DEBUG1. 2012-07-04 20:35:29 -04:00
union.out Back-patch "Fix EquivalenceClass processing for nested append relations". 2014-06-26 10:41:59 -07:00
updatable_views.out Make viewquery a copy in rewriteTargetView() 2015-12-21 10:34:28 -05:00
update.out Prevent multicolumn expansion of "foo.*" in an UPDATE source expression. 2016-11-20 14:26:19 -05:00
uuid.out Improve unique-constraint-violation error messages to include the exact 2009-08-01 19:59:41 +00:00
vacuum.out Improve wording of error message added in commit 714805010. 2017-09-26 15:25:57 -04:00
varchar.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
varchar_1.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
varchar_2.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
window.out Support default arguments and named-argument notation for window functions. 2013-11-06 13:33:18 -05:00
with.out Reduce indentation/parenthesization of set operations in rule/view dumps. 2014-04-30 13:26:29 -04:00
without_oid.out Combine cmin and cmax fields of HeapTupleHeaders into a single field, by 2007-02-09 03:35:35 +00:00
xml.out Fix previous commit's test, for non-UTF8 databases with non-XML builds. 2017-11-11 13:07:55 -08:00
xml_1.out Fix previous commit's test, for non-UTF8 databases with non-XML builds. 2017-11-11 13:07:55 -08:00
xml_2.out Fix previous commit's test, for non-UTF8 databases with non-XML builds. 2017-11-11 13:07:55 -08:00
xmlmap.out Fix cursor_to_xml in tableforest false mode 2017-05-04 21:31:12 -04:00
xmlmap_1.out Fix cursor_to_xml in tableforest false mode 2017-05-04 21:31:12 -04:00