Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JdbcExecutor trims oracle wrapped body packages making them invalid #3163

Open
ISpectruM opened this issue Aug 10, 2022 · 1 comment
Open

Comments

@ISpectruM
Copy link

ISpectruM commented Aug 10, 2022

Environment

Liquibase Version: 4.12.0

Liquibase Integration & Version: spring boot

Liquibase Extension(s) & Version: NA

Database Vendor & Version: com.oracle.database.jdbc:ojdbc11

Operating System Type & Version: Windows 10

Infrastructure Type/Provider: Local

Description

My case is that I need to execute a Changeset which is SQL file containing wrapped body of an oracle DB package. There are cases, where on jdbc execution this wrapped body is trimmed and that way its checksum is no longer valid, which on DB deploy results in "PLS-00753: Malformed or corrupted wrapped unit." error.

Steps To Reproduce


Actual Behavior

It happens, due to when Oracle initially wraps these packages, it applies one additional row to the wrapped body and then calculates and saves the checksum in wrapped package. Then when the Liquibase JdbcExecutor executes the Changeset it trims this additional row, and that way making it invalid and unable for deploy. The code that is trimming it is at:

private class ExecuteStatementCallback implements StatementCallback
....
@Override
        public Object doInStatement(Statement stmt) throws SQLException, DatabaseException {
            Logger log = Scope.getCurrentScope().getLog(getClass());

            for (String statement : applyVisitors(sql, sqlVisitors)) {
                Scope.getCurrentScope().
                  if (database instanceof OracleDatabase) {
                    while (statement.matches("(?s).*[\\s\\r\\n]*[^*]/[\\s\\r\\n]*$")) { //all trailing /'s
                        statement = statement.replaceFirst("[\\s\\r\\n]*[^*]/[\\s\\r\\n]*$", "");
                    }
                }
...

Expected/Desired Behavior

I want to be able to switch that trimming on/off and successfully deploy SQL changesets holding wrapped Oracle packages. Is there a way to change this functionality? I don't need to introduce entire new Executor implementation, since this one operates fine except the subject issue. Is it reasonable to introduce a change in the JdbcExecutor with ability to configure toggle the trimming functionality. What I`m not sure is:

  1. Where is the proper place for such configuration? "liquibase.properties" file, as changeLog property tag or different place?
  2. how can I access this config property in code?
    For example a change in JdbcExecutor like this:
               if(isTrimmingEnabled){
                    if (database instanceof OracleDatabase) {
                        while (statement.matches(
                            "(?s).*[\\s\\r\\n]*[^*]/[\\s\\r\\n]*$")) { //all trailing /'s
                            statement = statement.replaceFirst("[\\s\\r\\n]*[^*]/[\\s\\r\\n]*$",
                                "");
                        }
                    }
                }

Thank you!

@kataggart
Copy link
Contributor

@ISpectruM there was some work done recently #3118 Oracle PL/SQL terminator that was released in v4.15.0. Not sure if this will resolve/help, but you might want to try the newer version.

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

No branches or pull requests

2 participants