-
Notifications
You must be signed in to change notification settings - Fork 549
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
Client session tracking #1092
Merged
Merged
Client session tracking #1092
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4f011cf
Client session tracking
insom 41d6d4e
Add session tracking enumeration
insom 11ac160
Conditionally add the session_track method
insom 832faf5
Add tests for client.session_track
bibstha 4000b9d
Add session track information to Readme
bibstha 85fe0c8
Disable rubocop block length
bibstha eec4cc0
Allow compilation with mariadb-connector-c
bibstha d3c815c
Merge pull request #1 from Shopify/allow_compilation_with_mariadb
bibstha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Mysql2::Client do | ||
RSpec.describe Mysql2::Client do # rubocop:disable Metrics/BlockLength | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any chance to disable/extend this rubocop rule in specs only? rspec is usually bunch of huge blocks by design. |
||
context "using defaults file" do | ||
let(:cnf_file) { File.expand_path('../../my.cnf', __FILE__) } | ||
|
||
|
@@ -1026,6 +1026,49 @@ def run_gc | |
expect(@client).to respond_to(:ping) | ||
end | ||
|
||
context "session_track" do | ||
before(:each) do | ||
unless Mysql2::Client.const_defined?(:SESSION_TRACK) | ||
skip('Server versions must be MySQL 5.7 later.') | ||
end | ||
@client.query("SET @@SESSION.session_track_system_variables='*';") | ||
end | ||
|
||
it "returns changes system variables for SESSION_TRACK_SYSTEM_VARIABLES" do | ||
@client.query("SET @@SESSION.session_track_state_change=ON;") | ||
res = @client.session_track(Mysql2::Client::SESSION_TRACK_SYSTEM_VARIABLES) | ||
expect(res).to eq(%w[session_track_state_change ON]) | ||
end | ||
|
||
it "returns database name for SESSION_TRACK_SCHEMA" do | ||
@client.query("USE information_schema") | ||
res = @client.session_track(Mysql2::Client::SESSION_TRACK_SCHEMA) | ||
expect(res).to eq(["information_schema"]) | ||
end | ||
|
||
it "returns multiple session track type values when available" do | ||
@client.query("SET @@SESSION.session_track_transaction_info='CHARACTERISTICS'") | ||
|
||
res = @client.session_track(Mysql2::Client::SESSION_TRACK_TRANSACTION_STATE) | ||
expect(res).to eq(["________"]) | ||
|
||
res = @client.session_track(Mysql2::Client::SESSION_TRACK_TRANSACTION_CHARACTERISTICS) | ||
expect(res).to eq([""]) | ||
|
||
res = @client.session_track(Mysql2::Client::SESSION_TRACK_STATE_CHANGE) | ||
expect(res).to be_nil | ||
|
||
res = @client.session_track(Mysql2::Client::SESSION_TRACK_SYSTEM_VARIABLES) | ||
expect(res).to eq(%w[session_track_transaction_info CHARACTERISTICS]) | ||
end | ||
|
||
it "returns empty array if session track type not found" do | ||
@client.query("SET @@SESSION.session_track_state_change=ON;") | ||
res = @client.session_track(Mysql2::Client::SESSION_TRACK_TRANSACTION_CHARACTERISTICS) | ||
expect(res).to be_nil | ||
end | ||
end | ||
|
||
context "select_db" do | ||
before(:each) do | ||
2.times do |i| | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this example might be wrong? Should it be
flags: Mysql2::Client::SESSION_TRACK
?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.
You can pass all sorts of things to
flags
😁 -- https://github.com/brianmario/mysql2/blob/master/lib/mysql2/client.rb#L56L57 -- so this will work. It might be better to encourage the use of the constant for style reasons though? The other examples do.