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

mysql: Pull out the correct variable when setting read-only mode #406

Closed
wants to merge 2 commits into from
Closed

Conversation

symonds
Copy link

@symonds symonds commented Apr 3, 2014

MariaDB10 has 3 variables that include read_only. Pull out the correct variable instead of grep'ing for it.

MariaDB10 has 3 variables that include read_only. Pull out the correct variable instead of grep'ing for it.
@grooverdan
Copy link

or

read_only_state=`$MYSQL $MYSQL_OPTIONS_REPL \
         -ss -e "select @@read_only" `
if [ $read_only_state -eq 1 ]; then

@grooverdan
Copy link

for correctness it should also be SHOW GLOBAL VARIABLES LIKE 'read_only'

@symonds
Copy link
Author

symonds commented Apr 21, 2015

@grooverdan Merged in the 2 suggestions, Thanks.

@krig
Copy link
Contributor

krig commented Feb 22, 2016

Currently, this PR is broken. I don't know if it is because of changes in the mysql agent, either way it would need to be fixed to be merged. @symonds, still interested in submitting this?


if [ "$read_only_state" = "ON" ]; then
if [ $read_only_state =~ '*ON' ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to http://shellcheck.net, this has two issues:

  • SC2074 Can't use =~ in [ ]. Use [[..]] instead.
  • Don't quote rhs of =~, it'll match literally rather than as a regex. 1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Mon, Feb 22, 2016 at 06:00:05AM -0800, Kristoffer Grönlund wrote:

  • if [ "$read_only_state" = "ON" ]; then
  • if [ $read_only_state =~ '*ON' ]; then

According to http://shellcheck.net, this has two issues:

  • SC2074 Can't use =~ in [ ]. Use [[..]] instead.

I think that [[..]] is a bashism, this is a /bin/sh script.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=~ is not in POSIX test either

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Mon, Feb 22, 2016 at 07:14:15AM -0800, Kristoffer Grönlund wrote:

  • if [ "$read_only_state" = "ON" ]; then
  • if [ $read_only_state =~ '*ON' ]; then

=~ is not in POSIX test either

Right, so it shouldn't be used. Just wanted to warn about
introducing stuff which aren't available in /bin/sh.

@krig krig changed the title Update mysql mysql: Pull out the correct variable when setting read-only mode Feb 22, 2016
@symonds symonds closed this Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants