Reputation: 585
We have a changeset to create a function in Postgres.
We used update-sql to generate a .sql file.
Then tried to use execute-sql to run that sql file and we get the error message
"Unexpected error running Liquibase: Unterminated dollar quote started at position..."
We have splitStatements:false set.
Running liquibase update works. The generated sql works fine in pgAdmin.
Is this normal behavior or an error?
Postgres 16.3, Liquibase latest version 4.31.0, Windows op sys
Here is the changeset file:
--liquibase formatted sql
--changeset homer:1 labels:WI-12345 runOnChange:true splitStatements:false stripComments:false
--comment: Create function
CREATE OR REPLACE FUNCTION test_func1()
RETURNS TABLE(user_id INTEGER, firstname TEXT, lastname TEXT)
AS
$$
BEGIN
RETURN QUERY
SELECT u.user_id, u.firstname, u.lastname
FROM users u;
END;
$$
LANGUAGE plpgsql;
Liquibase commands:
liquibase update-sql --output-file ./release/test1.sql
liquibase execute-sql --sql-file=./release/test1.sql
Exact error message:
ERROR: Exception Details
ERROR: Exception Primary Class: PSQLException
ERROR: Exception Primary Reason: Unterminated dollar quote started at position 107 in SQL CREATE OR REPLACE FUNCTION test_func1()
Pasting the generated .sql file contents into pgAdmin executes successfully. Running liquibase update runs successfully. Only execute-sql after update-sql throws the error.
Side note: Perhaps another bug is position 107 in both the changeset file and output .sql file doesn't correlate with what the error message states.
Upvotes: -2
Views: 34