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 Scott <dan@coffeecode.net>
Thu, 18 Aug 2011 23:31:48 +0000 (19:31 -0400)
commitb01a0ee3a8567dfcb8cd3392e9c1d14e8dc370ef
treece476996e8cd489f2561e6ca7fbe5902713aa235
parent2ee54e937ef54575ee9b74709ba609f4bde5f702
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>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/005.schema.actors.sql
Open-ILS/src/sql/Pg/upgrade/0605.schema.lp826844_org_unit_parent_protect_fix.sql [new file with mode: 0644]