Skip to content

Commit bdbf47d

Browse files
committed
ported mysql and mysqlnd
1 parent 1d8bc9a commit bdbf47d

20 files changed

+164
-162
lines changed

Diff for: ext/mysql/php_mysql.c

+17-17
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static int le_result, le_link, le_plink;
8080
#define SAFE_STRING(s) ((s)?(s):"")
8181

8282
#if MYSQL_VERSION_ID > 32199 || defined(MYSQL_USE_MYSQLND)
83-
# define mysql_row_length_type unsigned long
83+
# define mysql_row_length_type php_uint_t
8484
# define HAVE_MYSQL_ERRNO
8585
#else
8686
# define mysql_row_length_type unsigned int
@@ -727,12 +727,12 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
727727
char *tmp = NULL, *host = NULL;
728728
int user_len = 0, passwd_len = 0, host_len = 0;
729729
int port = MYSQL_PORT;
730-
long client_flags = 0;
730+
php_int_t client_flags = 0;
731731
php_mysql_conn *mysql = NULL;
732732
#if MYSQL_VERSION_ID <= 32230
733733
void (*handler) (int);
734734
#endif
735-
long connect_timeout;
735+
php_int_t connect_timeout;
736736
zend_string *hashed_details = NULL;
737737
zend_bool free_host = 0, new_link = 0;
738738

@@ -780,13 +780,13 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
780780
} else {
781781
/* mysql_pconnect does not support new_link parameter */
782782
if (persistent) {
783-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!l", &host_and_port, &host_len,
783+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!i", &host_and_port, &host_len,
784784
&user, &user_len, &passwd, &passwd_len,
785785
&client_flags)==FAILURE) {
786786
return;
787787
}
788788
} else {
789-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!bl", &host_and_port, &host_len,
789+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!bi", &host_and_port, &host_len,
790790
&user, &user_len, &passwd, &passwd_len,
791791
&new_link, &client_flags)==FAILURE) {
792792
return;
@@ -1927,7 +1927,7 @@ PHP_FUNCTION(mysql_insert_id)
19271927
PHP_FUNCTION(mysql_result)
19281928
{
19291929
zval *result, *field=NULL;
1930-
long row;
1930+
php_int_t row;
19311931
MYSQL_RES *mysql_result;
19321932
#ifndef MYSQL_USE_MYSQLND
19331933
MYSQL_ROW sql_row;
@@ -1940,7 +1940,7 @@ johannes TODO:
19401940
Do 2 zend_parse_parameters calls instead of type "z" and switch below
19411941
Q: String or long first?
19421942
*/
1943-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &result, &row, &field) == FAILURE) {
1943+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri|z", &result, &row, &field) == FAILURE) {
19441944
return;
19451945
}
19461946

@@ -2063,7 +2063,7 @@ PHP_FUNCTION(mysql_num_fields)
20632063

20642064
/* {{{ php_mysql_fetch_hash
20652065
*/
2066-
static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, int expected_args, int into_object)
2066+
static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, php_int_t result_type, int expected_args, int into_object)
20672067
{
20682068
MYSQL_RES *mysql_result;
20692069
zval *res, *ctor_params = NULL;
@@ -2096,7 +2096,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type,
20962096
} else
20972097
#endif
20982098
{
2099-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &res, &result_type) == FAILURE) {
2099+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|i", &res, &result_type) == FAILURE) {
21002100
return;
21012101
}
21022102
if (!result_type) {
@@ -2271,10 +2271,10 @@ PHP_FUNCTION(mysql_fetch_assoc)
22712271
PHP_FUNCTION(mysql_data_seek)
22722272
{
22732273
zval *result;
2274-
long offset;
2274+
php_int_t offset;
22752275
MYSQL_RES *mysql_result;
22762276

2277-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &result, &offset)) {
2277+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri", &result, &offset)) {
22782278
return;
22792279
}
22802280

@@ -2398,11 +2398,11 @@ static char *php_mysql_get_field_name(int field_type)
23982398
PHP_FUNCTION(mysql_fetch_field)
23992399
{
24002400
zval *result;
2401-
long field=0;
2401+
php_int_t field=0;
24022402
MYSQL_RES *mysql_result;
24032403
const MYSQL_FIELD *mysql_field;
24042404

2405-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &result, &field) == FAILURE) {
2405+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|i", &result, &field) == FAILURE) {
24062406
return;
24072407
}
24082408

