If the target relation of UPDATE, DELETE, or MERGE has an alias, we printed that "bare" (without AS or forced quoting), the same as we do in FROM. However, if that alias is "set", there's an ambiguity with the SET keyword that must follow the relation specification. The parser would choose the wrong interpretation, so that the dumped query would fail to reload. The least surprising and most future-proof fix seems to be to always print AS in these contexts, as we already did in INSERT. Also, we were insufficiently careful about parenthesizing the left-hand argument of a SubLink (IN, op ANY/ALL, or row comparison), so that the printed expression might not parse back with the intended meaning depending on operator precedence. This is only a problem in "pretty-print" mode, since non-pretty mode fully parenthesizes every operator. So it isn't a hazard for pg_dump, but it still seems like something to fix. To do so, switch to using get_rule_expr_paren. Presently that will add parens in some cases where it wouldn't really be necessary, but that's better than the reverse, and it arguably is helpful for readability anyway. Author: Henson Choi <assam258@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAAAe_zDqXin5NeB5atRCbZqUdcMOeyXRqhan+tVp0F30OCURnw@mail.gmail.com Discussion: https://postgr.es/m/CAAAe_zCy+D45Qd_br484F+V34y0BVA=hp_7cb=u6HysyMkE3UQ@mail.gmail.com Backpatch-through: 14
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/18/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/18/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.