postgresql/src/backend
Tom Lane 906bfcad7b Improve handling of "UPDATE ... SET (column_list) = row_constructor".
Previously, the right-hand side of a multiple-column assignment, if it
wasn't a sub-SELECT, had to be a simple parenthesized expression list,
because gram.y was responsible for "bursting" the construct into
independent column assignments.  This had the minor defect that you
couldn't write ROW (though you should be able to, since the standard says
this is a row constructor), and the rather larger defect that unlike other
uses of row constructors, we would not expand a "foo.*" item into multiple
columns.

Fix that by changing the RHS to be just "a_expr" in the grammar, leaving
it to transformMultiAssignRef to separate the elements of a RowExpr;
which it will do only after performing standard transformation of the
RowExpr, so that "foo.*" behaves as expected.

The key reason we didn't do that before was the hard-wired handling of
DEFAULT tokens (SetToDefault nodes).  This patch deals with that issue by
allowing DEFAULT in any a_expr and having parse analysis throw an error
if SetToDefault is found in an unexpected place.  That's an improvement
anyway since the error can be more specific than just "syntax error".

The SQL standard suggests that the RHS could be any a_expr yielding a
suitable row value.  This patch doesn't really move the goal posts in that
respect --- you're still limited to RowExpr or a sub-SELECT --- but it does
fix the grammar restriction, so it provides some tangible progress towards
a full implementation.  And the limitation is now documented by an explicit
error message rather than an unhelpful "syntax error".

Discussion: <8542.1479742008@sss.pgh.pa.us>
2016-11-22 15:20:10 -05:00
..
access Support condition variables. 2016-11-22 14:27:11 -05:00
bootstrap Support condition variables. 2016-11-22 14:27:11 -05:00
catalog Add pg_sequences view 2016-11-18 14:59:03 -05:00
commands Add pg_sequences view 2016-11-18 14:59:03 -05:00
executor Simplify code by getting rid of SPI_push, SPI_pop, SPI_restore_connection. 2016-11-08 17:39:57 -05:00
foreign Remove GetUserMappingId() and GetUserMappingById(). 2016-07-22 11:32:23 -04:00
lib Clarify the new Red-Black post-order traversal code a bit. 2016-09-04 15:02:06 +03:00
libpq Consistently mention 'SELECT pg_reload_conf()' in config files 2016-10-25 11:26:15 -04:00
main
nodes Implement syntax for transition tables in AFTER triggers. 2016-11-04 10:49:50 -05:00
optimizer Fix optimization for skipping searches for parallel-query hazards. 2016-11-21 13:19:23 -05:00
parser Improve handling of "UPDATE ... SET (column_list) = row_constructor". 2016-11-22 15:20:10 -05:00
po Translation updates 2016-08-08 11:08:00 -04:00
port Try to find out the actual hugepage size when making a MAP_HUGETLB request. 2016-10-13 15:06:46 -04:00
postmaster Support condition variables. 2016-11-22 14:27:11 -05:00
regex Make locale-dependent regex character classes work for large char codes. 2016-09-05 17:06:29 -04:00
replication Support condition variables. 2016-11-22 14:27:11 -05:00
rewrite Cleanup of rewriter and planner handling of Query.hasRowSecurity flag. 2016-11-10 16:16:33 -05:00
snowball
storage Support condition variables. 2016-11-22 14:27:11 -05:00
tcop Remove or reduce verbosity of some debug messages. 2016-11-17 17:05:16 -05:00
tsearch Add macros to make AllocSetContextCreate() calls simpler and safer. 2016-08-27 17:50:38 -04:00
utils Fix PGLC_localeconv() to handle errors better. 2016-11-21 18:21:55 -05:00
.gitignore
common.mk
Makefile Refer to OS X as "macOS", except for the port name which is still "darwin". 2016-09-25 15:40:57 -04:00
nls.mk