@@ -2445,10 +2445,10 @@ PHP_FUNCTION(mysql_fetch_field)
24452445
PHP_FUNCTION(mysql_field_seek)
24462446
{
24472447
zval *result;
2448-
long offset;
2448+
php_int_t offset;
24492449
MYSQL_RES *mysql_result;
24502450

2451-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &result, &offset) == FAILURE) {
2451+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri", &result, &offset) == FAILURE) {
24522452
return;
24532453
}
24542454
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
@@ -2473,13 +2473,13 @@ PHP_FUNCTION(mysql_field_seek)
24732473
static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
24742474
{
24752475
zval *result;
2476-
long field;
2476+
php_int_t field;
24772477
MYSQL_RES *mysql_result;
24782478
const MYSQL_FIELD *mysql_field = {0};
24792479
char buf[512];
24802480
int len;
24812481

2482-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &result, &field) == FAILURE) {
2482+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri", &result, &field) == FAILURE) {
24832483
return;
24842484
}
24852485

Diff for: ext/mysql/php_mysql_structs.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,18 @@ PHP_FUNCTION(mysql_set_charset);
112112

113113
ZEND_BEGIN_MODULE_GLOBALS(mysql)
114114
zend_resource *default_link;
115-
long num_links,num_persistent;
116-
long max_links,max_persistent;
117-
long allow_persistent;
118-
long default_port;
115+
php_int_t num_links,num_persistent;
116+
php_int_t max_links,max_persistent;
117+
php_int_t allow_persistent;
118+
php_int_t default_port;
119119
char *default_host, *default_user, *default_password;
120120
char *default_socket;
121121
char *connect_error;
122-
long connect_errno;
123-
long connect_timeout;
124-
long result_allocated;
125-
long trace_mode;
126-
long allow_local_infile;
122+
php_int_t connect_errno;
123+
php_int_t connect_timeout;
124+
php_int_t result_allocated;
125+
php_int_t trace_mode;
126+
php_int_t allow_local_infile;
127127
ZEND_END_MODULE_GLOBALS(mysql)
128128

129129
#ifdef ZTS

