Class: MysqlPR
- Inherits:
-
Object
- Object
- MysqlPR
- Defined in:
- lib/mysql-pr.rb,
lib/mysql-pr/error.rb,
lib/mysql-pr/packet.rb,
lib/mysql-pr/charset.rb,
lib/mysql-pr/version.rb,
lib/mysql-pr/protocol.rb,
lib/mysql-pr/constants.rb
Overview
Copyright © 2003-2008 TOMITA Masahiro [email protected]
Defined Under Namespace
Classes: Charset, ClientError, Error, Field, Packet, Protocol, ProtocolError, RawRecord, Result, ResultBase, ServerError, StatementResult, Stmt, StmtRawRecord, Time
Constant Summary collapse
- MYSQL_UNIX_PORT =
"/tmp/mysql.sock"- MYSQL_TCP_PORT =
3306- VERSION =
"3.0.2"- COM_SLEEP =
Command
0- COM_QUIT =
1- COM_INIT_DB =
2- COM_QUERY =
3- COM_FIELD_LIST =
4- COM_CREATE_DB =
5- COM_DROP_DB =
6- COM_REFRESH =
7- COM_SHUTDOWN =
8- COM_STATISTICS =
9- COM_PROCESS_INFO =
10- COM_CONNECT =
11- COM_PROCESS_KILL =
12- COM_DEBUG =
13- COM_PING =
14- COM_TIME =
15- COM_DELAYED_INSERT =
16- COM_CHANGE_USER =
17- COM_BINLOG_DUMP =
18- COM_TABLE_DUMP =
19- COM_CONNECT_OUT =
20- COM_REGISTER_SLAVE =
21- COM_STMT_PREPARE =
22- COM_STMT_EXECUTE =
23- COM_STMT_SEND_LONG_DATA =
24- COM_STMT_CLOSE =
25- COM_STMT_RESET =
26- COM_SET_OPTION =
27- COM_STMT_FETCH =
28- CLIENT_LONG_PASSWORD =
Client flag
1- CLIENT_FOUND_ROWS =
new more secure passwords
1 << 1
- CLIENT_LONG_FLAG =
Found instead of affected rows
1 << 2
- CLIENT_CONNECT_WITH_DB =
Get all column flags
1 << 3
- CLIENT_NO_SCHEMA =
One can specify db on connect
1 << 4
- CLIENT_COMPRESS =
Don’t allow database.table.column
1 << 5
- CLIENT_ODBC =
Can use compression protocol
1 << 6
- CLIENT_LOCAL_FILES =
Odbc client
1 << 7
- CLIENT_IGNORE_SPACE =
Can use LOAD DATA LOCAL
1 << 8
- CLIENT_PROTOCOL_41 =
Ignore spaces before ‘(’
1 << 9
- CLIENT_INTERACTIVE =
New 4.1 protocol
1 << 10
- CLIENT_SSL =
This is an interactive client
1 << 11
- CLIENT_IGNORE_SIGPIPE =
Switch to SSL after handshake
1 << 12
- CLIENT_TRANSACTIONS =
IGNORE sigpipes
1 << 13
- CLIENT_RESERVED =
Client knows about transactions
1 << 14
- CLIENT_SECURE_CONNECTION =
Old flag for 4.1 protocol
1 << 15
- CLIENT_MULTI_STATEMENTS =
New 4.1 authentication
1 << 16
- CLIENT_MULTI_RESULTS =
Enable/disable multi-stmt support
1 << 17
- CLIENT_PS_MULTI_RESULTS =
Enable/disable multi-results
1 << 18
- CLIENT_PLUGIN_AUTH =
Multi-results in PS-protocol
1 << 19
- OPT_CONNECT_TIMEOUT =
Connection Option
0- OPT_COMPRESS =
1- OPT_NAMED_PIPE =
2- INIT_COMMAND =
3- READ_DEFAULT_FILE =
4- READ_DEFAULT_GROUP =
5- SET_CHARSET_DIR =
6- SET_CHARSET_NAME =
7- OPT_LOCAL_INFILE =
8- OPT_PROTOCOL =
9- SHARED_MEMORY_BASE_NAME =
10- OPT_READ_TIMEOUT =
11- OPT_WRITE_TIMEOUT =
12- OPT_USE_RESULT =
13- OPT_USE_REMOTE_CONNECTION =
14- OPT_USE_EMBEDDED_CONNECTION =
15- OPT_GUESS_CONNECTION =
16- SET_CLIENT_IP =
17- SECURE_AUTH =
18- REPORT_DATA_TRUNCATION =
19- OPT_RECONNECT =
20- OPT_SSL_VERIFY_SERVER_CERT =
21- OPTION_MULTI_STATEMENTS_ON =
Server Option
0- OPTION_MULTI_STATEMENTS_OFF =
1- SERVER_STATUS_IN_TRANS =
Server Status
1- SERVER_STATUS_AUTOCOMMIT =
1 << 1
- SERVER_MORE_RESULTS_EXISTS =
1 << 3
- SERVER_QUERY_NO_GOOD_INDEX_USED =
1 << 4
- SERVER_QUERY_NO_INDEX_USED =
1 << 5
- SERVER_STATUS_CURSOR_EXISTS =
1 << 6
- SERVER_STATUS_LAST_ROW_SENT =
1 << 7
- SERVER_STATUS_DB_DROPPED =
1 << 8
- SERVER_STATUS_NO_BACKSLASH_ESCAPES =
1 << 9
- REFRESH_GRANT =
Refresh parameter
1- REFRESH_LOG =
1 << 1
- REFRESH_TABLES =
1 << 2
- REFRESH_HOSTS =
1 << 3
- REFRESH_STATUS =
1 << 4
- REFRESH_THREADS =
1 << 5
- REFRESH_SLAVE =
1 << 6
- REFRESH_MASTER =
1 << 7
- REFRESH_READ_LOCK =
1 << 14
- REFRESH_FAST =
1 << 15
Instance Attribute Summary collapse
-
#charset ⇒ MysqlPR::Charset
Character set of MySQL connection.
-
#host_info ⇒ String
(also: #get_host_info)
readonly
Connection type.
-
#protocol ⇒ MysqlPR::Protocol
readonly
Protocol handler.
- #query_with_result ⇒ Boolean
-
#ssl_options ⇒ Hash
writeonly
Configure SSL with additional options.
Class Method Summary collapse
-
.client_info ⇒ String
Client version (dummy for MySQL/Ruby compatibility).
-
.client_version ⇒ Integer
Client version (dummy for MySQL/Ruby compatibility).
-
.escape_string(str) ⇒ String
Escape special character in string.
-
.get_client_info ⇒ String
Client version (dummy for MySQL/Ruby compatibility).
-
.get_client_version ⇒ Integer
Client version (dummy for MySQL/Ruby compatibility).
-
.init ⇒ MysqlPR
Make MysqlPR object without connecting.
-
.new(*args) ⇒ MysqlPR
(also: real_connect, connect)
Make MysqlPR object and connect to mysqld.
-
.quote ⇒ String
Escape special character in string.
Instance Method Summary collapse
-
#affected_rows ⇒ Integer
Number of affected records by insert/update/delete.
-
#autocommit(flag) ⇒ MysqlPR
Set autocommit mode.
-
#character_set_name ⇒ String
Charset name.
-
#client_info ⇒ String
(also: #get_client_info)
Client version.
-
#client_version ⇒ Integer
(also: #get_client_version)
Client version.
-
#close ⇒ MysqlPR
Disconnect from mysql.
-
#close! ⇒ MysqlPR
Disconnect from mysql without QUIT packet.
-
#commit ⇒ MysqlPR
Commit transaction.
-
#connect(host = nil, user = nil, passwd = nil, db = nil, port = nil, socket = nil, flag = 0) ⇒ MysqlPR
(also: #real_connect)
Connect to mysqld.
-
#errno ⇒ Integer
Last error number.
-
#error ⇒ String
Last error message.
-
#escape_string(str) ⇒ String
(also: #quote)
Escape special character in MySQL.
-
#field_count ⇒ Integer
Number of columns for last query.
-
#info ⇒ String
Information for last query.
-
#initialize ⇒ MysqlPR
constructor
A new instance of MysqlPR.
-
#insert_id ⇒ Integer
Latest auto_increment value.
-
#kill(pid) ⇒ MysqlPR
Kill query.
-
#list_dbs(db = nil) ⇒ Array<String>
Database list.
-
#list_fields(table, field = nil) ⇒ MysqlPR::Result
Returns MysqlPR::Result object that is empty.
-
#list_processes ⇒ MysqlPR::Result
Containing process list.
-
#list_tables(table = nil) ⇒ Array<String>
List of table name.
-
#more_results ⇒ Boolean
(also: #more_results?)
True if multiple queries are specified and unexecuted queries exist.
-
#next_result ⇒ Boolean
Execute next query if multiple queries are specified.
-
#options(opt, value = nil) ⇒ MysqlPR
Set option for connection.
-
#ping ⇒ MysqlPR
Check whether the connection is available.
-
#prepare(str) ⇒ MysqlPR::Stmt
Parse prepared-statement.
-
#proto_info ⇒ Integer
(also: #get_proto_info)
Protocol version.
-
#query(str) {|MysqlPR::Result| ... } ⇒ MysqlPR::Result, ...
(also: #real_query)
Execute query string.
-
#refresh(op) ⇒ MysqlPR
Flush tables or caches.
-
#reload ⇒ MysqlPR
Reload grant tables.
-
#rollback ⇒ MysqlPR
Rollback transaction.
-
#select_db(db) ⇒ MysqlPR
Select default database.
-
#server_info ⇒ String
(also: #get_server_info)
Server version.
-
#server_version ⇒ Integer
(also: #get_server_version)
Server version.
-
#set_server_option(opt) ⇒ MysqlPR
Set server option.
-
#shutdown(level = 0) ⇒ MysqlPR
Shutdown server.
-
#sqlstate ⇒ String
Sqlstate for last error.
-
#ssl_cipher ⇒ Array?
Get the SSL cipher being used.
-
#ssl_enabled? ⇒ Boolean
Check if SSL is enabled for the current connection.
-
#ssl_set(key = nil, cert = nil, ca = nil, ca_path = nil, cipher = nil) ⇒ MysqlPR
Configure SSL options for the connection.
-
#stat ⇒ String
Statistics message.
-
#stmt_init ⇒ MysqlPR::Stmt
Make empty prepared-statement object.
-
#store_result ⇒ MysqlPR::Result
Get all data for last query if query_with_result is false.
-
#thread_id ⇒ Integer
Thread ID.
-
#use_result ⇒ MysqlPR::Result
Use result of query.
-
#warning_count ⇒ Integer
Number of warnings for previous query.
Constructor Details
#initialize ⇒ MysqlPR
Returns a new instance of MysqlPR.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/mysql-pr.rb', line 82 def initialize @fields = nil @protocol = nil @charset = nil @connect_timeout = nil @read_timeout = nil @write_timeout = nil @init_command = nil @sqlstate = "00000" @query_with_result = true @host_info = nil @last_error = nil @result_exist = false @local_infile = nil @ssl_options = nil end |
Instance Attribute Details
#charset ⇒ MysqlPR::Charset
Returns character set of MySQL connection.
25 26 27 |
# File 'lib/mysql-pr.rb', line 25 def charset @charset end |
#host_info ⇒ String (readonly) Also known as: get_host_info
Returns connection type.
274 275 276 |
# File 'lib/mysql-pr.rb', line 274 def host_info @host_info end |
#protocol ⇒ MysqlPR::Protocol (readonly)
Returns protocol handler.
28 29 30 |
# File 'lib/mysql-pr.rb', line 28 def protocol @protocol end |
#query_with_result ⇒ Boolean
31 32 33 |
# File 'lib/mysql-pr.rb', line 31 def query_with_result @query_with_result end |
#ssl_options=(value) ⇒ Hash (writeonly)
Configure SSL with additional options. Must be called before connect.
202 203 204 |
# File 'lib/mysql-pr.rb', line 202 def (value) @ssl_options = value end |
Class Method Details
.client_info ⇒ String
Returns client version (dummy for MySQL/Ruby compatibility).
70 71 72 |
# File 'lib/mysql-pr.rb', line 70 def client_info "5.0.0" end |
.client_version ⇒ Integer
Returns client version (dummy for MySQL/Ruby compatibility).
76 77 78 |
# File 'lib/mysql-pr.rb', line 76 def client_version 50_000 end |
.escape_string(str) ⇒ String
Escape special character in string.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mysql-pr.rb', line 56 def escape_string(str) str.gsub(/[\0\n\r\\'"\x1a]/) do |s| case s when "\0" then "\\0" when "\n" then "\\n" when "\r" then "\\r" when "\x1a" then "\\Z" else "\\#{s}" end end end |
.get_client_info ⇒ String
Returns client version (dummy for MySQL/Ruby compatibility).
73 74 75 |
# File 'lib/mysql-pr.rb', line 73 def client_info "5.0.0" end |
.get_client_version ⇒ Integer
Returns client version (dummy for MySQL/Ruby compatibility).
79 80 81 |
# File 'lib/mysql-pr.rb', line 79 def client_version 50_000 end |
.init ⇒ MysqlPR
Make MysqlPR object without connecting.
36 37 38 39 40 |
# File 'lib/mysql-pr.rb', line 36 def init my = allocate my.send(:initialize) my end |
.new(*args) ⇒ MysqlPR Also known as: real_connect, connect
Make MysqlPR object and connect to mysqld.
45 46 47 48 |
# File 'lib/mysql-pr.rb', line 45 def new(*args) my = init my.connect(*args) end |
.quote ⇒ String
Escape special character in string.
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/mysql-pr.rb', line 67 def escape_string(str) str.gsub(/[\0\n\r\\'"\x1a]/) do |s| case s when "\0" then "\\0" when "\n" then "\\n" when "\r" then "\\r" when "\x1a" then "\\Z" else "\\#{s}" end end end |
Instance Method Details
#affected_rows ⇒ Integer
Returns number of affected records by insert/update/delete.
303 304 305 |
# File 'lib/mysql-pr.rb', line 303 def affected_rows @protocol ? @protocol.affected_rows : 0 end |
#autocommit(flag) ⇒ MysqlPR
Set autocommit mode
529 530 531 532 |
# File 'lib/mysql-pr.rb', line 529 def autocommit(flag) query("set autocommit=#{flag ? 1 : 0}") self end |
#character_set_name ⇒ String
Returns charset name.
249 250 251 |
# File 'lib/mysql-pr.rb', line 249 def character_set_name @charset.name end |
#client_info ⇒ String Also known as: get_client_info
Returns client version.
225 226 227 |
# File 'lib/mysql-pr.rb', line 225 def client_info self.class.client_info end |
#client_version ⇒ Integer Also known as: get_client_version
Returns client version.
231 232 233 |
# File 'lib/mysql-pr.rb', line 231 def client_version self.class.client_version end |
#close ⇒ MysqlPR
Disconnect from mysql.
124 125 126 127 128 129 130 |
# File 'lib/mysql-pr.rb', line 124 def close if @protocol @protocol.quit_command @protocol = nil end self end |
#close! ⇒ MysqlPR
Disconnect from mysql without QUIT packet.
134 135 136 137 138 139 140 |
# File 'lib/mysql-pr.rb', line 134 def close! if @protocol @protocol.close @protocol = nil end self end |
#commit ⇒ MysqlPR
Commit transaction
514 515 516 517 |
# File 'lib/mysql-pr.rb', line 514 def commit query("commit") self end |
#connect(host = nil, user = nil, passwd = nil, db = nil, port = nil, socket = nil, flag = 0) ⇒ MysqlPR Also known as: real_connect
Connect to mysqld.
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/mysql-pr.rb', line 108 def connect(host = nil, user = nil, passwd = nil, db = nil, port = nil, socket = nil, flag = 0) if (flag & CLIENT_COMPRESS) != 0 warn "unsupported flag: CLIENT_COMPRESS" flag &= ~CLIENT_COMPRESS end @protocol = Protocol.new(host, port, socket, @connect_timeout, @read_timeout, @write_timeout, @ssl_options) @protocol.authenticate(user, passwd, db, (@local_infile ? CLIENT_LOCAL_FILES : 0) | flag, @charset) @charset ||= @protocol.charset @host_info = host.nil? || host == "localhost" ? "Localhost via UNIX socket" : "#{host} via TCP/IP" query(@init_command) if @init_command self end |
#errno ⇒ Integer
Returns last error number.
254 255 256 |
# File 'lib/mysql-pr.rb', line 254 def errno @last_error ? @last_error.errno : 0 end |
#error ⇒ String
Returns last error message.
259 260 261 |
# File 'lib/mysql-pr.rb', line 259 def error @last_error&.error end |
#escape_string(str) ⇒ String Also known as: quote
Escape special character in MySQL.
219 220 221 |
# File 'lib/mysql-pr.rb', line 219 def escape_string(str) self.class.escape_string(str) end |
#field_count ⇒ Integer
Returns number of columns for last query.
269 270 271 |
# File 'lib/mysql-pr.rb', line 269 def field_count @fields.size end |
#info ⇒ String
Returns information for last query.
298 299 300 |
# File 'lib/mysql-pr.rb', line 298 def info @protocol&. end |
#insert_id ⇒ Integer
Returns latest auto_increment value.
308 309 310 |
# File 'lib/mysql-pr.rb', line 308 def insert_id @protocol ? @protocol.insert_id : 0 end |
#kill(pid) ⇒ MysqlPR
Kill query.
320 321 322 323 324 |
# File 'lib/mysql-pr.rb', line 320 def kill(pid) check_connection @protocol.kill_command(pid) self end |
#list_dbs(db = nil) ⇒ Array<String>
Database list.
329 330 331 332 |
# File 'lib/mysql-pr.rb', line 329 def list_dbs(db = nil) db &&= db.gsub(/[\\']/) { "\\#{::Regexp.last_match(0)}" } query(db ? "show databases like '#{db}'" : "show databases").map(&:first) end |
#list_fields(table, field = nil) ⇒ MysqlPR::Result
Returns MysqlPR::Result object that is empty. Use fetch_fields to get list of fields.
442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/mysql-pr.rb', line 442 def list_fields(table, field = nil) check_connection begin fields = @protocol.field_list_command(table, field) Result.new(fields) rescue ServerError => e @last_error = e @sqlstate = e.sqlstate raise end end |
#list_processes ⇒ MysqlPR::Result
Returns containing process list.
455 456 457 458 459 460 |
# File 'lib/mysql-pr.rb', line 455 def list_processes check_connection @fields = @protocol.process_info_command @result_exist = true store_result end |
#list_tables(table = nil) ⇒ Array<String>
Returns list of table name.
464 465 466 467 |
# File 'lib/mysql-pr.rb', line 464 def list_tables(table = nil) q = table ? "show tables like '#{quote(table)}'" : "show tables" query(q).map(&:first) end |
#more_results ⇒ Boolean Also known as: more_results?
Returns true if multiple queries are specified and unexecuted queries exist.
402 403 404 |
# File 'lib/mysql-pr.rb', line 402 def more_results (@protocol.server_status & SERVER_MORE_RESULTS_EXISTS) != 0 end |
#next_result ⇒ Boolean
Execute next query if multiple queries are specified.
409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/mysql-pr.rb', line 409 def next_result return false unless more_results check_connection @fields = nil nfields = @protocol.get_result if nfields @fields = @protocol.retr_fields(nfields) @result_exist = true end true end |
#options(opt, value = nil) ⇒ MysqlPR
Set option for connection.
Available options:
MysqlPR::INIT_COMMAND, MysqlPR::OPT_CONNECT_TIMEOUT, MysqlPR::OPT_READ_TIMEOUT,
MysqlPR::OPT_WRITE_TIMEOUT, MysqlPR::SET_CHARSET_NAME
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/mysql-pr.rb', line 150 def (opt, value = nil) case opt when MysqlPR::INIT_COMMAND @init_command = value.to_s when MysqlPR::OPT_CONNECT_TIMEOUT @connect_timeout = value when MysqlPR::OPT_LOCAL_INFILE @local_infile = value when MysqlPR::OPT_READ_TIMEOUT @read_timeout = value.to_i when MysqlPR::OPT_WRITE_TIMEOUT @write_timeout = value.to_i when MysqlPR::SET_CHARSET_NAME @charset = Charset.by_name(value.to_s) else warn "option not implemented: #{opt}" end self end |
#ping ⇒ MysqlPR
Check whether the connection is available.
471 472 473 474 475 |
# File 'lib/mysql-pr.rb', line 471 def ping check_connection @protocol.ping_command self end |
#prepare(str) ⇒ MysqlPR::Stmt
Parse prepared-statement.
425 426 427 428 429 |
# File 'lib/mysql-pr.rb', line 425 def prepare(str) st = Stmt.new(@protocol, @charset) st.prepare(str) st end |
#proto_info ⇒ Integer Also known as: get_proto_info
Returns protocol version.
278 279 280 |
# File 'lib/mysql-pr.rb', line 278 def proto_info MysqlPR::Protocol::VERSION end |
#query(str) {|MysqlPR::Result| ... } ⇒ MysqlPR::Result, ... Also known as: real_query
Execute query string.
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/mysql-pr.rb', line 342 def query(str, &block) check_connection @fields = nil begin nfields = @protocol.query_command(str) if nfields @fields = @protocol.retr_fields(nfields) @result_exist = true end if block loop do block.call(store_result) if @fields break unless next_result end return self end return @fields ? store_result : nil if @query_with_result self rescue ServerError => e @last_error = e @sqlstate = e.sqlstate raise end end |
#refresh(op) ⇒ MysqlPR
Flush tables or caches.
480 481 482 483 484 |
# File 'lib/mysql-pr.rb', line 480 def refresh(op) check_connection @protocol.refresh_command(op) self end |
#reload ⇒ MysqlPR
Reload grant tables.
488 489 490 |
# File 'lib/mysql-pr.rb', line 488 def reload refresh(MysqlPR::REFRESH_GRANT) end |
#rollback ⇒ MysqlPR
Rollback transaction
521 522 523 524 |
# File 'lib/mysql-pr.rb', line 521 def rollback query("rollback") self end |
#select_db(db) ⇒ MysqlPR
Select default database
494 495 496 497 |
# File 'lib/mysql-pr.rb', line 494 def select_db(db) query("use #{db}") self end |
#server_info ⇒ String Also known as: get_server_info
Returns server version.
284 285 286 287 |
# File 'lib/mysql-pr.rb', line 284 def server_info check_connection @protocol.server_info end |
#server_version ⇒ Integer Also known as: get_server_version
Returns server version.
291 292 293 294 |
# File 'lib/mysql-pr.rb', line 291 def server_version check_connection @protocol.server_version end |
#set_server_option(opt) ⇒ MysqlPR
Set server option.
395 396 397 398 399 |
# File 'lib/mysql-pr.rb', line 395 def set_server_option(opt) check_connection @protocol.set_option_command(opt) self end |
#shutdown(level = 0) ⇒ MysqlPR
Shutdown server.
501 502 503 504 505 |
# File 'lib/mysql-pr.rb', line 501 def shutdown(level = 0) check_connection @protocol.shutdown_command(level) self end |
#sqlstate ⇒ String
Returns sqlstate for last error.
264 265 266 |
# File 'lib/mysql-pr.rb', line 264 def sqlstate @last_error ? @last_error.sqlstate : "00000" end |
#ssl_cipher ⇒ Array?
Get the SSL cipher being used.
212 213 214 |
# File 'lib/mysql-pr.rb', line 212 def ssl_cipher @protocol&.ssl_cipher end |
#ssl_enabled? ⇒ Boolean
Check if SSL is enabled for the current connection.
206 207 208 |
# File 'lib/mysql-pr.rb', line 206 def ssl_enabled? @protocol&.ssl_enabled? || false end |
#ssl_set(key = nil, cert = nil, ca = nil, ca_path = nil, cipher = nil) ⇒ MysqlPR
Configure SSL options for the connection. Must be called before connect.
178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/mysql-pr.rb', line 178 def ssl_set(key = nil, cert = nil, ca = nil, ca_path = nil, cipher = nil) @ssl_options = { key: key, cert: cert, ca: ca, ca_path: ca_path, cipher: cipher, verify: ca || ca_path ? true : false } self end |
#stat ⇒ String
Returns statistics message.
508 509 510 |
# File 'lib/mysql-pr.rb', line 508 def stat @protocol ? @protocol.statistics_command : "MySQL server has gone away" end |
#stmt_init ⇒ MysqlPR::Stmt
Make empty prepared-statement object.
433 434 435 |
# File 'lib/mysql-pr.rb', line 433 def stmt_init Stmt.new(@protocol, @charset) end |
#store_result ⇒ MysqlPR::Result
Get all data for last query if query_with_result is false.
371 372 373 374 375 376 377 378 |
# File 'lib/mysql-pr.rb', line 371 def store_result check_connection raise ClientError, "invalid usage" unless @result_exist res = Result.new(@fields, @protocol) @result_exist = false res end |
#thread_id ⇒ Integer
Returns Thread ID.
381 382 383 384 |
# File 'lib/mysql-pr.rb', line 381 def thread_id check_connection @protocol.thread_id end |
#use_result ⇒ MysqlPR::Result
Use result of query. The result data is retrieved when you use MysqlPR::Result#fetch.
388 389 390 |
# File 'lib/mysql-pr.rb', line 388 def use_result store_result end |
#warning_count ⇒ Integer
Returns number of warnings for previous query.
313 314 315 |
# File 'lib/mysql-pr.rb', line 313 def warning_count @protocol ? @protocol.warning_count : 0 end |