postgresql/src/backend
Tom Lane 285b850d51 Fix some oversights in expression dependency recording.
find_expr_references() neglected to record a dependency on the result type
of a FieldSelect node, allowing a DROP TYPE to break a view or rule that
contains such an expression.  I think we'd omitted this case intentionally,
reasoning that there would always be a related dependency ensuring that the
DROP would cascade to the view.  But at least with nested field selection
expressions, that's not true, as shown in bug #14867 from Mansur Galiev.
Add the dependency, and for good measure a dependency on the node's exposed
collation.

Likewise add a dependency on the result type of a FieldStore.  I think here
the reasoning was that it'd only appear within an assignment to a field,
and the dependency on the field's column would be enough ... but having
seen this example, I think that's wrong for nested-composites cases.

Looking at nearby code, I notice we're not recording a dependency on the
exposed collation of CoerceViaIO, which seems inconsistent with our choices
for related node types.  Maybe that's OK but I'm feeling suspicious of this
code today, so let's add that; it certainly can't hurt.

This patch does not do anything to protect already-existing views, only
views created after it's installed.  But seeing that the issue has been
there a very long time and nobody noticed till now, that's probably good
enough.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/20171023150118.1477.19174@wrigleys.postgresql.org
2017-10-23 13:57:45 -04:00
..
access Fix access-off-end-of-array in clog.c. 2017-10-06 12:20:13 -04:00
bootstrap Add macros to make AllocSetContextCreate() calls simpler and safer. 2016-08-27 17:50:38 -04:00
catalog Fix some oversights in expression dependency recording. 2017-10-23 13:57:45 -04:00
commands Fix low-probability loss of NOTIFY messages due to XID wraparound. 2017-10-11 14:28:33 -04:00
executor Fix AggGetAggref() so it won't lie to aggregate final functions. 2017-10-12 15:20:04 -04:00
foreign Remove GetUserMappingId() and GetUserMappingById(). 2016-07-22 11:32:23 -04:00
lib Revert "Permit dump/reload of not-too-large >1GB tuples" 2016-12-06 12:46:03 -03:00
libpq Fix misparsing of non-newline-terminated pg_hba.conf files. 2017-10-17 12:15:08 -04:00
main Repair a bit of pgindent damage. 2016-06-09 18:09:17 -04:00
nodes Fix parallel query so it doesn't spoil row estimates above Gather. 2017-03-31 21:10:30 -04:00
optimizer Allow rel_is_distinct_for() to look through RelabelType below OpExpr. 2017-09-17 15:28:51 -04:00
parser Add missing ALTER USER variants 2017-08-03 20:49:07 -04:00
po Translation updates 2017-08-28 10:17:39 -04:00
port Provide a way to control SysV shmem attach address in EXEC_BACKEND builds. 2017-04-15 17:27:51 -04:00
postmaster On Windows, retry process creation if we fail to reserve shared memory. 2017-07-10 11:00:09 -04:00
regex Fix regexport.c to behave sanely with lookaround constraints. 2017-04-13 17:18:35 -04:00
replication Fix more user-visible elog() calls. 2017-10-05 08:03:04 -04:00
rewrite Fix multiple assignments to a column of a domain type. 2017-07-11 16:48:59 -04:00
snowball Update copyright for 2016 2016-01-02 13:33:40 -05:00
storage Increase distance between flush requests during bulk file copies. 2017-10-08 15:25:26 -04:00
tcop Prevent idle in transaction session timeout from sometimes being ignored. 2017-10-11 14:02:41 -07:00
tsearch Reduce memory usage of tsvector type analyze function. 2017-07-12 22:06:10 +03:00
utils Fix typcache's failure to treat ranges as container types. 2017-10-20 17:12:27 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
Makefile Provide and use a makefile target to build all generated headers. 2016-07-01 15:09:02 -04:00
nls.mk Translation updates 2017-02-06 12:42:47 -05:00