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

Add transaction id support to makara_abstract_adapter #273

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ def custom_error_message?(connection, message)
:schema_cache=, :lock, :seconds_idle, :==


SQL_MASTER_MATCHERS = [/\A\s*select.+for update\Z/i, /select.+lock in share mode\Z/i, /\A\s*select.+(nextval|currval|lastval|get_lock|release_lock|pg_advisory_lock|pg_advisory_unlock)\(/i].map(&:freeze).freeze
SQL_SLAVE_MATCHERS = [/\A\s*(select|with.+\)\s*select)\s/i].map(&:freeze).freeze
SQL_MASTER_MATCHERS = [/select.+txid_current\(\)\Z/i, /\A\s*select.+for update\Z/i, /select.+lock in share mode\Z/i, /\A\s*select.+(nextval|currval|lastval|get_lock|release_lock|pg_advisory_lock|pg_advisory_unlock)\(/i].map(&:freeze).freeze
SQL_SLAVE_MATCHERS = [/select.+txid_visible_in_snapshot\(/i, /\A\s*(select|with.+\)\s*select)\s/i].map(&:freeze).freeze
SQL_ALL_MATCHERS = [/\A\s*set\s/i].map(&:freeze).freeze
SQL_SKIP_STICKINESS_MATCHERS = [/\A\s*show\s([\w]+\s)?(field|table|database|schema|view|index)(es|s)?/i, /\A\s*(set|describe|explain|pragma)\s/i].map(&:freeze).freeze
SQL_SKIP_STICKINESS_MATCHERS = [/select.+txid_current\(\)\Z/i, /\A\s*show\s([\w]+\s)?(field|table|database|schema|view|index)(es|s)?/i, /\A\s*(set|describe|explain|pragma)\s/i].map(&:freeze).freeze


def sql_master_matchers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
'select get_lock(\'foo\', 0)' => true,
'select release_lock(\'foo\')' => true,
'select pg_advisory_lock(12345)' => true,
'select pg_advisory_unlock(12345)' => true
'select pg_advisory_unlock(12345)' => true,
'select txid_current()' => true,
'select txid_visible_in_snapshot(1, txid_current_snapshot())' => false,
}.each do |sql, should_go_to_master|

it "determines that \"#{sql}\" #{should_go_to_master ? 'requires' : 'does not require'} master" do
Expand Down Expand Up @@ -99,6 +101,7 @@
'begin deferred transaction' => true,
'commit transaction' => true,
'rollback transaction' => true,
'select txid_current()' => false,
%Q{
UPDATE
dogs
Expand Down