Stricter order for actor.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:33:22 +0000 (14:33 -0400)
commit7f92d9924f54b2185df28b03f71a15ff73465b16
treec63ba7e8154bbed884f3738c97dbcccbb8363dfe
parent94b1a4cef3d33d935425a41bce9f486cc86fe3a9
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]