question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't know how to query for sequences on MariaDB

See original GitHub issue

Environment

Liquibase Version: 4.0.0

Liquibase Integration & Version: CLI

Liquibase Extension(s) & Version: NO

Database Vendor & Version: docker official mariadb (image-id: 22851c7fe916) mariadb --version: mariadb Ver 15.1 Distrib 10.5.4-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2 jdbc driver: org.mariadb.jdbc:mariadb-java-client:2.6.1

Operating System Type & Version: Ubuntu 20.04 LTS (Focal Fossa)

Description

Liquibase 4.0.0 is able to write sequences into the mariadb instance, but it can’t query the sequences when it is attempting to loadUpdateData into the table.

The issue is related to the class liquibase.snapshot.jvmSequenceSnapshotGenerator, in the method getSelectSequenceSql

MariaDB query isn’t implemented there. It should add something like this:


} else if (database instanceof MariaDBDatabase) {
  return "SELECT TABLE_NAME AS SEQUENCE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='SEQUENCE' AND TABLE_SCHEMA='" + schema.getName() + "'"
} else {
  throw new UnexpectedLiquibaseException("Don't know how to query for sequences on " + database);
}

Steps To Reproduce

test_table.csv

id_test, test_text
1, text 1
2, text 2
3, text 3

changelog-test.yml

databaseChangeLog:
  - changeSet:
      id: test-seq
      author: test
      changes:
        - createSequence:
            sequenceName: seq_test
  - changeSet:
      id: test-table
      author: test
      changes:
        - createTable:
            tableName: test_table
            columns:
              - column:
                  name: id_test
                  type: bigint
                  constraints:
                    primaryKeyName: pk_test_table
                    primaryKey: true
                    nullable: false
             - column:
                  name: test_text
                  type: nvarchar(100)
   - changeSet:
      id: test-seq-default
      author: test
      changes:
        - addDefaultValue:
            tableName: test_table
            columnName: id_test
            columnDataType: bigint
            defaultValueSequenceNext: seq_test
    - changeSet:
      id: test-dml
      author: test
      changes:
        - loadUpdateData:
            tableName: test_table
            primaryKey: id_test
            file: test_table.csv
            encoding: UTF-8
            relativeToChangelogFile: true
$ docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=your_password mariadb
$ java -jar liquibase.jar --changeLogFile changelog-test.yml --url "jdbc:mariadb://localhost/mysql" --username root --password "your_password" update

Actual Behavior

Error message:

Unexpected error running Liquibase: Migration failed for change set changelog-test.yml::test-dml::test:
     Reason: liquibase.exception.UnexpectedLiquibaseException: Don't know how to query for sequences on root @ jdbc:mariadb://localhost/mysql (Default Schema: mysql)
For more information, please use the --logLevel flag

Expected/Desired Behavior

Conclude the loadUpdateData without issues.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
giorgioinfcommented, Jul 28, 2020

Isn’t this fixed by #1024?

It’s related. But the pushed code isn’t part of the version 4.0.0. I think we should try to bring these changes to v4 and test them.

0reactions
FBurguercommented, Aug 22, 2022

Looks like it got fixed for liquibase 4.15. Try upgrading your liquibase version to latest, if this doesnt fix your issue, please try to re-open the issue and we will look into it again. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sequences - Knowledge Base - MariaDB
CREATE SEQUENCE was introduced in MariaDB 10.3. A sequence is an object that generates a sequence of numeric values, as specified by the...
Read more >
Sequence Overview - MariaDB Knowledge Base
Introduction. A sequence is an object that generates a sequence of numeric values, as specified by the CREATE SEQUENCE statement.
Read more >
CREATE SEQUENCE - MariaDB Knowledge Base
I don't know how replicate the bug, it seems random, I'm Mariadb 10.4 and I create a sequence like CREATE SEQUENCE $nameSequence START...
Read more >
SHOW CREATE SEQUENCE - MariaDB Knowledge Base
Description. Shows the CREATE SEQUENCE statement that created the given sequence. The statement requires the SELECT privilege for the table.
Read more >
Sequences Support in MariaDB Server 10.3
The idea of sequences is to have a way of requesting unique values on demand. The typical use case for sequences is to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found