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:00:56 +0000 (19:00 -0400)
commit41f00b25bb95ac45c826304fb8e17844ad0e6fa2
tree1fb83e584507006ca3a8c2b35bcb9f1f80b84bb4
parentf087dc931de79d3d5bc86866c4de64d557a7db51
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]