postgresql/src/pl
Tom Lane 55caaaeba8 Improve handling of array elements as getdiag_targets and cursor_variables.
There's no good reason why plpgsql's GET DIAGNOSTICS statement can't
support an array element as target variable, since the execution code
already uses the generic exec_assign_value() function to assign to it.
Hence, refactor the grammar to allow that, by making getdiag_target
depend on the assign_var production.

Ideally we'd also let a cursor_variable expand to an element of a
refcursor[] array, but that's substantially harder since those statements
also have to handle bound-cursor-variable cases.  For now, just make sure
the reported error is sensible, ie "cursor variable must be a simple
variable" not "variable must be of type cursor or refcursor".  The latter
was quite confusing from the user's viewpoint, since what he wrote
satisfies the claimed restriction.

Per bug #14463 from Zhou Digoal.  Given the lack of previous complaints,
I see no need for a back-patch.

Discussion: https://postgr.es/m/20161213152548.14897.81245@wrigleys.postgresql.org
2016-12-13 16:33:03 -05:00
..
plperl Simplify code by getting rid of SPI_push, SPI_pop, SPI_restore_connection. 2016-11-08 17:39:57 -05:00
plpgsql Improve handling of array elements as getdiag_targets and cursor_variables. 2016-12-13 16:33:03 -05:00
plpython Be more careful about Python refcounts while creating exception objects. 2016-12-09 15:27:23 -05:00
tcl Check that result tupdesc has exactly 1 column in return_next scalar case. 2016-11-15 16:48:19 -05:00
Makefile Make distprep and *clean build targets recurse into all subdirectories. 2011-07-03 13:55:12 -04:00