Unexpected error/Unknown Reason if any mysql view is broken

Description

Problem described in this ticked covers problem discussed on stackoverflow and mentioned in pull request comment.

To replicate this problem execute following SQL command on any DB you apply changesets to:

CREATE TABLE mytable (c1 int, c2 int); CREATE VIEW myview AS SELECT c1, c2 FROM mytable; -- this will break myview ALTER TABLE mytable DROP COLUMN c2;

Now execute liquibase update command on that database, it will fail before applying the changesets.

If MySql database contains broken view (at least one) most of Liquibase commands will fail because of exception. Location and text of the exception is not usable by user becasue the real mysql exception is ignored in code.

The real exception, not visible to user is:

java.sql.SQLException: View 'informaglobal.myview' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

Problematic code is in JdbcDatabaseSnapshot.java::bulkFetchQuery().
This is my first time I see Liquibase code so I am not proposing fix, but on first look:

  • the exception should be printed to user at least with warning severity

  • shouldReturnEmptyColumns() maybe works in fastFetchQuery() because that is handling single table, but doesn't work in bulkFetchQuery() because the exception will cause problem to metadata collected for all tables/views from database

  • shouldReturnEmptyColumns() depends on english message text which is not nice

Environment

mysql

Activity

Show:

Nathan Voxland March 14, 2016 at 5:07 PM

I am not able to reproduce this anymore with the 3.5 codebase. I think it was fixed by other changes

Martin Minka June 23, 2015 at 8:54 PM
Edited

Nathan, would it please be possible to write the mysql exception to output with severity warning in next minor release ?
The problem is in DB and it is easy to fix if user knows what is the reason for "Unknown Reason" message.
At this moment it is required to debug the Java source code to find out the problematic view.
The code is here https://github.com/liquibase/liquibase/blob/liquibase-parent-3.3.5/liquibase-core/src/main/java/liquibase/snapshot/JdbcDatabaseSnapshot.java#L290.

Thank you.

Cannot Reproduce

Details

Reporter

Affects versions

Priority

Created June 23, 2015 at 2:07 PM
Updated March 14, 2016 at 5:07 PM
Resolved March 14, 2016 at 5:07 PM

Flag notifications