title: Null / Out of Bounds Error when running Liquibase
body: <p>I am using the database-migration Grails plugin. But running dbm-update runs into fatal errors for some of my sql when using the liquibase formatted sql migrations. I get this error:</p>
  
  <pre><code>liquibase : 'Change Set GraphFunctions.sql::graph_functions_initialize_1::&lt;user&gt; failed.  Error: null'
  java.lang.ArrayIndexOutOfBoundsException
  </code></pre>
  
  <p>This happens when I run the code:</p>
  
  <pre><code>--changeset &lt;username&gt;:graph_functions_initialize_1
  CREATE OR REPLACE FUNCTION build_trcd(
      IN new_parent_id bigint,
      IN new_child_id bigint)
      RETURNS TABLE(ancestor_id bigint, descendant_id bigint, paths bigint, cost bigint) AS '
      SELECT
          t1.ancestor_id AS ancestor_id,
          t2.descendant_id AS descendant_id,
          SUM(t1.paths*t2.paths)::bigint AS paths,
          MIN(t1."cost"+t2."cost")+1::bigint AS "cost"
      FROM db_set_membership_closure t1, db_set_membership_closure t2
      WHERE t1.descendant_id=new_parent_id AND t2.ancestor_id=NEW_child_id
      GROUP BY t1.ancestor_id, t2.descendant_id
      UNION
      SELECT
          NEW_parent_id AS ancestor_id,
          descendant_id AS descendant_id,
          paths AS paths ,
          (c."cost" + 1)::bigint AS "cost"
      FROM db_set_membership_closure c
      WHERE ancestor_id = NEW_child_id
      UNION
      SELECT
          ancestor_id AS ancestor_id,
          NEW_child_id AS descendant_id,
          paths AS paths,
          c."cost" + 1::bigint AS "cost"
      FROM db_set_membership_closure c
      WHERE descendant_id = NEW_parent_id
      UNION VALUES (NEW_parent_id, NEW_child_id,1::bigint,1::bigint);
  ' LANGUAGE sql;
  --rollback drop function build_trcd;
  </code></pre>
  
  <p>If I don't use formatted-sql then it runs fine. However, if I do that, then I cannot manage a rollback through the Liquibase interface. Does anyone have an insight into what I might change to make this work?</p>