47 upsert_status->warning_count = 0;
48 upsert_status->server_status = 0;
49 upsert_status->affected_rows = 0;
50 upsert_status->last_insert_id = 0;
59 upsert_status->affected_rows = (uint64_t) ~0;
75 upsert_status->m->reset(upsert_status);
82mysqlnd_error_list_pdtor(
void * pDest)
86 DBG_ENTER(
"mysqlnd_error_list_pdtor");
99 DBG_ENTER(
"mysqlnd_error_info::reset");
102 info->error[0] =
'\0';
103 memset(&info->sqlstate, 0,
sizeof(info->sqlstate));
114 const unsigned int err_no,
116 const char *
const error)
118 DBG_ENTER(
"mysqlnd_error_info::set_client_error");
122 info->error_no = err_no;
126 error_for_the_list.
error_no = err_no;
129 if (error_for_the_list.
error) {
130 DBG_INF_FMT(
"adding error [%s] to the list", error_for_the_list.
error);
134 info->m->reset(info);
152 DBG_ENTER(
"mysqlnd_error_info_init");
154 info->m->reset(info);
167 DBG_ENTER(
"mysqlnd_error_info_free_contents");
168 info->m->reset(info);
180 DBG_ENTER(
"mysqlnd_connection_state::get");
181 DBG_INF_FMT(
"State=%u", state_struct->state);
191 DBG_ENTER(
"mysqlnd_connection_state::set");
192 DBG_INF_FMT(
"New state=%u",
state);
209 DBG_ENTER(
"mysqlnd_connection_state_init");
222 bool pers = conn->persistent;
224 if (conn->options->charset_name) {
225 mnd_pefree(conn->options->charset_name, pers);
226 conn->options->charset_name =
NULL;
228 if (conn->options->auth_protocol) {
229 mnd_pefree(conn->options->auth_protocol, pers);
230 conn->options->auth_protocol =
NULL;
232 if (conn->options->num_commands) {
234 for (i = 0; i < conn->options->num_commands; i++) {
236 mnd_pefree(conn->options->init_commands[i], pers);
238 mnd_pefree(conn->options->init_commands, pers);
239 conn->options->init_commands =
NULL;
241 if (conn->options->cfg_file) {
243 conn->options->cfg_file =
NULL;
245 if (conn->options->cfg_section) {
247 conn->options->cfg_section =
NULL;
249 if (conn->options->connect_attr) {
251 mnd_pefree(conn->options->connect_attr, pers);
252 conn->options->connect_attr =
NULL;
254 if (conn->options->local_infile_directory) {
255 mnd_pefree(conn->options->local_infile_directory, pers);
256 conn->options->local_infile_directory =
NULL;
266 bool pers = conn->persistent;
268 DBG_ENTER(
"mysqlnd_conn_data::free_contents");
270 if (conn->current_result) {
271 conn->current_result->m.free_result(conn->current_result,
TRUE);
272 conn->current_result =
NULL;
275 if (conn->protocol_frame_codec) {
276 conn->protocol_frame_codec->data->m.free_contents(conn->protocol_frame_codec);
280 conn->vio->data->m.free_contents(conn->vio);
283 DBG_INF(
"Freeing memory of members");
285 mysqlnd_set_persistent_string(&conn->hostname,
NULL, 0, pers);
286 mysqlnd_set_persistent_string(&conn->username,
NULL, 0, pers);
287 mysqlnd_set_persistent_string(&conn->password,
NULL, 0, pers);
288 mysqlnd_set_persistent_string(&conn->connect_or_select_db,
NULL, 0, pers);
289 mysqlnd_set_persistent_string(&conn->unix_socket,
NULL, 0, pers);
290 DBG_INF_FMT(
"scheme=%s", conn->scheme.s);
291 mysqlnd_set_persistent_string(&conn->scheme,
NULL, 0, pers);
293 if (conn->server_version) {
295 conn->server_version =
NULL;
297 if (conn->host_info) {
299 conn->host_info =
NULL;
301 mysqlnd_set_persistent_string(&conn->authentication_plugin_data,
NULL, 0, pers);
302 mysqlnd_set_string(&conn->last_message,
NULL, 0);
304 conn->charset =
NULL;
305 conn->greet_charset =
NULL;
316 DBG_ENTER(
"mysqlnd_conn_data::dtor");
317 DBG_INF_FMT(
"conn=%" PRIu64, conn->thread_id);
319 conn->m->free_contents(conn);
320 conn->m->free_options(conn);
322 if (conn->error_info) {
324 conn->error_info =
NULL;
327 if (conn->protocol_frame_codec) {
328 mysqlnd_pfc_free(conn->protocol_frame_codec, conn->stats, conn->error_info);
329 conn->protocol_frame_codec =
NULL;
337 if (conn->payload_decoder_factory) {
339 conn->payload_decoder_factory =
NULL;
357 DBG_ENTER(
"mysqlnd_conn_data::set_server_option");
358 DBG_RETURN(conn->command->set_option(conn, option));
367 DBG_ENTER(
"mysqlnd_conn_data::restart_psession");
369 conn->current_result =
NULL;
370 conn->last_message.s =
NULL;
380 DBG_ENTER(
"mysqlnd_conn_data::end_psession");
382 if (conn->current_result) {
383 conn->current_result->m.free_result(conn->current_result,
TRUE);
384 conn->current_result =
NULL;
386 mysqlnd_set_string(&conn->last_message,
NULL, 0);
387 conn->error_info = &conn->error_info_impl;
395MYSQLND_METHOD(mysqlnd_conn_data, fetch_auth_plugin_by_name)(
const char *
const requested_protocol)
398 char * plugin_name =
NULL;
399 DBG_ENTER(
"mysqlnd_conn_data::fetch_auth_plugin_by_name");
401 mnd_sprintf(&plugin_name, 0,
"auth_plugin_%s", requested_protocol);
402 DBG_INF_FMT(
"looking for %s auth plugin", plugin_name);
417 DBG_ENTER(
"mysqlnd_conn_data::execute_init_commands");
418 if (conn->options->init_commands) {
419 unsigned int current_command = 0;
420 for (; current_command < conn->options->num_commands; ++current_command) {
421 const char *
const command = conn->options->init_commands[current_command];
424 if (
PASS != conn->m->query(conn, command,
strlen(command))) {
436 }
while (conn->m->next_result(conn) !=
FAIL);
449#ifdef MYSQLND_COMPRESSION_ENABLED
454 DBG_ENTER(
"mysqlnd_conn_data::get_updated_connect_flags");
459 mysql_flags |= conn->options->flags;
461#ifndef MYSQLND_COMPRESSION_ENABLED
470#ifndef MYSQLND_SSL_SUPPORTED
485 if (conn->options->connect_attr && zend_hash_num_elements(conn->options->connect_attr)) {
501 const unsigned int mysql_flags)
504 DBG_ENTER(
"mysqlnd_conn_data::connect_handshake");
506 if (
PASS == conn->vio->data->m.connect(conn->vio, *scheme, conn->persistent, conn->stats, conn->error_info)) {
507 conn->protocol_frame_codec->data->m.reset(conn->protocol_frame_codec, conn->stats, conn->error_info);
508 size_t client_flags = mysql_flags;
510 ret = conn->command->handshake(conn, *username, *password, *database, client_flags);
521 DBG_ENTER(
"mysqlnd_conn_data::get_scheme");
523 if (hostname.l ==
sizeof(
"localhost") - 1 && !
strncasecmp(hostname.s,
"localhost", hostname.l)) {
524 DBG_INF_FMT(
"socket=%s", socket_or_pipe->s? socket_or_pipe->s:
"n/a");
525 if (!socket_or_pipe->s) {
526 socket_or_pipe->s =
"/tmp/mysql.sock";
527 socket_or_pipe->l =
strlen(socket_or_pipe->s);
529 transport.
l =
mnd_sprintf(&transport.
s, 0,
"unix://%s", socket_or_pipe->s);
532 if (hostname.l ==
sizeof(
".") - 1 && hostname.s[0] ==
'.') {
534 if (!socket_or_pipe->s) {
535 socket_or_pipe->s =
"\\\\.\\pipe\\MySQL";
536 socket_or_pipe->l =
strlen(socket_or_pipe->s);
538 transport.
l =
mnd_sprintf(&transport.
s, 0,
"pipe://%s", socket_or_pipe->s);
545 transport.
l =
mnd_sprintf(&transport.
s, 0,
"tcp://%s:%u", hostname.s, port);
547 DBG_INF_FMT(
"transport=%s", transport.
s? transport.
s:
"OOM");
562 unsigned int mysql_flags
565 bool unix_socket =
FALSE;
566 bool named_pipe =
FALSE;
567 bool reconnect =
FALSE;
568 bool saved_compression =
FALSE;
572 DBG_ENTER(
"mysqlnd_conn_data::connect");
573 DBG_INF_FMT(
"conn=%p", conn);
578 DBG_INF_FMT(
"host=%s user=%s db=%s port=%u flags=%u persistent=%u state=%u",
579 hostname.s?hostname.s:
"", username.s?username.s:
"", database.s?database.s:
"", port, mysql_flags,
583 DBG_INF(
"Connecting on a connected handle.");
588 conn->m->send_close(conn);
591 conn->m->free_contents(conn);
599 saved_compression =
TRUE;
610 if (!hostname.s || !hostname.s[0]) {
611 hostname.s =
"localhost";
612 hostname.l =
strlen(hostname.s);
615 DBG_INF_FMT(
"no user given, using empty string");
620 DBG_INF_FMT(
"no password given, using empty string");
624 if (!database.s || !database.s[0]) {
625 DBG_INF_FMT(
"no db given, using empty string");
632 transport = conn->m->get_scheme(conn, hostname, &socket_or_pipe, port, &unix_socket, &named_pipe);
634 mysql_flags = conn->m->get_updated_connect_flags(conn, mysql_flags);
638 if (
FAIL == conn->m->connect_handshake(conn, &scheme, &username, &password, &database, mysql_flags)) {
646 if (saved_compression) {
657 mysqlnd_set_persistent_string(&conn->scheme, transport.
s, transport.
l, conn->persistent);
663 if (!conn->scheme.s) {
667 mysqlnd_set_persistent_string(&conn->username, username.s, username.l, conn->persistent);
668 mysqlnd_set_persistent_string(&conn->password, username.s, password.l, conn->persistent);
670 mysqlnd_set_persistent_string(&conn->connect_or_select_db, database.s, database.l, conn->persistent);
672 if (!unix_socket && !named_pipe) {
673 mysqlnd_set_persistent_string(&conn->hostname, hostname.s, hostname.l, conn->persistent);
685 conn->unix_socket.s =
mnd_pestrdup(socket_or_pipe.s, conn->persistent);
687 conn->host_info =
mnd_pestrdup(
"Localhost via UNIX socket", conn->persistent);
688 }
else if (named_pipe) {
690 mnd_sprintf(&
p, 0,
"%s via named pipe", conn->unix_socket.s);
700 if (!conn->unix_socket.s || !conn->host_info) {
704 conn->unix_socket.l =
strlen(conn->unix_socket.s);
711 if (
FAIL == conn->m->execute_init_commands(conn)) {
719 if (conn->persistent) {
723 DBG_INF_FMT(
"connection_id=%" PRIu64, conn->thread_id);
728 DBG_ERR_FMT(
"[%u] %.128s (trying to connect via %s)", conn->error_info->error_no, conn->error_info->error, transport.
s ? transport.
s : conn->scheme.s);
729 if (!conn->error_info->error_no) {
732 mnd_sprintf(&
msg, 0,
"Unknown error while trying to connect via %s", transport.
s ? transport.
s : conn->scheme.s);
742 conn->m->free_contents(conn);
758 unsigned int mysql_flags)
762 DBG_ENTER(
"mysqlnd_conn::connect");
765 if (hostname.l > 0) {
768 DBG_RETURN(conn->m->connect(conn, hostname, username, password, database, port, socket_or_pipe, mysql_flags));
782 DBG_ENTER(
"mysqlnd_conn_data::query");
783 DBG_INF_FMT(
"conn=%p conn=%" PRIu64
" query=%s", conn, conn->
thread_id, query);
785 if (
PASS == conn->m->send_query(conn, query, query_len,
NULL,
NULL) &&
786 PASS == conn->m->reap_query(conn))
804 DBG_ENTER(
"mysqlnd_conn_data::send_query");
805 DBG_INF_FMT(
"conn=%" PRIu64
" query=%s", conn->thread_id, query);
820 DBG_ENTER(
"mysqlnd_conn_data::reap_query");
821 DBG_INF_FMT(
"conn=%" PRIu64, conn->thread_id);
835 char * show_query =
NULL;
836 size_t show_query_len;
839 DBG_ENTER(
"mysqlnd_conn_data::list_method");
840 DBG_INF_FMT(
"conn=%" PRIu64
" query=%s wild=%p", conn->
thread_id, query, achtung_wild);
844 show_query_len =
mnd_sprintf(&show_query, 0, query, par1, achtung_wild);
846 show_query_len =
mnd_sprintf(&show_query, 0, query, par1);
850 show_query_len =
mnd_sprintf(&show_query, 0, query, achtung_wild);
852 show_query_len =
strlen(show_query = (
char *)query);
856 if (
PASS == conn->m->query(conn, show_query, show_query_len)) {
857 result = conn->m->store_result(conn);
859 if (show_query != query) {
898 DBG_ENTER(
"mysqlnd_old_escape_string");
907 const char *
const ca,
const char *
const capath,
const char *
const cipher)
910 DBG_ENTER(
"mysqlnd_conn_data::ssl_set");
928 DBG_ENTER(
"mysqlnd_conn_data::escape_string");
929 DBG_INF_FMT(
"conn=%" PRIu64, conn->thread_id);
946 DBG_ENTER(
"mysqlnd_conn_data::dump_debug_info");
947 DBG_INF_FMT(
"conn=%" PRIu64, conn->thread_id);
957 DBG_ENTER(
"mysqlnd_conn_data::select_db");
958 DBG_INF_FMT(
"conn=%" PRIu64
" db=%s", conn->thread_id, db);
961 DBG_RETURN(conn->command->init_db(conn, database));
970 DBG_ENTER(
"mysqlnd_conn_data::ping");
971 DBG_INF_FMT(
"conn=%" PRIu64, conn->thread_id);
974 DBG_INF_FMT(
"ret=%u",
ret);
984 DBG_ENTER(
"mysqlnd_conn_data::statistic");
985 DBG_INF_FMT(
"conn=%" PRIu64, conn->thread_id);
986 DBG_RETURN(conn->command->statistics(conn, message));
995 DBG_ENTER(
"mysqlnd_conn_data::kill");
996 DBG_INF_FMT(
"conn=%" PRIu64
" pid=%u", conn->thread_id, pid);
998 const unsigned int process_id = pid;
1000 const unsigned int read_response = (pid != conn->thread_id);
1002 DBG_RETURN(conn->command->process_kill(conn, process_id, read_response));
1014 DBG_ENTER(
"mysqlnd_conn_data::set_charset");
1015 DBG_INF_FMT(
"conn=%" PRIu64
" cs=%s", conn->thread_id, csname);
1023 size_t query_len =
mnd_sprintf(&query, 0,
"SET NAMES %s", csname);
1025 if (
FAIL == (
ret = conn->m->query(conn, query, query_len)) || conn->error_info->error_no) {
1032 DBG_INF(
ret ==
PASS?
"PASS":
"FAIL");
1042 DBG_ENTER(
"mysqlnd_conn_data::refresh");
1043 DBG_INF_FMT(
"conn=%" PRIu64
" options=%u", conn->thread_id,
options);
1058 DBG_ENTER(
"mysqlnd_send_close");
1059 DBG_INF_FMT(
"conn=%" PRIu64
" vio->data->stream->abstract=%p", conn->thread_id, net_stream? net_stream->
abstract:
NULL);
1060 DBG_INF_FMT(
"state=%u",
state);
1064 if (conn->persistent) {
1070 DBG_INF(
"Connection clean, sending COM_QUIT");
1072 ret = conn->command->quit(conn);
1073 vio->
data->m.close_stream(vio, conn->stats, conn->error_info);
1086 DBG_ERR_FMT(
"Brutally closing connection [%p][%s]", conn, conn->scheme.s);
1103 vio->
data->m.close_stream(vio, conn->stats, conn->error_info);
1116 DBG_ENTER(
"mysqlnd_conn_data::get_reference");
1118 DBG_INF_FMT(
"conn=%" PRIu64
" new_refcount=%u", conn->thread_id, conn->refcount);
1129 DBG_ENTER(
"mysqlnd_conn_data::free_reference");
1130 DBG_INF_FMT(
"conn=%" PRIu64
" old_refcount=%u", conn->thread_id, conn->refcount);
1131 if (!(--conn->refcount)) {
1137 ret = conn->m->send_close(conn);
1138 conn->m->dtor(conn);
1149 return conn->field_count;
1194 return conn->last_message.s;
1219 return conn->server_version;
1228 return conn->host_info;
1237 return conn->protocol_version;
1246 return conn->charset->name;
1255 return conn->thread_id;
1267 if (!(
p = conn->server_version)) {
1286 DBG_ENTER(
"mysqlnd_conn_data::more_results");
1297 DBG_ENTER(
"mysqlnd_conn_data::next_result");
1298 DBG_INF_FMT(
"conn=%" PRIu64
"", conn->thread_id);
1317 if (!conn->error_info->error_no) {
1318 DBG_ERR_FMT(
"Serious error. %s::%u", __FILE__, __LINE__);
1321 conn->m->send_close(conn);
1323 DBG_INF_FMT(
"Error from the server : (%u) %s", conn->error_info->error_no, conn->error_info->error);
1339 const char * passwd,
1347 DBG_ENTER(
"mysqlnd_conn_data::change_user");
1348 DBG_INF_FMT(
"conn=%" PRIu64
" user=%s passwd=%s db=%s silent=%u",
1349 conn->thread_id, user?user:
"", passwd?
"***":
"null", db?db:
"", silent ==
TRUE);
1367 conn->authentication_plugin_data, conn->options->auth_protocol,
1368 0 , conn->options, conn->server_capabilities, silent,
TRUE);
1374 DBG_INF(
ret ==
PASS?
"PASS":
"FAIL");
1384 const char *
const value
1388 DBG_ENTER(
"mysqlnd_conn_data::set_client_option");
1389 DBG_INF_FMT(
"conn=%" PRIu64
" option=%u", conn->thread_id, option);
1402 ret = conn->vio->data->m.set_client_option(conn->vio, option,
value);
1407 ret = conn->protocol_frame_codec->data->m.set_client_option(conn->protocol_frame_codec, option,
value);
1410 conn->options->int_and_float_native = *(
unsigned int*)
value;
1413 if (
value && (*(
unsigned int*)
value) ? 1 : 0) {
1421 if (conn->options->local_infile_directory) {
1422 mnd_pefree(conn->options->local_infile_directory, conn->persistent);
1426 conn->options->local_infile_directory =
NULL;
1434 char ** new_init_commands;
1438 new_init_commands =
mnd_perealloc(conn->options->init_commands,
sizeof(
char *) * (conn->options->num_commands + 1), conn->persistent);
1439 conn->options->init_commands = new_init_commands;
1441 conn->options->init_commands[conn->options->num_commands] = new_command;
1442 ++conn->options->num_commands;
1451 char * new_charset_name;
1459 if (conn->options->charset_name) {
1460 mnd_pefree(conn->options->charset_name, conn->persistent);
1462 conn->options->charset_name = new_charset_name;
1463 DBG_INF_FMT(
"charset=%s", conn->options->charset_name);
1471 conn->options->protocol = *(
unsigned int*)
value;
1475 if (*(
unsigned int*)
value > (1<<16)) {
1476 conn->options->max_allowed_packet = *(
unsigned int*)
value;
1482 if (conn->options->auth_protocol) {
1483 mnd_pefree(conn->options->auth_protocol, conn->persistent);
1485 conn->options->auth_protocol = new_auth_protocol;
1486 DBG_INF_FMT(
"auth_protocol=%s", conn->options->auth_protocol);
1490 if (
value && (*(
unsigned int*)
value) ? 1 : 0) {
1497 if (conn->options->connect_attr) {
1498 DBG_INF_FMT(
"Before reset %d attribute(s)", zend_hash_num_elements(conn->options->connect_attr));
1503 if (conn->options->connect_attr &&
value) {
1504 DBG_INF_FMT(
"Before delete %d attribute(s)", zend_hash_num_elements(conn->options->connect_attr));
1506 DBG_INF_FMT(
"%d left", zend_hash_num_elements(conn->options->connect_attr));
1521 const char *
const key,
1522 const char *
const value
1526 DBG_ENTER(
"mysqlnd_conn_data::set_client_option_2d");
1527 DBG_INF_FMT(
"conn=%" PRIu64
" option=%u", conn->thread_id, option);
1531 if (!conn->options->connect_attr) {
1532 DBG_INF(
"Initializing connect_attr hash");
1536 DBG_INF_FMT(
"Adding [%s][%s]",
key,
value);
1541 if (conn->persistent) {
1566 DBG_ENTER(
"mysqlnd_conn_data::use_result");
1567 DBG_INF_FMT(
"conn=%" PRIu64, conn->thread_id);
1569 if (!conn->current_result) {
1576 DBG_ERR(
"Command out of sync");
1582 conn->current_result->conn = conn->m->get_reference(conn);
1586 conn->current_result->m.free_result(conn->current_result,
TRUE);
1588 conn->current_result =
NULL;
1598 DBG_ENTER(
"mysqlnd_conn_data::store_result");
1599 DBG_INF_FMT(
"conn=%" PRIu64
" conn=%p", conn->thread_id, conn);
1601 if (!conn->current_result) {
1608 DBG_ERR(
"Command out of sync");
1615 conn->current_result->m.free_result(conn->current_result,
TRUE);
1617 conn->current_result =
NULL;
1628 DBG_ENTER(
"mysqlnd_conn_data::get_connection_stats");
1639 DBG_ENTER(
"mysqlnd_conn_data::set_autocommit");
1640 DBG_RETURN(conn->m->query(conn, (
mode) ?
"SET AUTOCOMMIT=1":
"SET AUTOCOMMIT=0",
sizeof(
"SET AUTOCOMMIT=1") - 1));
1669 smart_str_appendl(str,
" ",
sizeof(
" ") - 1);
1671 smart_str_appendl(str,
"AND CHAIN",
sizeof(
"AND CHAIN") - 1);
1674 smart_str_appendl(str,
" ",
sizeof(
" ") - 1);
1676 smart_str_appendl(str,
"AND NO CHAIN",
sizeof(
"AND NO CHAIN") - 1);
1681 smart_str_appendl(str,
" ",
sizeof(
" ") - 1);
1683 smart_str_appendl(str,
"RELEASE",
sizeof(
"RELEASE") - 1);
1686 smart_str_appendl(str,
" ",
sizeof(
" ") - 1);
1688 smart_str_appendl(str,
"NO RELEASE",
sizeof(
"NO RELEASE") - 1);
1697mysqlnd_escape_string_for_tx_name_in_comment(
const char *
const name)
1700 DBG_ENTER(
"mysqlnd_escape_string_for_tx_name_in_comment");
1702 bool warned =
FALSE;
1703 const char * p_orig =
name;
1710 register char v = *p_orig;
1714 if ((
v >=
'0' &&
v <=
'9') ||
1715 (
v >=
'a' &&
v <=
'z') ||
1716 (
v >=
'A' &&
v <=
'Z') ||
1723 }
else if (warned ==
FALSE) {
1724 php_error_docref(
NULL,
E_WARNING,
"Transaction name has been truncated, since it can only contain the A-Z, a-z, 0-9, \"\\\", \"-\", \"_\", and \"=\" characters");
1742 DBG_ENTER(
"mysqlnd_conn_data::tx_commit_or_rollback");
1745 conn->m->tx_cor_options_to_string(conn, &tmp_str,
flags);
1746 smart_str_0(&tmp_str);
1750 char * name_esc = mysqlnd_escape_string_for_tx_name_in_comment(
name);
1752 query_len =
mnd_sprintf(&query, 0, (commit?
"COMMIT%s %s":
"ROLLBACK%s %s"),
1753 name_esc? name_esc:
"", tmp_str.
s?
ZSTR_VAL(tmp_str.
s):
"");
1754 smart_str_free(&tmp_str);
1775 DBG_ENTER(
"mysqlnd_conn_data::tx_begin");
1780 smart_str_appendl(&tmp_str,
", ",
sizeof(
", ") - 1);
1782 smart_str_appendl(&tmp_str,
"WITH CONSISTENT SNAPSHOT",
sizeof(
"WITH CONSISTENT SNAPSHOT") - 1);
1786 smart_str_appendl(&tmp_str,
", ",
sizeof(
", ") - 1);
1788 smart_str_appendl(&tmp_str,
"READ WRITE",
sizeof(
"READ WRITE") - 1);
1791 smart_str_appendl(&tmp_str,
", ",
sizeof(
", ") - 1);
1793 smart_str_appendl(&tmp_str,
"READ ONLY",
sizeof(
"READ ONLY") - 1);
1795 smart_str_0(&tmp_str);
1797 char * name_esc = mysqlnd_escape_string_for_tx_name_in_comment(
name);
1799 unsigned int query_len =
mnd_sprintf(&query, 0,
"START TRANSACTION%s %s", name_esc? name_esc:
"", tmp_str.
s?
ZSTR_VAL(tmp_str.
s):
"");
1800 smart_str_free(&tmp_str);
1814 "This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required");
1826 DBG_ENTER(
"mysqlnd_conn_data::tx_savepoint");
1851 DBG_ENTER(
"mysqlnd_conn_data::tx_savepoint_release");
1859 size_t query_len =
mnd_sprintf(&query, 0,
"RELEASE SAVEPOINT `%s`",
name);
1876 unsigned int ret = 0;
1877 DBG_ENTER(
"mysqlnd_conn_data::negotiate_client_api_capabilities");
1879 ret = conn->client_api_capabilities;
1880 conn->client_api_capabilities =
flags;
1892 DBG_ENTER(
"mysqlnd_conn_data::get_client_api_capabilities");
1893 DBG_RETURN(conn? conn->client_api_capabilities : 0);
1903 DBG_ENTER(
"mysqlnd_conn_data::stmt_init");
1904 ret = conn->object_factory.get_prepared_statement(conn);
1990 MYSQLND_METHOD(mysqlnd_conn_data, negotiate_client_api_capabilities),
2002 DBG_ENTER(
"mysqlnd_conn::get_reference");
2003 ret = conn->data->object_factory.clone_connection_object(conn);
2013 DBG_ENTER(
"mysqlnd_conn::dtor");
2014 DBG_INF_FMT(
"conn=%" PRIu64, conn->data->thread_id);
2016 conn->data->m->free_reference(conn->data);
2031 DBG_ENTER(
"mysqlnd_conn::close");
2032 DBG_INF_FMT(
"conn=%" PRIu64, conn->
thread_id);
2049 conn_handle->m->dtor(conn_handle);
2069 unsigned int cnt = 0;
2082 p_p =
p = conn_array;
2108 unsigned int cnt = 0;
2110 DBG_ENTER(
"mysqlnd_stream_array_to_fd_set");
2118 stream = (*p)->data->vio->data->m.get_stream((*p)->data->vio);
2119 DBG_INF_FMT(
"conn=%" PRIu64
" stream=%p", (*p)->data->thread_id, stream);
2120 if (stream !=
NULL &&
2127 if (this_fd > *max_fd) {
2141mysqlnd_stream_array_from_fd_set(
MYSQLND ** conn_array, fd_set * fds)
2145 unsigned int ret = 0;
2146 bool disproportion =
FALSE;
2147 MYSQLND **fwd = conn_array, **bckwd = conn_array;
2148 DBG_ENTER(
"mysqlnd_stream_array_from_fd_set");
2151 stream = (*fwd)->data->vio->data->m.get_stream((*fwd)->data->vio);
2152 DBG_INF_FMT(
"conn=%" PRIu64
" stream=%p", (*fwd)->data->thread_id, stream);
2156 if (disproportion) {
2165 disproportion =
TRUE;
2176#define php_select(m, r, w, e, t) select(m, r, w, e, t)
2187 struct timeval *tv_p =
NULL;
2188 fd_set rfds, wfds, efds;
2191 int set_count, max_set_count = 0;
2193 DBG_ENTER(
"_mysqlnd_poll");
2194 if (sec < 0 || usec < 0) {
2203 if (r_array !=
NULL) {
2205 set_count = mysqlnd_stream_array_to_fd_set(r_array, &rfds, &max_fd);
2206 if (set_count > max_set_count) {
2207 max_set_count = set_count;
2212 if (e_array !=
NULL) {
2213 set_count = mysqlnd_stream_array_to_fd_set(e_array, &efds, &max_fd);
2214 if (set_count > max_set_count) {
2215 max_set_count = set_count;
2222 DBG_ERR_FMT(*dont_poll ?
"All arrays passed are clear":
"No stream arrays were passed");
2231 if (usec > 999999) {
2232 tv.tv_sec = sec + (usec / 1000000);
2233 tv.tv_usec = usec % 1000000;
2249 if (r_array !=
NULL) {
2250 mysqlnd_stream_array_from_fd_set(r_array, &rfds);
2252 if (e_array !=
NULL) {
2253 mysqlnd_stream_array_from_fd_set(e_array, &efds);
2264 const char *
const host,
2265 const char *
const user,
2266 const char *
const passwd,
unsigned int passwd_len,
2267 const char *
const db,
unsigned int db_len,
2269 const char *
const sock_or_pipe,
2270 unsigned int mysql_flags,
2271 unsigned int client_api_flags
2275 bool self_alloced =
FALSE;
2282 DBG_ENTER(
"mysqlnd_connect");
2283 DBG_INF_FMT(
"host=%s user=%s db=%s port=%u flags=%u", host? host:
"", user? user:
"", db? db:
"", port, mysql_flags);
2286 self_alloced =
TRUE;
2293 ret = conn_handle->m->connect(conn_handle, hostname, username, password, database, port, socket_or_pipe, mysql_flags);
2301 conn_handle->m->dtor(conn_handle);
2316 DBG_ENTER(
"mysqlnd_connection_init");
2319 ret->data->m->negotiate_client_api_capabilities(
ret->data, client_flags);
reset(array|object &$array)
memset(ptr, 0, type->size)
const php_stream_filter_factory * factory
enum entity_charset charset
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
#define MYSQLND_INC_GLOBAL_STATISTIC(statistic)
PHPAPI MYSQLND_STATS * mysqlnd_global_stats
#define mysqlnd_stmt_errno(stmt)
#define MYSQLND_METHOD_PRIVATE(class, method)
#define MYSQLND_INC_CONN_STATISTIC(conn_stats, statistic)
PHPAPI const MYSQLND_STRING mysqlnd_stats_values_names[]
#define PHP_MYSQLND_VERSION
PHPAPI void * mysqlnd_plugin_find(const char *const name)
#define MYSQLND_VERSION_ID
#define mysqlnd_options4(conn, opt, k, v)
PHPAPI void mysqlnd_local_infile_default(MYSQLND_CONN_DATA *conn)
#define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value)
#define MYSQLND_METHOD(class, method)
#define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2)
PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_name(const char *const charsetname)
#define MYSQLND_DEC_GLOBAL_STATISTIC(statistic)
#define mnd_pemalloc(size, pers)
#define mnd_pestrdup(ptr, pers)
#define mnd_sprintf_free(p)
#define mnd_perealloc(ptr, new_size, p)
#define mnd_sprintf(p, mx_len, fmt,...)
#define mnd_emalloc(size)
#define mnd_pefree(ptr, pers)
enum_func_status mysqlnd_run_authentication(MYSQLND_CONN_DATA *const conn, const char *const user, const char *const passwd, const size_t passwd_len, const char *const db, const size_t db_len, const MYSQLND_STRING auth_plugin_data, const char *const auth_protocol, const unsigned int charset_no, const MYSQLND_SESSION_OPTIONS *const session_options, const zend_ulong mysql_flags, const bool silent, const bool is_change_user)
const MYSQLND_CHARSET mysqlnd_charsets[]
PHPAPI zend_ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET *const cset, char *newstr, const char *escapestr, const size_t escapestr_len)
PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET *const cset, char *newstr, const char *escapestr, const size_t escapestr_len)
PHPAPI MYSQLND * mysqlnd_connection_init(const size_t client_flags, const bool persistent, MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *object_factory)
PHPAPI void mysqlnd_connection_state_init(struct st_mysqlnd_connection_state *const state)
#define php_select(m, r, w, e, t)
PHPAPI void mysqlnd_error_info_init(MYSQLND_ERROR_INFO *const info, const bool persistent)
PHPAPI const char * mysqlnd_get_client_info(void)
PHPAPI const char *const mysqlnd_out_of_memory
PHPAPI const char *const mysqlnd_server_gone
PHPAPI enum_func_status mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQLND ***dont_poll, long sec, long usec, int *desc_num)
MYSQLND ** mysqlnd_stream_array_check_for_readiness(MYSQLND **conn_array)
void mysqlnd_upsert_status_init(MYSQLND_UPSERT_STATUS *const upsert_status)
PHPAPI void mysqlnd_error_info_free_contents(MYSQLND_ERROR_INFO *const info)
PHPAPI MYSQLND * mysqlnd_connection_connect(MYSQLND *conn_handle, const char *const host, const char *const user, const char *const passwd, unsigned int passwd_len, const char *const db, unsigned int db_len, unsigned int port, const char *const sock_or_pipe, unsigned int mysql_flags, unsigned int client_api_flags)
PHPAPI const char *const mysqlnd_out_of_sync
PHPAPI unsigned long mysqlnd_get_client_version(void)
PHPAPI zend_ulong mysqlnd_old_escape_string(char *newstr, const char *escapestr, size_t escapestr_len)
mysqlnd_query_read_result_set_header
#define SET_CONNECTION_STATE(state_struct, s)
#define UPSERT_STATUS_GET_AFFECTED_ROWS(status)
#define UPSERT_STATUS_GET_SERVER_STATUS(status)
#define UPSERT_STATUS_GET_WARNINGS(status)
#define UPSERT_STATUS_GET_LAST_INSERT_ID(status)
#define UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(status)
#define GET_CONNECTION_STATE(state_struct)
#define DBG_RETURN(value)
@ CONN_NEXT_RESULT_PENDING
#define CLIENT_LOCAL_FILES
#define TRANS_COR_NO_RELEASE
#define MYSQLND_PROTOCOL_FLAG_USE_COMPRESSION
#define CR_NOT_IMPLEMENTED
#define TRANS_START_READ_WRITE
#define MYSQLND_SQLSTATE_NULL
@ MYSQL_OPT_CONNECT_TIMEOUT
@ MYSQL_OPT_LOAD_DATA_LOCAL_DIR
@ MYSQLND_OPT_AUTH_PROTOCOL
@ MYSQL_OPT_CONNECT_ATTR_DELETE
@ MYSQLND_OPT_NET_CMD_BUFFER_SIZE
@ MYSQLND_OPT_INT_AND_FLOAT_NATIVE
@ MYSQL_SERVER_PUBLIC_KEY
@ MYSQL_OPT_WRITE_TIMEOUT
@ MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS
@ MYSQL_OPT_CONNECT_ATTR_ADD
@ MYSQLND_OPT_MAX_ALLOWED_PACKET
@ MYSQL_READ_DEFAULT_GROUP
@ MYSQL_OPT_SSL_VERIFY_SERVER_CERT
@ MYSQL_OPT_CONNECT_ATTR_RESET
@ MYSQL_READ_DEFAULT_FILE
@ MYSQLND_OPT_NET_READ_BUFFER_SIZE
enum mysqlnd_client_option enum_mysqlnd_client_option
@ STAT_INIT_COMMAND_FAILED_COUNT
@ STAT_OPENED_CONNECTIONS
@ STAT_INIT_COMMAND_EXECUTED_COUNT
@ STAT_ROWS_AFFECTED_NORMAL
@ STAT_OPENED_PERSISTENT_CONNECTIONS
#define TRANS_COR_RELEASE
#define CLIENT_CONNECT_WITH_DB
#define TRANS_START_WITH_CONSISTENT_SNAPSHOT
#define CLIENT_CONNECT_ATTRS
enum mysqlnd_collected_stats enum_mysqlnd_collected_stats
enum mysqlnd_connection_close_type enum_connection_close_type
#define TRANS_COR_AND_CHAIN
#define MYSQLND_ASSEMBLED_PACKET_MAX_SIZE
#define CR_CONNECTION_ERROR
#define MYSQLND_CAPABILITIES
#define CR_COMMANDS_OUT_OF_SYNC
enum mysqlnd_server_option enum_mysqlnd_server_option
#define CR_CANT_FIND_CHARSET
#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS
#define SERVER_MORE_RESULTS_EXISTS
#define SERVER_STATUS_NO_BACKSLASH_ESCAPES
enum func_status enum_func_status
#define TRANS_START_READ_ONLY
#define TRANS_COR_AND_NO_CHAIN
#define mysqlnd_error_info_get_methods()
PHPAPI void mysqlnd_pfc_free(MYSQLND_PFC *const pfc, MYSQLND_STATS *stats, MYSQLND_ERROR_INFO *error_info)
PHPAPI void mysqlnd_fill_stats_hash(const MYSQLND_STATS *const stats, const MYSQLND_STRING *names, zval *return_value ZEND_FILE_LINE_DC)
PHPAPI void mysqlnd_stats_end(MYSQLND_STATS *stats, const bool persistent)
#define MYSQLND_CLASS_METHODS_END
struct st_mysqlnd_vio MYSQLND_VIO
struct st_mysqlnd_upsert_status MYSQLND_UPSERT_STATUS
struct st_mysqlnd_connection_data MYSQLND_CONN_DATA
struct st_mysqlnd_string MYSQLND_STRING
struct st_mysqlnd_const_string MYSQLND_CSTRING
#define MYSQLND_CLASS_METHODS_TYPE(class)
struct st_mysqlnd_stats MYSQLND_STATS
struct st_mysqlnd_protocol_frame_codec MYSQLND_PFC
struct st_mysqlnd_error_list_element MYSQLND_ERROR_LIST_ELEMENT
#define SET_EMPTY_ERROR(info)
struct st_mysqlnd_connection MYSQLND
struct st_mysqlnd_charset MYSQLND_CHARSET
struct st_mysqlnd_stmt MYSQLND_STMT
#define SET_OOM_ERROR(info)
#define SET_CLIENT_ERROR(info, err_no, sqlstate, error)
#define MYSQLND_CLASS_METHODS_START(class)
struct st_mysqlnd_error_info MYSQLND_ERROR_INFO
struct st_mysqlnd_res MYSQLND_RES
#define MYSQLND_CLASS_METHOD_TABLE_NAME(class)
PHPAPI void mysqlnd_vio_free(MYSQLND_VIO *const vio, MYSQLND_STATS *stats, MYSQLND_ERROR_INFO *error_info)
PHPAPI void mysqlnd_protocol_payload_decoder_factory_free(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY *const factory)
PHP_JSON_API size_t int options
#define PHP_SAFE_FD_ISSET(fd, set)
#define PHP_SAFE_FD_SET(fd, set)
#define PHP_SAFE_MAX_FD(m, n)
unsigned char key[REFLECTION_KEY_LEN]
#define php_stream_cast(stream, as, ret, show_err)
struct _php_stream php_stream
#define PHP_STREAM_AS_FD_FOR_SELECT
#define PHP_STREAM_CAST_INTERNAL
MYSQLND_UPSERT_STATUS * upsert_status
enum_mysqlnd_query_type last_query_type
MYSQLND_ERROR_INFO * error_info
MYSQLND_CONNECTION_STATE state
enum mysqlnd_connection_state state
char sqlstate[MYSQLND_SQLSTATE_LENGTH+1]
char error[MYSQLND_ERRMSG_SIZE+1]
char sqlstate[MYSQLND_SQLSTATE_LENGTH+1]
struct st_mysqlnd_protocol_frame_codec_data * data
MYSQLND_VIO_OPTIONS options
struct st_mysqlnd_vio_data * data
#define ecalloc(nmemb, size)
zend_string_release_ex(func->internal_function.function_name, 0)
#define strncasecmp(s1, s2, n)
ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht)
ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht)
ZEND_API zval *ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData)
ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, size_t len)
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)
ZEND_API void zend_llist_add_element(zend_llist *l, const void *element)
ZEND_API void zend_llist_init(zend_llist *l, size_t size, llist_dtor_func_t dtor, unsigned char persistent)
ZEND_API void zend_llist_clean(zend_llist *l)
void(* llist_dtor_func_t)(void *)
#define ZEND_STRTOL(s0, s1, base)
struct _zend_string zend_string
#define ZEND_FILE_LINE_DC
#define ZEND_VALID_SOCKET(sock)
#define ZEND_FILE_LINE_CC
struct _zend_array HashTable
#define GC_MAKE_PERSISTENT_LOCAL(p)
#define ZVAL_NEW_STR(z, s)
#define ZVAL_INTERNAL_PTR_DTOR