Skip to content

Commit 0d3329f

Browse files
committed
MNDR:
- send_command and send_command_handle_response_* moved to a structure
1 parent e81ecc8 commit 0d3329f

File tree

3 files changed

+244
-185
lines changed

3 files changed

+244
-185
lines changed

ext/mysqlnd/mysqlnd_loaddata.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,13 @@ mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * const filenam
212212

213213
infile_error:
214214
/* get response from server and update upsert values */
215-
if (FAIL == send_command_handle_response(PROT_OK_PACKET, FALSE, COM_QUERY, FALSE,
216-
conn->error_info,
217-
conn->upsert_status,
218-
conn->payload_decoder_factory,
219-
&conn->last_message,
220-
conn->persistent)) {
215+
if (FAIL == conn->payload_decoder_factory->m.send_command_handle_response(
216+
conn->payload_decoder_factory,
217+
PROT_OK_PACKET, FALSE, COM_QUERY, FALSE,
218+
conn->error_info,
219+
conn->upsert_status,
220+
&conn->last_message,
221+
conn->persistent)) {
221222
result = FAIL;
222223
}
223224

ext/mysqlnd/mysqlnd_structs.h

Lines changed: 106 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -385,62 +385,6 @@ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_net)
385385
};
386386

387387

388-
struct st_mysqlnd_packet_greet;
389-
struct st_mysqlnd_packet_greet;
390-
struct st_mysqlnd_packet_auth;
391-
struct st_mysqlnd_packet_ok;
392-
struct st_mysqlnd_packet_command;
393-
struct st_mysqlnd_packet_eof;
394-
struct st_mysqlnd_packet_rset_header;
395-
struct st_mysqlnd_packet_res_field;
396-
struct st_mysqlnd_packet_row;
397-
struct st_mysqlnd_packet_stats;
398-
struct st_mysqlnd_packet_prepare_response;
399-
struct st_mysqlnd_packet_chg_user_resp;
400-
struct st_mysqlnd_packet_auth_pam;
401-
struct st_mysqlnd_packet_sha256_pk_request;
402-
struct st_mysqlnd_packet_sha256_pk_request_response;
403-
404-
typedef struct st_mysqlnd_packet_greet * (*func_mysqlnd_protocol_payload_decoder_factory__get_greet_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
405-
typedef struct st_mysqlnd_packet_auth * (*func_mysqlnd_protocol_payload_decoder_factory__get_auth_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
406-
typedef struct st_mysqlnd_packet_auth_response *(*func_mysqlnd_protocol_payload_decoder_factory__get_auth_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
407-
typedef struct st_mysqlnd_packet_change_auth_response * (*func_mysqlnd_protocol_payload_decoder_factory__get_change_auth_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
408-
typedef struct st_mysqlnd_packet_ok * (*func_mysqlnd_protocol_payload_decoder_factory__get_ok_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
409-
typedef struct st_mysqlnd_packet_command * (*func_mysqlnd_protocol_payload_decoder_factory__get_command_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
410-
typedef struct st_mysqlnd_packet_eof * (*func_mysqlnd_protocol_payload_decoder_factory__get_eof_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
411-
typedef struct st_mysqlnd_packet_rset_header * (*func_mysqlnd_protocol_payload_decoder_factory__get_rset_header_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
412-
typedef struct st_mysqlnd_packet_res_field * (*func_mysqlnd_protocol_payload_decoder_factory__get_result_field_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
413-
typedef struct st_mysqlnd_packet_row * (*func_mysqlnd_protocol_payload_decoder_factory__get_row_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
414-
typedef struct st_mysqlnd_packet_stats * (*func_mysqlnd_protocol_payload_decoder_factory__get_stats_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
415-
typedef struct st_mysqlnd_packet_prepare_response *(*func_mysqlnd_protocol_payload_decoder_factory__get_prepare_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
416-
typedef struct st_mysqlnd_packet_chg_user_resp*(*func_mysqlnd_protocol_payload_decoder_factory__get_change_user_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
417-
typedef struct st_mysqlnd_packet_sha256_pk_request *(*func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
418-
typedef struct st_mysqlnd_packet_sha256_pk_request_response *(*func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
419-
420-
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory)
421-
{
422-
func_mysqlnd_protocol_payload_decoder_factory__get_greet_packet get_greet_packet;
423-
func_mysqlnd_protocol_payload_decoder_factory__get_auth_packet get_auth_packet;
424-
func_mysqlnd_protocol_payload_decoder_factory__get_auth_response_packet get_auth_response_packet;
425-
func_mysqlnd_protocol_payload_decoder_factory__get_change_auth_response_packet get_change_auth_response_packet;
426-
func_mysqlnd_protocol_payload_decoder_factory__get_ok_packet get_ok_packet;
427-
func_mysqlnd_protocol_payload_decoder_factory__get_command_packet get_command_packet;
428-
func_mysqlnd_protocol_payload_decoder_factory__get_eof_packet get_eof_packet;
429-
func_mysqlnd_protocol_payload_decoder_factory__get_rset_header_packet get_rset_header_packet;
430-
func_mysqlnd_protocol_payload_decoder_factory__get_result_field_packet get_result_field_packet;
431-
func_mysqlnd_protocol_payload_decoder_factory__get_row_packet get_row_packet;
432-
func_mysqlnd_protocol_payload_decoder_factory__get_stats_packet get_stats_packet;
433-
func_mysqlnd_protocol_payload_decoder_factory__get_prepare_response_packet get_prepare_response_packet;
434-
func_mysqlnd_protocol_payload_decoder_factory__get_change_user_response_packet get_change_user_response_packet;
435-
func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_packet get_sha256_pk_request_packet;
436-
func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_response_packet get_sha256_pk_request_response_packet;
437-
438-
void * unused1;
439-
void * unused2;
440-
void * unused3;
441-
};
442-
443-
444388
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory);
445389

446390
typedef MYSQLND * (*func_mysqlnd_object_factory__get_connection)(struct st_mysqlnd_object_factory_methods * factory, zend_bool persistent);
@@ -658,6 +602,7 @@ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn)
658602
func_mysqlnd_conn__close close;
659603
};
660604

605+
661606
/* for decoding - binary or text protocol */
662607
typedef enum_func_status (*func_mysqlnd_res__row_decoder)(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval * fields,
663608
unsigned int field_count, const MYSQLND_FIELD * fields_metadata,
@@ -932,14 +877,6 @@ struct st_mysqlnd_net
932877
};
933878

934879

935-
struct st_mysqlnd_protocol_payload_decoder_factory
936-
{
937-
MYSQLND_CONN_DATA * conn;
938-
zend_bool persistent;
939-
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory) m;
940-
};
941-
942-
943880
struct st_mysqlnd_protocol_command
944881
{
945882
enum_func_status (*run)(void *cmd);
@@ -1055,6 +992,111 @@ struct st_mysqlnd_connection
1055992
};
1056993

1057994

995+
996+
struct st_mysqlnd_packet_greet;
997+
struct st_mysqlnd_packet_greet;
998+
struct st_mysqlnd_packet_auth;
999+
struct st_mysqlnd_packet_ok;
1000+
struct st_mysqlnd_packet_command;
1001+
struct st_mysqlnd_packet_eof;
1002+
struct st_mysqlnd_packet_rset_header;
1003+
struct st_mysqlnd_packet_res_field;
1004+
struct st_mysqlnd_packet_row;
1005+
struct st_mysqlnd_packet_stats;
1006+
struct st_mysqlnd_packet_prepare_response;
1007+
struct st_mysqlnd_packet_chg_user_resp;
1008+
struct st_mysqlnd_packet_auth_pam;
1009+
struct st_mysqlnd_packet_sha256_pk_request;
1010+
struct st_mysqlnd_packet_sha256_pk_request_response;
1011+
1012+
typedef struct st_mysqlnd_packet_greet * (*func_mysqlnd_protocol_payload_decoder_factory__get_greet_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1013+
typedef struct st_mysqlnd_packet_auth * (*func_mysqlnd_protocol_payload_decoder_factory__get_auth_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1014+
typedef struct st_mysqlnd_packet_auth_response *(*func_mysqlnd_protocol_payload_decoder_factory__get_auth_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1015+
typedef struct st_mysqlnd_packet_change_auth_response * (*func_mysqlnd_protocol_payload_decoder_factory__get_change_auth_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1016+
typedef struct st_mysqlnd_packet_ok * (*func_mysqlnd_protocol_payload_decoder_factory__get_ok_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1017+
typedef struct st_mysqlnd_packet_command * (*func_mysqlnd_protocol_payload_decoder_factory__get_command_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1018+
typedef struct st_mysqlnd_packet_eof * (*func_mysqlnd_protocol_payload_decoder_factory__get_eof_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1019+
typedef struct st_mysqlnd_packet_rset_header * (*func_mysqlnd_protocol_payload_decoder_factory__get_rset_header_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1020+
typedef struct st_mysqlnd_packet_res_field * (*func_mysqlnd_protocol_payload_decoder_factory__get_result_field_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1021+
typedef struct st_mysqlnd_packet_row * (*func_mysqlnd_protocol_payload_decoder_factory__get_row_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1022+
typedef struct st_mysqlnd_packet_stats * (*func_mysqlnd_protocol_payload_decoder_factory__get_stats_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1023+
typedef struct st_mysqlnd_packet_prepare_response *(*func_mysqlnd_protocol_payload_decoder_factory__get_prepare_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1024+
typedef struct st_mysqlnd_packet_chg_user_resp*(*func_mysqlnd_protocol_payload_decoder_factory__get_change_user_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1025+
typedef struct st_mysqlnd_packet_sha256_pk_request *(*func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1026+
typedef struct st_mysqlnd_packet_sha256_pk_request_response *(*func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, zend_bool persistent);
1027+
1028+
typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_command)(
1029+
MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * payload_decoder_factory,
1030+
const enum php_mysqlnd_server_command command,
1031+
const zend_uchar * const arg, const size_t arg_len,
1032+
const zend_bool silent,
1033+
1034+
MYSQLND_CONNECTION_STATE * connection_state,
1035+
MYSQLND_ERROR_INFO * error_info,
1036+
MYSQLND_UPSERT_STATUS * upsert_status,
1037+
MYSQLND_STATS * stats,
1038+
func_mysqlnd_conn_data__send_close send_close,
1039+
void * send_close_ctx);
1040+
1041+
typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_OK)(
1042+
MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const payload_decoder_factory,
1043+
MYSQLND_ERROR_INFO * const error_info,
1044+
MYSQLND_UPSERT_STATUS * const upsert_status,
1045+
const zend_bool ignore_upsert_status, /* actually used only by LOAD DATA. COM_QUERY and COM_EXECUTE handle the responses themselves */
1046+
MYSQLND_STRING * const last_message,
1047+
const zend_bool last_message_persistent);
1048+
1049+
typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_EOF)(
1050+
MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const payload_decoder_factory,
1051+
MYSQLND_ERROR_INFO * const error_info,
1052+
MYSQLND_UPSERT_STATUS * const upsert_status);
1053+
1054+
typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response)(
1055+
MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * payload_decoder_factory,
1056+
const enum mysqlnd_packet_type ok_packet,
1057+
const zend_bool silent,
1058+
const enum php_mysqlnd_server_command command,
1059+
const zend_bool ignore_upsert_status, /* actually used only by LOAD DATA. COM_QUERY and COM_EXECUTE handle the responses themselves */
1060+
1061+
MYSQLND_ERROR_INFO * error_info,
1062+
MYSQLND_UPSERT_STATUS * upsert_status,
1063+
MYSQLND_STRING * last_message,
1064+
zend_bool last_message_persistent);
1065+
1066+
1067+
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory)
1068+
{
1069+
func_mysqlnd_protocol_payload_decoder_factory__get_greet_packet get_greet_packet;
1070+
func_mysqlnd_protocol_payload_decoder_factory__get_auth_packet get_auth_packet;
1071+
func_mysqlnd_protocol_payload_decoder_factory__get_auth_response_packet get_auth_response_packet;
1072+
func_mysqlnd_protocol_payload_decoder_factory__get_change_auth_response_packet get_change_auth_response_packet;
1073+
func_mysqlnd_protocol_payload_decoder_factory__get_ok_packet get_ok_packet;
1074+
func_mysqlnd_protocol_payload_decoder_factory__get_command_packet get_command_packet;
1075+
func_mysqlnd_protocol_payload_decoder_factory__get_eof_packet get_eof_packet;
1076+
func_mysqlnd_protocol_payload_decoder_factory__get_rset_header_packet get_rset_header_packet;
1077+
func_mysqlnd_protocol_payload_decoder_factory__get_result_field_packet get_result_field_packet;
1078+
func_mysqlnd_protocol_payload_decoder_factory__get_row_packet get_row_packet;
1079+
func_mysqlnd_protocol_payload_decoder_factory__get_stats_packet get_stats_packet;
1080+
func_mysqlnd_protocol_payload_decoder_factory__get_prepare_response_packet get_prepare_response_packet;
1081+
func_mysqlnd_protocol_payload_decoder_factory__get_change_user_response_packet get_change_user_response_packet;
1082+
func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_packet get_sha256_pk_request_packet;
1083+
func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_response_packet get_sha256_pk_request_response_packet;
1084+
1085+
func_mysqlnd_protocol_payload_decoder_factory__send_command send_command;
1086+
func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response;
1087+
func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_OK send_command_handle_OK;
1088+
func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_EOF send_command_handle_EOF;
1089+
};
1090+
1091+
struct st_mysqlnd_protocol_payload_decoder_factory
1092+
{
1093+
MYSQLND_CONN_DATA * conn;
1094+
zend_bool persistent;
1095+
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory) m;
1096+
};
1097+
1098+
1099+
10581100
struct mysqlnd_field_hash_key
10591101
{
10601102
zend_bool is_numeric;

0 commit comments

Comments
 (0)