Diff for: ext/mysqlnd/mysqlnd.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ mysqlnd_switch_to_ssl_if_needed(
440440
MYSQLND_CONN_DATA * conn,
441441
const MYSQLND_PACKET_GREET * const greet_packet,
442442
const MYSQLND_OPTIONS * const options,
443-
unsigned long mysql_flags
443+
php_uint_t mysql_flags
444444
TSRMLS_DC
445445
)
446446
{
@@ -546,7 +546,7 @@ mysqlnd_run_authentication(
546546
const char * const auth_protocol,
547547
unsigned int charset_no,
548548
const MYSQLND_OPTIONS * const options,
549-
unsigned long mysql_flags,
549+
php_uint_t mysql_flags,
550550
zend_bool silent,
551551
zend_bool is_change_user
552552
TSRMLS_DC)
@@ -678,7 +678,7 @@ mysqlnd_connect_run_authentication(
678678
size_t passwd_len,
679679
const MYSQLND_PACKET_GREET * const greet_packet,
680680
const MYSQLND_OPTIONS * const options,
681-
unsigned long mysql_flags
681+
php_uint_t mysql_flags
682682
TSRMLS_DC)
683683
{
684684
enum_func_status ret = FAIL;
@@ -1588,7 +1588,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, sqlstate)(const MYSQLND_CONN_DATA * const conn
15881588

15891589

15901590
/* {{{ mysqlnd_old_escape_string */
1591-
PHPAPI ulong
1591+
PHPAPI php_uint_t
15921592
mysqlnd_old_escape_string(char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC)
15931593
{
15941594
DBG_ENTER("mysqlnd_old_escape_string");
@@ -1622,11 +1622,11 @@ MYSQLND_METHOD(mysqlnd_conn_data, ssl_set)(MYSQLND_CONN_DATA * const conn, const
16221622

16231623

16241624
/* {{{ mysqlnd_conn_data::escape_string */
1625-
static ulong
1625+
static php_uint_t
16261626
MYSQLND_METHOD(mysqlnd_conn_data, escape_string)(MYSQLND_CONN_DATA * const conn, char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC)
16271627
{
16281628
size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, escape_string);
1629-
ulong ret = FAIL;
1629+
php_uint_t ret = FAIL;
16301630
DBG_ENTER("mysqlnd_conn_data::escape_string");
16311631
DBG_INF_FMT("conn=%llu", conn->thread_id);
16321632

@@ -2114,23 +2114,23 @@ MYSQLND_METHOD(mysqlnd_conn_data, thread_id)(const MYSQLND_CONN_DATA * const con
21142114

21152115

21162116
/* {{{ mysqlnd_conn_data::get_server_version */
2117-
static unsigned long
2117+
static php_uint_t
21182118
MYSQLND_METHOD(mysqlnd_conn_data, get_server_version)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC)
21192119
{
2120-
long major, minor, patch;
2120+
php_int_t major, minor, patch;
21212121
char *p;
21222122

21232123
if (!(p = conn->server_version)) {
21242124
return 0;
21252125
}
21262126

2127-
major = strtol(p, &p, 10);
2127+
major = ZEND_STRTOI(p, &p, 10);
21282128
p += 1; /* consume the dot */
2129-
minor = strtol(p, &p, 10);
2129+
minor = ZEND_STRTOI(p, &p, 10);
21302130
p += 1; /* consume the dot */
2131-
patch = strtol(p, &p, 10);
2131+
patch = ZEND_STRTOI(p, &p, 10);
21322132

2133-
return (unsigned long)(major * 10000L + (unsigned long)(minor * 100L + patch));
2133+
return (php_uint_t)(major * Z_I(10000) + (php_uint_t)(minor * Z_I(100) + patch));
21342134
}
21352135
/* }}} */
21362136

Diff for: ext/mysqlnd/mysqlnd.h

+12-12
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void mysqlnd_local_infile_default(MYSQLND_CONN_DATA * conn);
219219
#define mysqlnd_escape_string(newstr, escapestr, escapestr_len) \
220220
mysqlnd_old_escape_string((newstr), (escapestr), (escapestr_len) TSRMLS_CC)
221221

222-
PHPAPI ulong mysqlnd_old_escape_string(char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC);
222+
PHPAPI php_uint_t mysqlnd_old_escape_string(char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC);
223223

224224

225225
/* PS */
@@ -270,17 +270,17 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqlnd)
270270
char * trace_alloc_settings; /* The actual string */
271271
MYSQLND_DEBUG * dbg; /* The DBG object for standard tracing */
272272
MYSQLND_DEBUG * trace_alloc; /* The DBG object for allocation tracing */
273-
long net_cmd_buffer_size;
274-
long net_read_buffer_size;
275-
long log_mask;
276-
long net_read_timeout;
277-
long mempool_default_size;
278-
long debug_emalloc_fail_threshold;
279-
long debug_ecalloc_fail_threshold;
280-
long debug_erealloc_fail_threshold;
281-
long debug_malloc_fail_threshold;
282-
long debug_calloc_fail_threshold;
283-
long debug_realloc_fail_threshold;
273+
php_int_t net_cmd_buffer_size;
274+
php_int_t net_read_buffer_size;
275+
php_int_t log_mask;
276+
php_int_t net_read_timeout;
277+
php_int_t mempool_default_size;
278+
php_int_t debug_emalloc_fail_threshold;
279+
php_int_t debug_ecalloc_fail_threshold;
280+
php_int_t debug_erealloc_fail_threshold;
281+
php_int_t debug_malloc_fail_threshold;
282+
php_int_t debug_calloc_fail_threshold;
283+
php_int_t debug_realloc_fail_threshold;
284284
char * sha256_server_public_key;
285285
zend_bool fetch_data_copy;
286286
ZEND_END_MODULE_GLOBALS(mysqlnd)

Diff for: ext/mysqlnd/mysqlnd_alloc.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D)
7979
void *ret;
8080
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
8181
#if PHP_DEBUG
82-
long * threshold = &MYSQLND_G(debug_emalloc_fail_threshold);
82+
php_int_t * threshold = &MYSQLND_G(debug_emalloc_fail_threshold);
8383
#endif
8484
TRACE_ALLOC_ENTER(mysqlnd_emalloc_name);
8585

@@ -119,7 +119,7 @@ void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D)
119119
void *ret;
120120
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
121121
#if PHP_DEBUG
122-
long * threshold = persistent? &MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold);
122+
php_int_t * threshold = persistent? &MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold);
123123
#endif
124124
TRACE_ALLOC_ENTER(mysqlnd_pemalloc_name);
125125

@@ -162,7 +162,7 @@ void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
162162
void *ret;
163163
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
164164
#if PHP_DEBUG
165-
long * threshold = &MYSQLND_G(debug_ecalloc_fail_threshold);
165+
php_int_t * threshold = &MYSQLND_G(debug_ecalloc_fail_threshold);
166166
#endif
167167
TRACE_ALLOC_ENTER(mysqlnd_ecalloc_name);
168168

