Permalink
Browse files

Implement MariaDB's sequence support

  • Loading branch information...
schrieveslaach committed Jan 28, 2019
1 parent aae5ecb commit 530e4fb264f81a2de80562abe9e809d5a938b23e
@@ -13,6 +13,10 @@
public class MariaDBDatabase extends MySQLDatabase {
private static final String PRODUCT_NAME = "MariaDB";

public MariaDBDatabase() {
super.sequenceNextValueFunction = "NEXT VALUE FOR %s";
}

@Override
public String getShortName() {
return "mariadb";
@@ -80,4 +84,14 @@ protected String getMinimumVersionForFractionalDigitsForTimestamp() {
// https://mariadb.com/kb/en/library/microseconds-in-mariadb/
return "5.3.0";
}

@Override
public boolean supportsSequences() {
try {
return getDatabaseMajorVersion() >= 10 && getDatabaseMinorVersion() >= 3;
} catch (DatabaseException e) {
LogService.getLog(getClass()).debug(LogType.LOG, "Cannot retrieve database version", e);
return false;
}
}
}
@@ -51,7 +51,7 @@ public ValidationErrors validate(CreateSequenceStatement statement, Database dat
if (database instanceof HsqlDatabase || database instanceof Db2zDatabase) {
buffer.append(" AS BIGINT ");
}
if (statement.getStartValue() != null) {
if (!(database instanceof MariaDBDatabase) && statement.getStartValue() != null) {
buffer.append(" START WITH ").append(statement.getStartValue());
}
if (statement.getIncrementBy() != null) {
@@ -63,6 +63,9 @@ public ValidationErrors validate(CreateSequenceStatement statement, Database dat
if (statement.getMaxValue() != null) {
buffer.append(" MAXVALUE ").append(statement.getMaxValue());
}
if (database instanceof MariaDBDatabase && statement.getStartValue() != null) {
buffer.append(" START WITH ").append(statement.getStartValue());
}

if (statement.getCacheSize() != null) {
if (database instanceof OracleDatabase || database instanceof Db2zDatabase) {
@@ -76,7 +79,7 @@ public ValidationErrors validate(CreateSequenceStatement statement, Database dat
}
}

if (statement.getOrdered() != null) {
if (!(database instanceof MariaDBDatabase) && statement.getOrdered() != null) {
if (!(database instanceof SybaseASADatabase)) {
if (statement.getOrdered()) {
buffer.append(" ORDER");
@@ -87,7 +90,7 @@ public ValidationErrors validate(CreateSequenceStatement statement, Database dat
}
}
}
if (statement.getCycle() != null) {
if (!(database instanceof MariaDBDatabase) && statement.getCycle() != null) {
if (statement.getCycle()) {
buffer.append(" CYCLE");
}

0 comments on commit 530e4fb

Please sign in to comment.