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

Added the ability to forcibly set NULL for fields in settings proxy_mysql_query_rule #98

Merged
merged 1 commit into from
Jul 5, 2019

Conversation

identw
Copy link
Contributor

@identw identw commented Mar 19, 2019

Pull Request (PR) description

I found not convenient behavior:

Suppose a rule with digest has been configured:

   proxy_mysql_query_rule { "mysql_query_rule-1":
            rule_id               => 1,
            active                => 1,
            digest                => '0xDBF868B2AA296BC5',
            destination_hostgroup => 2,
            apply                 => 1,
   }

It creates in proxysql such a rule:

Admin> SELECT rule_id,match_pattern,digest FROM mysql_query_rules WHERE rule_id = 1 AND match_pattern IS NULL;
+---------+---------------+--------------------+
| rule_id | match_pattern | digest             |
+---------+---------------+--------------------+
| 1       | NULL          | 0xDBF868B2AA296BC5 |
+---------+---------------+--------------------+

NOTE: match_pattern is real NULL
Then I replace digest to match_pattern:

   proxy_mysql_query_rule { "mysql_query_rule-1":
            rule_id               => 1,
            active                => 1,
            match_pattern         => '^SELECT',
            destination_hostgroup => 2,
            apply                 => 1,
   }

Then:

+---------+---------------+--------------------+
| rule_id | match_pattern | digest             |
+---------+---------------+--------------------+
| 1       | ^SELECT       | 0xDBF868B2AA296BC5 |
+---------+---------------+--------------------+

But I would like to have digest equal NULL =(.

I tried to set digest to undef:

proxy_mysql_query_rule { "mysql_query_rule-1":
    rule_id               => 1,
    active                => 1,
    digest                => undef,
    match_pattern         => '^SELECT',
    destination_hostgroup => 2,
    apply                 => 1,
}

Then:

Admin> SELECT rule_id,match_pattern,digest FROM mysql_query_rules WHERE rule_id = 1;
+---------+---------------+--------------------+
| rule_id | match_pattern | digest             |
+---------+---------------+--------------------+
| 1       | ^SELECT       | 0xDBF868B2AA296BC5 |
+---------+---------------+--------------------+
1 row in set (0.00 sec)

But digest not changed =(.

I tried to set digest to NULL:

   proxy_mysql_query_rule { "mysql_query_rule-1":
            rule_id               => 1,
            active                => 1,
            digest                => 'NULL',
            match_pattern         => '^SELECT',
            destination_hostgroup => 2,
            apply                 => 1,
   }

Then:

Admin> SELECT rule_id,match_pattern,digest FROM mysql_query_rules WHERE rule_id = 1;
+---------+---------------+--------+
| rule_id | match_pattern | digest |
+---------+---------------+--------+
| 1       | ^SELECT       | NULL   |
+---------+---------------+--------+

But digest is not real NULL =(:

Admin> SELECT rule_id,match_pattern,digest FROM mysql_query_rules WHERE rule_id = 1 AND digest IS NULL;
Empty set (0.00 sec)
Admin> 

I corrected this behavior with my edit. Now when setting NULL, the real NULL value is written into the proxysql:

   proxy_mysql_query_rule { "mysql_query_rule-1":
            rule_id               => 1,
            active                => 1,
            digest                => 'NULL',
            match_pattern         => '^SELECT',
            destination_hostgroup => 2,
            apply                 => 1,
   }
Admin> SELECT rule_id,match_pattern,digest FROM mysql_query_rules WHERE rule_id = 1 AND digest IS NULL;
+---------+---------------+--------+
| rule_id | match_pattern | digest |
+---------+---------------+--------+
| 1       | ^SELECT       | NULL   |
+---------+---------------+--------+
1 row in set (0.00 sec)

Admin> 

This Pull Request (PR) fixes the following issues

@identw identw changed the title Added the ability to forcibly set NULL for fields in settings proxysql Added the ability to forcibly set NULL for fields in settings proxy_mysql_query_rule Apr 5, 2019
@alexjfisher
Copy link
Member

Seems to work ok. Thanks! There's a small limitation in that if the value has already been set to the string 'NULL' puppet will think it is already insync and won't attempt to fix it.

@alexjfisher alexjfisher added the enhancement New feature or request label Jul 5, 2019
@alexjfisher alexjfisher merged commit 1497ff0 into voxpupuli:master Jul 5, 2019
@alexjfisher
Copy link
Member

@identw Thanks again. Sorry it took so long to review and merge.

cegeka-jenkins pushed a commit to cegeka/puppet-proxysql that referenced this pull request Aug 22, 2023
Added the ability to forcibly set NULL for fields in settings proxy_mysql_query_rule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants