-
Notifications
You must be signed in to change notification settings - Fork 88
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
sql_mode can be set in session, therefore we should look for ANSI_QUOTES in session variable instead of global variable #677
Conversation
Hi @SoledaD208 and thank you for taking the time to open a PR. Before we can merge, it misses:
About tests : I'm not sure what will happen when you change the scope of the sql_mode from global to session for the Also, while writing tests, you could demonstrate how you intent to set a session with set sql_mode='ANSI_QUOTES'". As I don't think community.mysql allow for this. But tests are a great way to experiment that. If I'm right, we could modify your PR to add such a feature. Feel free to ask me for help executing tests. I'm also available on matrix : #mysql:ansible.com |
Hi Laurent,
Thanks for your answer. I'm a bit busy these days so can't reply to you
promptly.
Before we can merge, it misses:
Sure, I will spend some time doing those.
A rapid grep showed that the line you modified is the only time we
use sql_mode in the entire collection.
Agreed with you. That's also what I can see from the code.
you could demonstrate how you intent to set a session with set
sql_mode='ANSI_QUOTES'". As I don't think community.mysql allow for this
Oh, I don't know about that, let me try if I can. In a 'real life'
situation, I can set sql_mode by making use of parameter session_vars or
setting sql_mode in a client config file, and point the module to that file.
By the way, not related to sql_mode, I think mysql_user cannot parse the
role grants or partial revokes (Please correct if I'm wrong). E.g:
- partial revoke:
mysql> SHOW GRANTS FOR u1; +------------------------------------------+ |
Grants for u1@% | +------------------------------------------+ | GRANT
SELECT, INSERT ON *.* TO `u1`@`%` | | REVOKE INSERT ON `world`.* FROM
`u1`@`%` | +------------------------------------------+
- role grants:
mysql> SHOW GRANTS FOR 'dev1'@'localhost'; +--------------------------------
-----------------+ | Grants for ***@***.*** | +--------------------------
-----------------------+ | GRANT USAGE ON *.* TO `dev1`@`localhost` | |
GRANT `app_developer`@`%` TO `dev1`@`localhost` | +-------------------------
------------------------+
If those types of grants are not able to be parsed yet. Would they be
supported in newer versions of the module?
Thanks,
Tuan ( aka soledad208 :) )
…------------------------------
*From:* Laurent Indermühle ***@***.***>
*Sent:* Wednesday, September 11, 2024 2:29:06 PM
*To:* ansible-collections/community.mysql <
***@***.***>
*Cc:* Soledad208 ***@***.***>; Mention <
***@***.***>
*Subject:* Re: [ansible-collections/community.mysql] sql_mode can be set in
session, therefore we should look for ANSI_QUOTES in session variable
instead of global variable (PR #677)
Hi @SoledaD208 <https://github.com/SoledaD208> and thank you for taking the
time to open a PR.
Before we can merge, it misses:
- A description that explains why the change is made.
- A change log fragment with the same explanation.
- Integration tests.
About tests : I'm not sure what will happen when you change the scope of
the sql_mode from global to session for the mysql_role and mysql_user
modules. A rapid grep showed that the line you modified is the only time we
use sql_mode in the entire collection.
Also, while writing tests, you could demonstrate how you intent to set a
session with set sql_mode='ANSI_QUOTES'". As I don't think community.mysql
allow for this. But tests are a great way to experiment that.
If I'm right, we could modify your PR to add such a feature. Feel free to
ask me for help executing tests. I'm also available on matrix :
#mysql:ansible.com <https://matrix.to/#/%23mysql:ansible.com>
—
Reply to this email directly, view it on GitHub
<#677 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCTXOXYG6L7TUPBQ7ZUN43ZV7WMFAVCNFSM6AAAAABN4CGCSSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBSHA3TANJUGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
folks any thoughts on ^? |
Hi @SoledaD208, For your question about the role/revoke/read of privileges, we should keep discussions separate. Maybe in a new issue. But before doing so, please use the |
if you ask about the bad effects to community.mysql module. Incorrect quotation in store procedure and function (not tables) will make the module always see the privs on function/SP are the new ones. As consequence, it will try to revoke the existing privs and re-grant them. Not only About the general purpose of ANSI_QUOTES. Afaik, ANSI_QUOTES is the standard SQL (which Mysql, by default, doesn't follow). So without enabling that mode, if you dump some data from Postresql or other RDBMS to a sql file, then run it in Mysql, the sql dump files will fail.
|
I'm using Mysql 8. Mysql 5.7 doesn't have partial revokes or RBAC, so there's no issue with the old version.
Agreed with you, I will open another issue. |
27e3b08
to
61a4ff4
Compare
Very good tests @SoledaD208. |
d44c899
to
22e3531
Compare
22e3531
to
6d4fc3c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #677 +/- ##
===========================================
+ Coverage 25.74% 76.96% +51.21%
===========================================
Files 32 20 -12
Lines 2808 2657 -151
Branches 704 679 -25
===========================================
+ Hits 723 2045 +1322
+ Misses 2044 413 -1631
- Partials 41 199 +158
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
thanks @laurent-indermuehle indeed my "params + persist" messed up the tests. |
The tests went well for Mysql, but failed for Mariadb. Apparently, it's because in Mariadb, users can't persist |
@SoledaD208 great job! Are you ready for a review or you want to add more tests? Also, please add a changelogs / framents file to describe what you're changing and why. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SoledaD208 thanks for the persistent work on the improvement!
Yep, as @laurent-indermuehle spotted we need a fragment here https://docs.ansible.com/ansible/latest/community/development_process.html#creating-a-changelog-fragment
mysql_query: | ||
<<: *mysql_params | ||
query: 'select @@GLOBAL.sql_mode AS sql_mode' | ||
register: sql_mode_orig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
register: sql_mode_orig | |
register: sql_mode_orig |
would you like to assert:
this one too? I see you assert the second one called result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, let me check and add the assert. by the way, due to some reasons, I will need to close this PR and open another via other account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, let me check and add the assert. by the way, due to some reasons, I will need to close this PR and open another via other account.
SGTM
hi @laurent-indermuehle @Andersson007 , I just modified my PR to add fragments files and improve the test file. The PR should be ready now, could you please have a look? |
@SoledaD208 let's wait for @laurent-indermuehle a bit, if no response i'll merge it within a few days, thanks |
Thanks @Andersson007 , that's totally fine :)
…________________________________
From: Andrew Klychkov ***@***.***>
Sent: Wednesday, October 23, 2024 3:34:32 PM
To: ansible-collections/community.mysql ***@***.***>
Cc: Soledad208 ***@***.***>; Mention ***@***.***>
Subject: Re: [ansible-collections/community.mysql] sql_mode can be set in session, therefore we should look for ANSI_QUOTES in session variable instead of global variable (PR #677)
@SoledaD208<https://github.com/SoledaD208> let's wait for @laurent-indermuehle<https://github.com/laurent-indermuehle> a bit, if no response i'll merge it within a few days, thanks
—
Reply to this email directly, view it on GitHub<#677 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACCTXORTMXJ3NRZ6ZPS77G3Z45NRRAVCNFSM6AAAAABN4CGCSSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZRGMYDMOBZHE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I'm on vacation. I'll back next week. No computer here so don't wait for me. Or do if it can wait ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is some linting propositions, mainly usage of FQCN and failed_when
instead of assert
when only one test is performed (this makes for better CI output).
But didn't you said you have to create a new PR @SoledaD208 ?
hi @laurent-indermuehle , please continue with this PR. I don't need to create new one any more. I just modified my PR and commited all the suggestions, please review again. |
@laurent-indermuehle could you please take a look? |
Sure! Sorry for the delay. |
ebb37ae
into
ansible-collections:main
@SoledaD208 thanks for the contribution! |
…TES in session variable instead of global variable
SUMMARY
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION