Maven:liquibase-firebird:Reason:liquibase.exception.DatabaseException:GDS异常。335544569动态SQL错误
我能够使用Maven:liquibase-firebird:Reason:liquibase.exception.DatabaseException:GDS异常。335544569动态SQL错误,maven,firebird,liquibase,Maven,Firebird,Liquibase,我能够使用mvn liquibase:update对我的Firebird数据库执行.sql查询 这项工作: CREATE TABLE xxx ( xxx ); 但是当我在.sql中执行此命令时失败了(X表示长度,我看到这对于MySQL来说太长了,但它是Firebird): 错误: [ERROR] Reason: liquibase.exception.DatabaseException: GDS Exception. 335544569. Dynamic SQL Error [E
mvn liquibase:update
对我的Firebird数据库执行.sql查询
这项工作:
CREATE TABLE xxx (
xxx
);
但是当我在.sql中执行此命令时失败了(X表示长度,我看到这对于MySQL来说太长了,但它是Firebird):
错误:
[ERROR] Reason: liquibase.exception.DatabaseException: GDS Exception. 335544569. Dynamic SQL Error
[ERROR] SQL error code = -104
[ERROR] Token unknown - line 8, column 1
[ERROR] GRANT [Failed SQL: CREATE TABLE XXXX_XXXX(
错误中的行是GRANT命令的行。当我从脚本中删除该命令(仅执行创建表)时,它会工作。我做错了什么
手动执行命令是有效的
更新:
当我在0001.sql中添加CREATETABLE语句和在0002.sql中添加Grant命令时,似乎安装工作正常
我的.sql文件如下所示(安装2.5.8后,我的firebird配置为默认配置):
GAME\u TEST\u GAME\u READ
在数据库设置过程中进行:
CREATE DATABASE 'C:/firebird/TEST_GAME.fdb' USER 'TEST_GAME' PASSWORD 'TEST_GAME';
CONNECT 'C:/firebird/TEST_GAME.fdb' USER 'TEST_GAME' PASSWORD 'TEST_GAME';
CREATE ROLE GAME_TEST_GAME_READ;
CREATE ROLE GAME_TEST_GAME_WRITE;
Liquibaseconfig:
<properties>
<liquibase.plugin.version>3.5.3</liquibase.plugin.version>
<firebird.client.version>2.1.6</firebird.client.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<configuration>
<propertyFile>liquibase/liquibase.properties</propertyFile>
<changeLogFile>liquibase/db-changelog-master.xml</changeLogFile>
</configuration>
更新2:
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<include file="liquibase/db-changelog-1.0.xml"/>
</databaseChangeLog>
和变化1:
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<includeAll path="01-testgame-scripts/" relativeToChangelogFile="true"/>
<changeSet id="tag-1.0" author="myname">
<tagDatabase tag="1.0" />
</changeSet>
</databaseChangeLog>
在
01测试游戏脚本中,我有.sql
文件。使用中描述的授权定义
问题在于您的SQL文件不符合的要求,因此它们只是按原样发送,没有任何解析或解释(即拆分单独的语句)。Firebird或Jaybird支持在一次执行中执行多个语句
如果将SQL文件更改为,它将正常工作
--liquibase formatted sql
--changeset mealesbia:1
CREATE TABLE TEST_GAMES (
TEST_GAME_ID INTEGER NOT NULL,
MONO_ID VARCHAR(255) NOT NULL,
PERIOD_FROM TIMESTAMP NOT NULL,
PERIOD_TO TIMESTAMP NOT NULL
);
GRANT SELECT ON TEST_GAMES TO GAME_TEST_GAME_READ;
用--liquibase格式化的sql
标记将导致liquibase解析sql文件并从中创建更改集(用--changeset author:id attribute1:value1 attribute2:value2[…]
标记,我在这里使用了--changeset mealesbia:1
。此解析包括拆分语句以供单独执行(除非用显式属性重写)
或者,您也可以使用在XML中显式包含SQL文件。这需要在XML中显式定义更改集并链接关联的SQL脚本(而以前的解决方案将在SQL文件中定义更改集和SQL).该错误似乎表明它正在同时执行多个语句(给定“第8行”和未知标记为GRANT
,并且Liquibase报告的“失败的SQL”以CREATE TABLE
开始,而不是GRANT
),语句必须单独执行。请显示.sql
文件的完整内容和Liquibase的配置。@markrotVeel-Hmm你说得对。当我创建两个单独的.sql文件时,它可以工作(首先创建表),下一个是授权。我已经用我的.sql文件更新了我的问题。什么是liquibase配置?我已经编辑了config@Arioch假设应用了正确的coverntions,并且没有覆盖默认值,那么它允许使用liquibase,并且应该拆分。我已经有一段时间没有使用liquibase了,但看起来OP在这里使用liquibase的方式是错误的对于table
对象类型是可选的。如链接到的页面上的语法所示:GRANT on[table]{tablename | viewname}
。如果这是原因,它会产生未知的XXXX_uxxxxx标记,而不是未知的授予。顺便说一句:您的第一个链接是语言参考更新,它只记录自InterBase 6.0以来的更改。第二个链接是Firebird语言参考,它取代了InterBase 6+语言参考更新。不,它是这里不是GRANT中的语法错误,而是错误文本-GRANT[失败的SQL:CREATE TABLE XXXX_XXXX
-清楚地提示客户端库无法将脚本解析为不同的语句。可能不应该这样做,而且它的脚本必须是每个文件一条语句,dunno。我记得我在UIB Delphi lib中遇到过类似的问题,我必须修复源代码,让脚本编写者理解一些新的FB2。1命令来拆分语句。谢谢,我现在尝试使用sqlFile。当我显式定义.sql文件时,它会起作用。你知道我是否可以只定义目录(不指定每个文件?)@mealesbia你可以,如果你使用注释标记来定义我在回答的第一部分中建议的更改集。
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<include file="liquibase/db-changelog-1.0.xml"/>
</databaseChangeLog>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<includeAll path="01-testgame-scripts/" relativeToChangelogFile="true"/>
<changeSet id="tag-1.0" author="myname">
<tagDatabase tag="1.0" />
</changeSet>
</databaseChangeLog>
GRANT
{<privileges> ON <object> | role}
TO <grantees>
[WITH {GRANT|ADMIN} OPTION]
[{GRANTED BY | AS} [USER] grantor]
GRANT SELECT ON TABLE XXXX_XXXXXX TO USER XXXXX_XXXX_XXXXX_XXXX;
--liquibase formatted sql
--changeset mealesbia:1
CREATE TABLE TEST_GAMES (
TEST_GAME_ID INTEGER NOT NULL,
MONO_ID VARCHAR(255) NOT NULL,
PERIOD_FROM TIMESTAMP NOT NULL,
PERIOD_TO TIMESTAMP NOT NULL
);
GRANT SELECT ON TEST_GAMES TO GAME_TEST_GAME_READ;