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

Mariadb support #41

Open
animalcarpet opened this issue Sep 22, 2018 · 7 comments
Open

Mariadb support #41

animalcarpet opened this issue Sep 22, 2018 · 7 comments
Assignees

Comments

@animalcarpet
Copy link
Collaborator

I'm going to be using mariadb quite a bit over the coming months so I'm planning to do some testing of the project against various mariadb versions and make any necessary changes. This will probably necessitate some changes with the installer to recognise the different versions and possibly a few other changes to accommodate information_schema differences.

@hepabolu
Copy link
Owner

That sounds like a really good plan.

@animalcarpet
Copy link
Collaborator Author

The good news is that most of this appears to work out of the box on the versions I've tested. Roles support needs a rewrite because the schema is completely different and Column Defaults are broken because mariadb represents NULL as 'NULL' for default values (so don't try setting that as a string). I will have to abandon the principal of a single test script for all versions.

@hepabolu
Copy link
Owner

Having to abandon the single script for all versions is a shame. It will make the code harder to maintain.

@animalcarpet
Copy link
Collaborator Author

animalcarpet commented Sep 24, 2018 via email

@sq6jnx
Copy link
Contributor

sq6jnx commented Oct 28, 2019

I think we can workaround this problem with NOT using mysql.user or information_schema.columns and using own views. Example below.

Using:

DROP VIEW IF EXISTS tap.mysql__user;
CREATE SQL SECURITY INVOKER VIEW tap.mysql__user AS
SELECT
    `user`
    , `host`
    /* ... */
    , `password_expired`
    , NULL AS `account_locked`
FROM `mysql`.`user`;

and applying diff:

diff --git a/mytap-user-576.sql b/mytap-user-576.sql
index 0d6e1b9..d2269c3 100644
--- a/mytap-user-576.sql
+++ b/mytap-user-576.sql
@@ -26,11 +26,11 @@ BEGIN
   DECLARE ret BOOLEAN;
 
   SELECT 1 INTO ret
-  FROM `mysql`.`user`
+  FROM tap.mysql__user
   WHERE `host` = hname
   AND `user` = uname
   AND `password_expired` <> 'Y'
-  AND `account_locked` <> 'Y';
+  AND (tap.mysql_variant() = 'MariaDB' OR `account_locked` <> 'Y');
 
   RETURN COALESCE(ret, 0);
 END //

I managed to run some tests from tests/test-mytap-user.my on MariaDB (10.4.8-MariaDB-1:10.4.8+maria~bionic)

sq6jnx pushed a commit to sq6jnx/mytap that referenced this issue Oct 28, 2019
sq6jnx pushed a commit to sq6jnx/mytap that referenced this issue Oct 28, 2019
sq6jnx pushed a commit to sq6jnx/mytap that referenced this issue Oct 28, 2019
sq6jnx pushed a commit to sq6jnx/mytap that referenced this issue Oct 28, 2019
@sq6jnx sq6jnx mentioned this issue Oct 28, 2019
@sq6jnx
Copy link
Contributor

sq6jnx commented Oct 28, 2019

OK, I feel we're getting closer. But, I can not understand what is the meaning of these statements:

    SET @sql1 = 'CREATE USER ''__taprole__''@''localhost''';
    SET @sql2 = 'CREATE USER __nohost__';
    SET @sql3 = 'GRANT ''__taprole__''@''localhost'', __nohost__ TO ''__tapuser__''@''localhost''';
    SET @sql4 = 'SET DEFAULT ROLE __nohost__ TO ''__tapuser__''@''localhost''';

Help?

@sq6jnx
Copy link
Contributor

sq6jnx commented Oct 28, 2019

Or better, if anyone can translate it to MariaDB I think I'll be able to do the rest (compatibility layer + tests).

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

No branches or pull requests

3 participants