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
Support connect attributes #164
Conversation
Hi! |
The first element of std::env::args_os() is usually the path of the executable. However it may not exist.
@@ -242,6 +243,25 @@ impl<'a> Drop for Transaction<'a> { | |||
} | |||
} | |||
|
|||
// length of length encoded integer | |||
fn lenenc_int_len(x: usize) -> usize { |
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.
Please add the following todo comment. I'll move this to mysql_common
crate later.
fn lenenc_int_len(x: usize) -> usize { | |
// TODO: Move to mysql_common | |
fn lenenc_int_len(x: usize) -> usize { |
} | ||
|
||
// length of length encoded string | ||
fn lenenc_str_len(s: &str) -> usize { |
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.
Please add the following todo comment. I'll move this to mysql_common
crate later.
fn lenenc_str_len(s: &str) -> usize { | |
// TODO: Move to mysql_common | |
fn lenenc_str_len(s: &str) -> usize { |
let value = env::var(name).expect(&format!("Could not get the environment variable {}", name)); | ||
println!("cargo:rustc-env={}={}", name, value); | ||
} | ||
} |
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.
Could you please apply the diff as suggested by rustfmt here.
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 did it. See the second commit.
Thanks for accepting it. I found a issue about tests. When the system variable |
Ok, thanks. I'll wait for it. |
This PR add connect attributes support as Perl DBD::MySQL.
I confirmed that this passes a test by
cargo test connect_attrs
for MySQL 5.7.build.rs
was added to gettarget_os
andtarget_arch
cfg features as string values.The followings is the doc comment of
Opts.connect_attrs
Connect attributes
This value is sent to the server as custom name-value attributes.
You can see them from performance_schema tables:
session_account_connect_attrs
and
session_connect_attrs
when the server is MySQL 5.6 or later,or MariaDB 10.0 or later.
Note
Attribute names that begin with an underscore (
_
) are not set byapplication programs because they are reserved for internal use.
The following attributes are sent in addition to ones set by programs.
rust-mysql-simple
)target_os
cfg feature)target_arch
cfg feature)std::env::args
if program_name isn't set by programs.