@@ -203,7 +203,7 @@ void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent M
203203
void *ret;
204204
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
205205
#if PHP_DEBUG
206-
long * threshold = persistent? &MYSQLND_G(debug_calloc_fail_threshold):&MYSQLND_G(debug_ecalloc_fail_threshold);
206+
php_int_t * threshold = persistent? &MYSQLND_G(debug_calloc_fail_threshold):&MYSQLND_G(debug_ecalloc_fail_threshold);
207207
#endif
208208
TRACE_ALLOC_ENTER(mysqlnd_pecalloc_name);
209209
#if PHP_DEBUG
@@ -246,7 +246,7 @@ void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D)
246246
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
247247
size_t old_size = collect_memory_statistics && ptr? *(size_t *) (((char*)ptr) - sizeof(size_t)) : 0;
248248
#if PHP_DEBUG
249-
long * threshold = &MYSQLND_G(debug_erealloc_fail_threshold);
249+
php_int_t * threshold = &MYSQLND_G(debug_erealloc_fail_threshold);
250250
#endif
251251
TRACE_ALLOC_ENTER(mysqlnd_erealloc_name);
252252

@@ -287,7 +287,7 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL
287287
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
288288
size_t old_size = collect_memory_statistics && ptr? *(size_t *) (((char*)ptr) - sizeof(size_t)) : 0;
289289
#if PHP_DEBUG
290-
long * threshold = persistent? &MYSQLND_G(debug_realloc_fail_threshold):&MYSQLND_G(debug_erealloc_fail_threshold);
290+
php_int_t * threshold = persistent? &MYSQLND_G(debug_realloc_fail_threshold):&MYSQLND_G(debug_erealloc_fail_threshold);
291291
#endif
292292
TRACE_ALLOC_ENTER(mysqlnd_perealloc_name);
293293

@@ -393,7 +393,7 @@ void * _mysqlnd_malloc(size_t size MYSQLND_MEM_D)
393393
void *ret;
394394
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
395395
#if PHP_DEBUG
396-
long * threshold = &MYSQLND_G(debug_malloc_fail_threshold);
396+
php_int_t * threshold = &MYSQLND_G(debug_malloc_fail_threshold);
397397
#endif
398398
TRACE_ALLOC_ENTER(mysqlnd_malloc_name);
399399

@@ -432,7 +432,7 @@ void * _mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
432432
void *ret;
433433
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
434434
#if PHP_DEBUG
435-
long * threshold = &MYSQLND_G(debug_calloc_fail_threshold);
435+
php_int_t * threshold = &MYSQLND_G(debug_calloc_fail_threshold);
436436
#endif
437437
TRACE_ALLOC_ENTER(mysqlnd_calloc_name);
438438

@@ -471,7 +471,7 @@ void * _mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D)
471471
void *ret;
472472
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
473473
#if PHP_DEBUG
474-
long * threshold = &MYSQLND_G(debug_realloc_fail_threshold);
474+
php_int_t * threshold = &MYSQLND_G(debug_realloc_fail_threshold);
475475
#endif
476476
TRACE_ALLOC_ENTER(mysqlnd_realloc_name);
477477

Diff for: ext/mysqlnd/mysqlnd_auth.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn,
3737
const char * const db,
3838
const size_t db_len,
3939
const MYSQLND_OPTIONS * const options,
40-
unsigned long mysql_flags,
40+
php_uint_t mysql_flags,
4141
unsigned int server_charset_no,
4242
zend_bool use_full_blown_auth_packet,
4343
const char * const auth_protocol,
@@ -361,7 +361,7 @@ mysqlnd_native_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
361361
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
362362
const MYSQLND_OPTIONS * const options,
363363
const MYSQLND_NET_OPTIONS * const net_options,
364-
unsigned long mysql_flags
364+
php_uint_t mysql_flags
365365
TSRMLS_DC)
366366
{
367367
zend_uchar * ret = NULL;
@@ -421,7 +421,7 @@ mysqlnd_pam_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
421421
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
422422
const MYSQLND_OPTIONS * const options,
423423
const MYSQLND_NET_OPTIONS * const net_options,
424-
unsigned long mysql_flags
424+
php_uint_t mysql_flags
425425
TSRMLS_DC)
426426
{
427427
zend_uchar * ret = NULL;
@@ -571,7 +571,7 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
571571
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
572572
const MYSQLND_OPTIONS * const options,
573573
const MYSQLND_NET_OPTIONS * const net_options,
574-
unsigned long mysql_flags
574+
php_uint_t mysql_flags
575575
TSRMLS_DC)
576576
{
577577
RSA * server_public_key;

0 commit comments

Comments
 (0)