Applies to:
- Liquibase Pro
- Liquibase Open Source (Community)
Conditions:
- Any version of Liquibase Pro or Open Source
- PostgreSQL
Issue Summary:
Postgres can use dollar sign ($) quoting to create functions and procedures.
When a script containing the dollar sign is deployed, it causes this error message. This is due to how the script is getting parsed by Liquibase.
Error Message:
Reason: liquibase.exception.DatabaseException: Unterminated dollar quote started at position
Root Cause:
There are three potential root causes:
- The script is running in raw SQL.
- The changeset has the parameter
splitStatements:true
set. - The SQL syntax for the driver/database version is incorrect.
Resolution:
Depending on the root cause, different resolutions might be applied.
The script running in raw SQL
If a script is run as raw SQL, the default values Liquibase uses for deployment will be used. By looking at the log, it is possible to determine if a changeset is running as raw SQL.
For example:
.sql::raw::includeAll
Ensure that the changeset is structured for Liquibase formatted SQL.
Changeset has splitStatements:true
By default, splitStatements is set to true for all statements. With this set to true, Liquibase will split the statement up by the default end delimiter and semicolon and deploy each statement. In the case of a function or procedure that contains the dollar sign, Liquibase will attempt to deploy a dollar sign as a statement.
The changeset needs to have splitStatements:false to allow the script to be deployed as a single statement.
The SQL syntax for the driver/database version is incorrect
If the SQL syntax for the dollar sign is incorrect, this error can occur.
Ensure that the SQL can be deployed outside of Liquibase successfully without encountering this error message.
Comments
0 comments
Article is closed for comments.