Stricter order for actor.org_unit_parent_protect() collab/dbwells/lp826844_org_unit_parent_protect_2_1
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:49:27 +0000 (14:49 -0400)
commit2d0125f834f232440402d4e31ee04feaffe4f7d6
tree2f22e92d98e2d77aced56f60546c512dbefa5a72
parent3812530f5e0fb74f18023be9057efd89e9d34798
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]