运行 Liquibase 时出现空值/越界错误

Null / Out of Bounds Error when running Liquibase

我正在使用数据库迁移 Grails 插件。但是在使用 liquibase 格式的 sql 迁移时,运行ning dbm-update 运行s 导致我的一些 sql 出现致命错误。我收到此错误:

liquibase : 'Change Set GraphFunctions.sql::graph_functions_initialize_1::<user> failed.  Error: null'
java.lang.ArrayIndexOutOfBoundsException

当我 运行 代码时会发生这种情况:

--changeset <username>: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;

如果我不使用格式化-sql,那么运行没问题。但是,如果我这样做,那么我将无法通过 Liquibase 界面管理回滚。有没有人知道我可以改变什么来完成这项工作?

事实证明,sql 包含函数声明的变更集失败了,因为它们在 create 语句的中间包含分号。要修复这些错误,我只需要将格式化的-sql 更改为不拆分语句:

--changeset <username>:graph_functions_initialize_1 splitStatements:false