mysql: Make auth_plugin_ a std::string

This commit is contained in:
Arne Welzel 2024-07-04 10:25:56 +02:00
parent e98b80d140
commit 48e76f38cb

View file

@ -584,7 +584,7 @@ refine connection MySQL_Conn += {
bool deprecate_eof_; bool deprecate_eof_;
bool server_query_attrs_; bool server_query_attrs_;
bool client_query_attrs_; bool client_query_attrs_;
bytestring auth_plugin_; std::string auth_plugin_;
%} %}
%init{ %init{
@ -599,11 +599,6 @@ refine connection MySQL_Conn += {
deprecate_eof_ = false; deprecate_eof_ = false;
server_query_attrs_ = false; server_query_attrs_ = false;
client_query_attrs_ = false; client_query_attrs_ = false;
auth_plugin_ = bytestring();
%}
%cleanup{
auth_plugin_.free();
%} %}
function get_version(): uint8 function get_version(): uint8
@ -688,21 +683,16 @@ refine connection MySQL_Conn += {
return true; return true;
%} %}
function get_auth_plugin(): bytestring
%{
return auth_plugin_;
%}
function set_auth_plugin(a: bytestring): bool function set_auth_plugin(a: bytestring): bool
%{ %{
if ( auth_plugin_.length() > 0 && // binpac::std_str() includes trailing \0 from parsing.
strncmp(c_str(auth_plugin_), c_str(a), auth_plugin_.length()) != 0 ) auto new_auth_plugin = std::string(binpac::c_str(a));
if ( ! auth_plugin_.empty() && new_auth_plugin != auth_plugin_ )
{ {
expected_ = EXPECT_AUTH_SWITCH; expected_ = EXPECT_AUTH_SWITCH;
} }
auth_plugin_.free(); auth_plugin_ = std::move(new_auth_plugin);
auth_plugin_.init(a.data(), a.length());
return true; return true;
%} %}