Stricter order for actor.org_unit_parent_protect() collab/dbwells/lp826844_org_unit_parent_protect
authorDan Wells <dbw2@calvin.edu>
Tue, 16 Aug 2011 21:22:47 +0000 (17:22 -0400)
committerDan Wells <dbw2@calvin.edu>
Wed, 17 Aug 2011 18:23:06 +0000 (14:23 -0400)
commit99b2bbe311887ee36d3459e013b952e30c06dd56
treef6f8f056e2b520064a0274216e7d4f5e630abeb4
parentf8b9a0809f7e5ecce2228e13d7f43dd8e5619761
Stricter order for actor.org_unit_parent_protect()

actor.org_unit_parent_protect() may not work due to the fact
that 'IF' conditions in PL/pgSQL are not necessarily processed
in the order written. This line:

"IF TG_OP = 'INSERT' OR NEW.parent_ou
IS DISTINCT FROM OLD.parent_ou THEN"

may fail because the 'IS DISTINCT FROM' happens before the
'INSERT' check, and and that fails because there is no 'OLD'
variable for INSERTs.

This commit may not be the optimal style for this circumstance
in this language, but it works.  It also appears to change more
than it really does due to a loss of one level of indentation in
the structure.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/sql/Pg/005.schema.actors.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp826844_org_unit_parent_protect_fix.sql [new file with mode: 0644]