/* }}} */
-/*
- COM_FIELD_LIST is special, different from a SHOW FIELDS FROM :
- - There is no result set header - status from the command, which
- impacts us to allocate big chunk of memory for reading the metadata.
- - The EOF packet is consumed by the metadata packet reader.
-*/
-
-/* {{{ mysqlnd_conn_data::list_fields */
-MYSQLND_RES *
-MYSQLND_METHOD(mysqlnd_conn_data, list_fields)(MYSQLND_CONN_DATA * conn, const char *table, const char *achtung_wild)
-{
- const size_t this_func = STRUCT_OFFSET(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data), list_fields);
- MYSQLND_RES * result = NULL;
- DBG_ENTER("mysqlnd_conn_data::list_fields");
- DBG_INF_FMT("conn=%llu table=%s wild=%s", conn->thread_id, table? table:"",achtung_wild? achtung_wild:"");
-
- if (PASS == conn->m->local_tx_start(conn, this_func)) {
- do {
- enum_func_status ret = FAIL;
- const MYSQLND_CSTRING tbl = {table, strlen(table)};
- const MYSQLND_CSTRING wildcard = {achtung_wild, strlen(achtung_wild)};
-
- struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_FIELD_LIST, conn, tbl, wildcard);
- if (command) {
- ret = command->run(command);
- command->free_command(command);
- }
- if (ret == FAIL) {
- break;
- }
-
- /*
- Prepare for the worst case.
- MyISAM goes to 2500 BIT columns, double it for safety.
- */
- result = conn->m->result_init(5000, conn->persistent);
- if (!result) {
- break;
- }
-
- if (FAIL == result->m.read_result_metadata(result, conn)) {
- DBG_ERR("Error occurred while reading metadata");
- result->m.free_result(result, TRUE);
- result = NULL;
- break;
- }
-
- result->type = MYSQLND_RES_NORMAL;
- result->unbuf = mysqlnd_result_unbuffered_init(result->field_count, FALSE, result->persistent);
- if (!result->unbuf) {
- /* OOM */
- SET_OOM_ERROR(conn->error_info);
- result->m.free_result(result, TRUE);
- result = NULL;
- break;
- }
- result->unbuf->eof_reached = TRUE;
- } while (0);
- conn->m->local_tx_end(conn, this_func, result == NULL? FAIL:PASS);
- }
-
- DBG_RETURN(result);
-}
-/* }}} */
-
-
/* {{{ mysqlnd_conn_data::list_method */
MYSQLND_RES *
MYSQLND_METHOD(mysqlnd_conn_data, list_method)(MYSQLND_CONN_DATA * conn, const char * query, const char *achtung_wild, char *par1)
MYSQLND_METHOD(mysqlnd_conn_data, get_proto_info),
MYSQLND_METHOD(mysqlnd_conn_data, info),
MYSQLND_METHOD(mysqlnd_conn_data, charset_name),
- MYSQLND_METHOD(mysqlnd_conn_data, list_fields),
MYSQLND_METHOD(mysqlnd_conn_data, list_method),
MYSQLND_METHOD(mysqlnd_conn_data, insert_id),
MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, get_reference),
MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, free_reference),
-// MYSQLND_METHOD(mysqlnd_conn_data, send_command_handle_response),
MYSQLND_METHOD(mysqlnd_conn_data, restart_psession),
MYSQLND_METHOD(mysqlnd_conn_data, end_psession),
MYSQLND_METHOD(mysqlnd_conn_data, send_close),
DBG_RETURN(FAIL);
}
- if (field_packet->stupid_list_fields_eof == TRUE) {
- meta->field_count = i;
- break;
- }
-
if (mysqlnd_ps_fetch_functions[meta->fields[i].type].func == NULL) {
- DBG_ERR_FMT("Unknown type %u sent by the server. Please send a report to the developers",
- meta->fields[i].type);
- php_error_docref(NULL, E_WARNING,
- "Unknown type %u sent by the server. "
- "Please send a report to the developers",
- meta->fields[i].type);
+ DBG_ERR_FMT("Unknown type %u sent by the server. Please send a report to the developers", meta->fields[i].type);
+ php_error_docref(NULL, E_WARNING, "Unknown type %u sent by the server. Please send a report to the developers", meta->fields[i].type);
PACKET_FREE(field_packet);
DBG_RETURN(FAIL);
}
typedef unsigned int (*func_mysqlnd_conn_data__get_protocol_information)(const MYSQLND_CONN_DATA * const conn);
typedef const char * (*func_mysqlnd_conn_data__get_last_message)(const MYSQLND_CONN_DATA * const conn);
typedef const char * (*func_mysqlnd_conn_data__charset_name)(const MYSQLND_CONN_DATA * const conn);
-typedef MYSQLND_RES * (*func_mysqlnd_conn_data__list_fields)(MYSQLND_CONN_DATA * conn, const char * table, const char * achtung_wild);
typedef MYSQLND_RES * (*func_mysqlnd_conn_data__list_method)(MYSQLND_CONN_DATA * conn, const char * query, const char * achtung_wild, char *par1);
typedef uint64_t (*func_mysqlnd_conn_data__get_last_insert_id)(const MYSQLND_CONN_DATA * const conn);
func_mysqlnd_conn_data__get_protocol_information get_protocol_information;
func_mysqlnd_conn_data__get_last_message get_last_message;
func_mysqlnd_conn_data__charset_name charset_name;
- func_mysqlnd_conn_data__list_fields list_fields;
func_mysqlnd_conn_data__list_method list_method;
func_mysqlnd_conn_data__get_last_insert_id get_last_insert_id;
DBG_ERR_FMT("Server error : (%u) %s", packet->error_info.error_no, packet->error_info.error);
DBG_RETURN(PASS);
} else if (EODATA_MARKER == *p && packet->header.size < 8) {
- /* Premature EOF. That should be COM_FIELD_LIST */
+ /* Premature EOF. That should be COM_FIELD_LIST. But we don't support COM_FIELD_LIST anymore, thus this should not happen */
DBG_INF("Premature EOF. That should be COM_FIELD_LIST");
- packet->stupid_list_fields_eof = TRUE;
DBG_RETURN(PASS);
}
}
/* }}} */
-/************************** COM_FIELD_LIST ******************************************/
-struct st_mysqlnd_protocol_com_field_list_command
-{
- struct st_mysqlnd_protocol_command parent;
- struct st_mysqlnd_com_field_list_context
- {
- MYSQLND_CONN_DATA * conn;
- MYSQLND_CSTRING table;
- MYSQLND_CSTRING achtung_wild;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_field_list_run */
-static enum_func_status
-mysqlnd_com_field_list_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_field_list_command * command = (struct st_mysqlnd_protocol_com_field_list_command *) cmd;
- enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- /* db + \0 + wild + \0 (for wild) */
- zend_uchar buff[MYSQLND_MAX_ALLOWED_DB_LEN * 2 + 1 + 1], *p = buff;
-
- DBG_ENTER("mysqlnd_com_field_list_run");
-
- if (command->context.table.s && command->context.table.l) {
- size_t to_copy = MIN(command->context.table.l, MYSQLND_MAX_ALLOWED_DB_LEN);
- memcpy(p, command->context.table.s, to_copy);
- p += to_copy;
- *p++ = '\0';
- }
-
- if (command->context.achtung_wild.s && command->context.achtung_wild.l) {
- size_t to_copy = MIN(command->context.achtung_wild.l, MYSQLND_MAX_ALLOWED_DB_LEN);
- memcpy(p, command->context.achtung_wild.s, to_copy);
- p += to_copy;
- *p++ = '\0';
- }
-
- ret = send_command(COM_FIELD_LIST, buff, p - buff, FALSE,
- &conn->state,
- conn->error_info,
- conn->upsert_status,
- conn->stats,
- conn->payload_decoder_factory,
- conn->m->send_close,
- conn);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_field_list_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_field_list_create_command(va_list args)
-{
- struct st_mysqlnd_protocol_com_field_list_command * command;
- DBG_ENTER("mysqlnd_com_field_list_create_command");
- command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_field_list_command));
- if (command) {
- command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command->context.table = va_arg(args, MYSQLND_CSTRING);
- command->context.achtung_wild = va_arg(args, MYSQLND_CSTRING);
-
- command->parent.free_command = mysqlnd_com_no_params_free_command;
- command->parent.run = mysqlnd_com_field_list_run;
- }
-
- DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
/************************** COM_STATISTICS ******************************************/
struct st_mysqlnd_protocol_com_statistics_command
case COM_PING:
ret = mysqlnd_com_ping_create_command(args);
break;
- case COM_FIELD_LIST:
- ret = mysqlnd_com_field_list_create_command(args);
- break;
case COM_STATISTICS:
ret = mysqlnd_com_statistics_create_command(args);
break;
MYSQLND_FIELD *metadata;
/* For table definitions, empty for result sets */
zend_bool skip_parsing;
- zend_bool stupid_list_fields_eof;
zend_bool persistent_alloc;
MYSQLND_ERROR_INFO error_info;