Skip to content

BUG: Quoting not always identified properly, causes issues in end delimiter identification #5674

Closed
@jasonlyle88

Description

Search first

  • I searched and no similar issues were found

Description

When liquibase is looking for end delimiters, it is not supposed to consider end delimiter characters that are character literals (aka quoted strings). However, I have discovered certain use cases where this is not the case. This functionality was working (at least for my test cases) in 4.25.0 and broke in 4.25.1.

In looking at the version change log for 4.25.1, I noticed PR #5108 (titled Improve SQL parsing of character literals (quoted strings)) which directly relates to what is going on here.

I am unfamiliar with the .jj extension of the file changed in this PR or the grammar syntax being used here, but I am assuming this is the culprit.

Steps To Reproduce

Run an update command with liquibase version 4.25.1 or 4.26.0 (4.26.0 is the latest release at time of writing) and run the following changelogs on an oracle database:

changelog.xml:

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ora="http://www.oracle.com/xml/ns/dbchangelog-ext"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd"
>
    <include relativeToChangelogFile="true" file="test1.sql"/>
    <include relativeToChangelogFile="true" file="test2.sql"/>
</databaseChangeLog>

test1.sql:

--liquibase formatted sql

--changeset jlyle:test1 stripComments:false runOnChange:true runAlways:true endDelimiter:; rollbackEndDelimiter:;
create or replace view jmltest1 as
select '[;]' jml
from sys.dual;
--rollback not required

test2.sql:

--liquibase formatted sql

--changeset jlyle:test2 stripComments:false runOnChange:true runAlways:true endDelimiter:;
create or replace view jmltest as
select '~'';[\s]*~' jml
from sys.dual;
--rollback not required

The test1 changeset passes, proving this is not all quoted strings with end delimiters in them.

The test2 changeset fails, even though the end delimiter character (; in this case) is inside a quoted string and should not be considered an end delimiter.

Expected/Desired Behavior

Character literal end delimiters should not be considered for end delimiters

Liquibase Version

4.25.1, 4.26.0

Database Vendor & Version

Oracle

Liquibase Integration

No response

Liquibase Extensions

No response

OS and/or Infrastructure Type/Provider

No response

Additional Context

In the example, I used the string q'~'';[\s]*~' to cause the issue, but the following list all cause the issue. I have not fully determined what exactly about these strings cause the issue

End delimiter: ;

q'~'';[\s]*~'
q'~';[\s]*~'
q'~;[\s]*~'
q'~;[\s]~'
q'~;\~'
q'!;\!'
q'{;\}'
q'{
;
\}'
q'{
;\}'
q'(;\)'
q'<;\>'
  • WORKS: q'[;\]'

Are you willing to submit a PR?

  • I'm willing to submit a PR (Thank you!)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions