diff options
| author | Tom Lane | 2025-02-11 17:34:59 +0000 |
|---|---|---|
| committer | Tom Lane | 2025-02-11 17:34:59 +0000 |
| commit | 6c7251db0ce12a83dd03c840e7d0ff7516b27229 (patch) | |
| tree | e2b16b70d239b580f8ffb66ad50080ac0134f918 /src/tools/pgindent | |
| parent | 36fb9ef269a092a1203c9482bdf9b3e963728fd9 (diff) | |
Implement new optimization rule for updates of expanded variables.
If a read/write expanded variable is declared locally to the
assignment statement that is updating it, and it is referenced
exactly once in the assignment RHS, then we can optimize the
operation as a direct update of the expanded value, whether
or not the function(s) operating on it can be trusted not to
modify the value before throwing an error. This works because
if an error does get thrown, we no longer care what value the
variable has.
In cases where that doesn't work, fall back to the previous
rule that checks for safety of the top-level function.
In any case, postpone determination of whether these optimizations
are feasible until we are executing a Param referencing the target
variable and that variable holds a R/W expanded object. While the
previous incarnation of exec_check_rw_parameter was pretty cheap,
this is a bit less so, and our plan to invoke support functions
will make it even less so. So avoiding the check for variables
where it couldn't be useful should be a win.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Pavel Borisov <pashkin.elfe@gmail.com>
Discussion: https://postgr.es/m/CACxu=vJaKFNsYxooSnW1wEgsAO5u_v1XYBacfVJ14wgJV_PYeg@mail.gmail.com
Diffstat (limited to 'src/tools/pgindent')
| -rw-r--r-- | src/tools/pgindent/typedefs.list | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index 656ecd919de..110aa8ab5a2 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -1873,6 +1873,7 @@ PLpgSQL_rec PLpgSQL_recfield PLpgSQL_resolve_option PLpgSQL_row +PLpgSQL_rwopt PLpgSQL_stmt PLpgSQL_stmt_assert PLpgSQL_stmt_assign @@ -3414,6 +3415,7 @@ core_yy_extra_type core_yyscan_t corrupt_items cost_qual_eval_context +count_param_references_context cp_hash_func create_upper_paths_hook_type createdb_failure_params |
