pgsql: Refactor to avoid code duplication in transformPLAssignStmt. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Refactor to avoid code duplication in transformPLAssignStmt.
Date
Msg-id E1v2cIw-000NsY-2u@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Refactor to avoid code duplication in transformPLAssignStmt.

transformPLAssignStmt contained many lines cribbed directly from
transformSelectStmt.  I had supposed that we could manage to keep
the two copies in sync, but the bug just fixed in 7504d2be9 shows
that that hope was foolish.  Let's refactor so there's just one copy.

The main stumbling block to doing this is that transformPLAssignStmt
has a chunk of custom code that has to run after transformTargetList
but before we potentially modify the tlist further during analysis
of ORDER BY and GROUP BY.  Rather than make transformSelectStmt fully
aware of PLAssignStmt processing, I put that code into a callback
function.  It still feels a little bit ugly, but it's not too awful,
and surely it's better than a hundred lines of duplicated code.
The steps involved in processing a PLAssignStmt remain exactly
the same as before, just in different places.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/31027.1758919078@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b0fb2c6aa5a485e28210e13ae5536c1231b1261f

Modified Files
--------------
src/backend/parser/analyze.c     | 207 ++++++++++++++++-----------------------
src/tools/pgindent/typedefs.list |   1 +
2 files changed, 84 insertions(+), 124 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix missed copying of groupDistinct in transformPLAssignStmt.
Next
From: Michael Paquier
Date:
Subject: pgsql: Add support for tracking of entry count in pgstats