]> granicus.if.org Git - postgresql/commit
Merge near-duplicate code in RI triggers.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 18 Nov 2017 21:24:05 +0000 (16:24 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 18 Nov 2017 21:24:05 +0000 (16:24 -0500)
commit4797f9b519995ceca5d6b8550b5caa2ff6d19347
tree537ff75bea268ee090da50f620863527cc78fd68
parentd0aa965c0a0ac2ff7906ae1b1dad50a7952efa56
Merge near-duplicate code in RI triggers.

Merge ri_restrict_del and ri_restrict_upd into one function ri_restrict.
Create a function ri_setnull that is the common implementation of
RI_FKey_setnull_del and RI_FKey_setnull_upd.  Likewise create a function
ri_setdefault that is the common implementation of RI_FKey_setdefault_del
and RI_FKey_setdefault_upd.  All of these pairs of functions were identical
except for needing to check for no-actual-key-change in the UPDATE cases;
the one extra if-test is a small price to pay for saving so much code.

Aside from removing about 400 lines of essentially duplicate code, this
allows us to recognize that we were uselessly caching two identical plans
whenever there were pairs of triggers using these duplicated functions
(which is likely very common).

Ildar Musin, reviewed by Ildus Kurbangaliev

Discussion: https://postgr.es/m/ca7064a7-6adc-6f22-ca47-8615ba9425a5@postgrespro.ru
src/backend/utils/adt/ri_triggers.c