some ri_triggers.c cleanup - Mailing list pgsql-hackers

From Peter Eisentraut
Subject some ri_triggers.c cleanup
Date
Msg-id 0ccdd3e1-10b0-dd05-d8a7-183507c11eb1@2ndquadrant.com
Whole thread Raw
Responses Re: some ri_triggers.c cleanup  (Corey Huinker <corey.huinker@gmail.com>)
List pgsql-hackers
ri_triggers.c is endlessly long and repetitive.  I want to clean it up a
bit (more).

I looked into all these switch cases for the unimplemented MATCH PARTIAL
option.  I toyed around with how a MATCH PARTIAL implementation would
actually look like, and it likely wouldn't use the existing code
structure anyway, so let's just simplify this for now.

First, have ri_FetchConstraintInfo() check that riinfo->confmatchtype
is valid.  Then we don't have to repeat that everywhere.

In the various referential action functions, we don't need to pay
attention to the match type at all right now, so remove all that code.
A future MATCH PARTIAL implementation would probably have some
conditions added to the present code, but it won't need an entirely
separate switch branch in each case.

In RI_FKey_fk_upd_check_required(), reorganize the code to make it
much simpler.

Separately, the comment style is also very generous and wasteful with
vertical space.  That can be shrunk a bit.

Attached are some patches.

Final score:

branch          wc -l
REL9_6_STABLE   3671
REL_10_STABLE   3668
REL_11_STABLE   3179
master          3034
patch           2695

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: WIP: Avoid creation of the free space map for small tables
Next
From: Robert Haas
Date:
Subject: Re: [patch] Add schema total size to psql \dn+