Skip to content

Commit

Permalink
MariaDB 10.8 support
Browse files Browse the repository at this point in the history
This commit marks MariaDB 10.8 as a supported DB flavor. No functional changes
were required. Two new 10.8 features are already introspected properly with
existing code:

* Descending indexes (DESC index parts) -- same information_schema
  representation as equivalent feature in MySQL 8

* Functions with IN / OUT / INOUT param qualifiers -- same information_schema
  representation as stored procedures with these qualifiers

Integration test coverage has been added for these two features.

No special handling for MariaDB 10.8's new binlog_alter_two_phase feature has
been added, but use of this variable won't inherently break anything in
Skeema. (Future versions of Skeema may also add new functionality which
integrates more closely with this variable, but nothing concrete added yet.)
  • Loading branch information
evanelias committed May 26, 2022
1 parent 8cb30d0 commit 1454f21
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/tengo/flavor.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ var (
FlavorMariaDB105 = Flavor{Vendor: VendorMariaDB, Version: Version{10, 5, 0}}
FlavorMariaDB106 = Flavor{Vendor: VendorMariaDB, Version: Version{10, 6, 0}}
FlavorMariaDB107 = Flavor{Vendor: VendorMariaDB, Version: Version{10, 7, 0}}
FlavorMariaDB108 = Flavor{Vendor: VendorMariaDB, Version: Version{10, 8, 0}}
)

// ParseFlavor returns a Flavor value based on the supplied string in format
Expand Down Expand Up @@ -352,7 +353,7 @@ func (fl Flavor) Supported() bool {
case VendorMySQL:
return fl.Version.AtLeast(Version{5, 5}) && fl.Version.Below(Version{8, 1}) // MySQL 5.5.0-8.0.x is supported
case VendorMariaDB:
return fl.Version.AtLeast(Version{10, 1}) && fl.Version.Below(Version{10, 8}) // MariaDB 10.1-10.7 is supported
return fl.Version.AtLeast(Version{10, 1}) && fl.Version.Below(Version{10, 9}) // MariaDB 10.1-10.8 is supported
default:
return false
}
Expand Down
1 change: 1 addition & 0 deletions internal/tengo/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ func (s TengoIntegrationSuite) TestInstanceFlavorVersion(t *testing.T) {
"mariadb:10.5": FlavorMariaDB105,
"mariadb:10.6": FlavorMariaDB106,
"mariadb:10.7": FlavorMariaDB107,
"mariadb:10.8": FlavorMariaDB108,
}

// Determine expected Flavor value of the Dockerized instance being tested
Expand Down
13 changes: 13 additions & 0 deletions internal/tengo/introspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ func (s TengoIntegrationSuite) TestInstanceRoutineIntrospection(t *testing.T) {
}
}

// Coverage for MariaDB 10.8 IN/OUT/INOUT params in funcs
if fl := s.d.Flavor(); fl.Min(FlavorMariaDB108) {
s.SourceTestSQL(t, "maria108.sql")
schema := s.GetSchema(t, "testing")
funcsByName := schema.FunctionsByName()
f := funcsByName["maria108func"]
if defn := f.Definition(fl); defn != f.CreateStatement {
t.Errorf("Generated function definition does not match SHOW CREATE FUNCTION. Generated definition:\n%s\nSHOW CREATE FUNCTION:\n%s", defn, f.CreateStatement)
} else if !strings.Contains(defn, "INOUT") {
t.Errorf("Functions with IN/OUT/INOUT params not introspected properly. Generated definition:\n%s", defn)
}
}

// Coverage for various nil cases and error conditions
schema = nil
if procCount := len(schema.ProceduresByName()); procCount != 0 {
Expand Down
4 changes: 4 additions & 0 deletions internal/tengo/tengo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ func flavorTestFiles(flavor Flavor) []string {
}
}

if flavor.Min(FlavorMariaDB108) { // descending indexes, IN/OUT/INOUT func params
result = append(result, "maria108.sql")
}

return result
}

Expand Down
30 changes: 30 additions & 0 deletions internal/tengo/testdata/maria108.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Coverage for two new features in MariaDB 10.8: DESC index parts, and functions
# with IN / OUT / INOUT param qualifiers

SET foreign_key_checks=0;
SET sql_log_bin=0;

use testing

CREATE TABLE maria108idx (
a int NOT NULL,
b int,
c int,
d int,
PRIMARY KEY (a),
INDEX idx1 (d, b DESC),
INDEX idx2 (a DESC, b ASC, d DESC)
);

# This is essentially tengo_test.go's aProc() changed to a func instead
delimiter //
CREATE FUNCTION maria108func(
IN name varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
INOUT iterations int(10) unsigned, OUT pct decimal(5, 2)
) RETURNS int READS SQL DATA SQL SECURITY INVOKER
BEGIN
SELECT @iterations + 1, 98.76 INTO iterations, pct;
RETURN 123;
END //
delimiter ;

0 comments on commit 1454f21

Please sign in to comment.