com php-src: basic fixes for ext/pdo: ext/pdo/pdo.c ext/pdo/pdo_dbh.c ext/pdo/pdo_sql_parser.c ext/pd o/pdo_sql_parser.re ext/pdo/pdo_stmt.c
ext/pdo/ph p_pdo.h ext/pdo/php_pdo_driver.h ext/pdo/php_pd o_int.h

From: Date: Tue, 03 Dec 2013 08:24:45 +0000
Subject: com php-src: basic fixes for ext/pdo: ext/pdo/pdo.c ext/pdo/pdo_dbh.c ext/pdo/pdo_sql_parser.c ext/pd o/pdo_sql_parser.re ext/pdo/pdo_stmt.c
ext/pdo/ph p_pdo.h ext/pdo/php_pdo_driver.h ext/pdo/php_pd o_int.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-74217@lists.php.net to get a copy of this message
Commit: da7d62ea8aaf3f6f2d435df43591161e85cfc746 Author: Anatol Belski <ab@php.net> Tue, 3 Dec 2013 09:24:45 +0100 Parents: 2fc14d515e710e8efc9e0492a9ec53da3fc1ba02 Branches: str_size_and_int64 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=da7d62ea8aaf3f6f2d435df43591161e85cfc746 Log: basic fixes for ext/pdo Changed paths: M ext/pdo/pdo.c M ext/pdo/pdo_dbh.c M ext/pdo/pdo_sql_parser.c M ext/pdo/pdo_sql_parser.re M ext/pdo/pdo_stmt.c M ext/pdo/php_pdo.h M ext/pdo/php_pdo_driver.h M ext/pdo/php_pdo_int.h

diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c index 452c27b..4cfca64 100644 --- a/ext/pdo/pdo.c +++ b/ext/pdo/pdo.c @@ -203,7 +203,7 @@ PDO_API void php_pdo_unregister_driver(pdo_driver_t *driver) zend_hash_del(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len); } -pdo_driver_t *pdo_find_driver(const char *name, int namelen) +pdo_driver_t *pdo_find_driver(const char *name, zend_str_size_int namelen) { pdo_driver_t **driver = NULL; @@ -213,7 +213,7 @@ pdo_driver_t *pdo_find_driver(const char *name, int namelen) } PDO_API int php_pdo_parse_data_source(const char *data_source, - unsigned long data_source_len, struct pdo_data_src_parser *parsed, + php_uint_t data_source_len, struct pdo_data_src_parser *parsed, int nparams) { int i, j; @@ -319,7 +319,7 @@ PDO_API char *php_pdo_int64_to_str(pdo_int64_t i64 TSRMLS_DC) char buffer[65]; char outbuf[65] = ""; register char *p; - long long_val; + php_int_t long_val; char *dst = outbuf; if (i64 < 0) { @@ -336,15 +336,15 @@ PDO_API char *php_pdo_int64_to_str(pdo_int64_t i64 TSRMLS_DC) p = &buffer[sizeof(buffer)-1]; *p = '\0'; - while ((pdo_uint64_t)i64 > (pdo_uint64_t)LONG_MAX) { + while ((pdo_uint64_t)i64 > (pdo_uint64_t)PHP_INT_MAX) { pdo_uint64_t quo = (pdo_uint64_t)i64 / (unsigned int)10; unsigned int rem = (unsigned int)(i64 - quo*10U); *--p = digit_vec[rem]; i64 = (pdo_int64_t)quo; } - long_val = (long)i64; + long_val = (php_int_t)i64; while (long_val != 0) { - long quo = long_val / 10; + php_int_t quo = long_val / 10; *--p = digit_vec[(unsigned int)(long_val - quo * 10)]; long_val = quo; } diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 67c6c58..60045d5 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -36,7 +36,7 @@ #include "zend_object_handlers.h" #include "zend_hash.h" -static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_DC); +static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, php_int_t attr, zval *value TSRMLS_DC); void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate, const char *supp TSRMLS_DC) /* {{{ */ { @@ -106,7 +106,7 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC) /* {{{ pdo_error_type *pdo_err = &dbh->error_code; const char *msg = "<<Unknown>>"; char *supp = NULL; - long native_code = 0; + php_int_t native_code = 0; char *message = NULL; zval *info = NULL; @@ -138,7 +138,7 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC) /* {{{ } if (SUCCESS == zend_hash_index_find(Z_ARRVAL_P(info), 2, (void**)&item)) { - supp = estrndup(Z_STRVAL_PP(item), Z_STRLEN_PP(item)); + supp = estrndup(Z_STRVAL_PP(item), Z_STRSIZE_PP(item)); } } } @@ -204,16 +204,16 @@ static PHP_METHOD(PDO, dbh_constructor) pdo_dbh_t *dbh = NULL; zend_bool is_persistent = FALSE; char *data_source; - int data_source_len; + zend_str_size_int data_source_len; char *colon; char *username=NULL, *password=NULL; - int usernamelen, passwordlen; + zend_str_size_int usernamelen, passwordlen; pdo_driver_t *driver = NULL; zval *options = NULL; char alt_dsn[512]; int call_factory = 1; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!a!", &data_source, &data_source_len, + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|S!S!a!", &data_source, &data_source_len, &username, &usernamelen, &password, &passwordlen, &options)) { ZVAL_NULL(object); return; @@ -281,7 +281,7 @@ static PHP_METHOD(PDO, dbh_constructor) pdo_dbh_t *pdbh = NULL; if (SUCCESS == zend_hash_index_find(Z_ARRVAL_P(options), PDO_ATTR_PERSISTENT, (void**)&v)) { - if (Z_TYPE_PP(v) == IS_STRING && !is_numeric_string(Z_STRVAL_PP(v), Z_STRLEN_PP(v), NULL, NULL, 0) && Z_STRLEN_PP(v) > 0) { + if (Z_TYPE_PP(v) == IS_STRING && !is_numeric_string(Z_STRVAL_PP(v), Z_STRSIZE_PP(v), NULL, NULL, 0) && Z_STRSIZE_PP(v) > 0) { /* user specified key */ plen = spprintf(&hashkey, 0, "PDO:DBH:DSN=%s:%s:%s:%s", data_source, username ? username : "", @@ -405,7 +405,7 @@ options: if (options) { zval **attr_value; char *str_key; - ulong long_key; + php_uint_t long_key; zend_hash_internal_pointer_reset(Z_ARRVAL_P(options)); while (SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(options), (void**)&attr_value) @@ -513,11 +513,11 @@ static PHP_METHOD(PDO, prepare) pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC); pdo_stmt_t *stmt; char *statement; - int statement_len; + zend_str_size_int statement_len; zval *options = NULL, **opt, **item, *ctor_args; zend_class_entry *dbstmt_ce, **pce; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|a", &statement, + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|a", &statement, &statement_len, &options)) { RETURN_FALSE; } @@ -528,7 +528,7 @@ static PHP_METHOD(PDO, prepare) if (ZEND_NUM_ARGS() > 1 && SUCCESS == zend_hash_index_find(Z_ARRVAL_P(options), PDO_ATTR_STATEMENT_CLASS, (void**)&opt)) { if (Z_TYPE_PP(opt) != IS_ARRAY || zend_hash_index_find(Z_ARRVAL_PP(opt), 0, (void**)&item) == FAILURE || Z_TYPE_PP(item) != IS_STRING - || zend_lookup_class(Z_STRVAL_PP(item), Z_STRLEN_PP(item), &pce TSRMLS_CC) == FAILURE + || zend_lookup_class(Z_STRVAL_PP(item), Z_STRSIZE_PP(item), &pce TSRMLS_CC) == FAILURE ) { pdo_raise_impl_error(dbh, NULL, "HY000", "PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); " @@ -707,7 +707,7 @@ static PHP_METHOD(PDO, inTransaction) } /* }}} */ -static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_DC) /* {{{ */ +static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, php_int_t attr, zval *value TSRMLS_DC) /* {{{ */ { #define PDO_LONG_PARAM_CHECK \ @@ -797,7 +797,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D if (Z_TYPE_P(value) != IS_ARRAY || zend_hash_index_find(Z_ARRVAL_P(value), 0, (void**)&item) == FAILURE || Z_TYPE_PP(item) != IS_STRING - || zend_lookup_class(Z_STRVAL_PP(item), Z_STRLEN_PP(item), &pce TSRMLS_CC) == FAILURE + || zend_lookup_class(Z_STRVAL_PP(item), Z_STRSIZE_PP(item), &pce TSRMLS_CC) == FAILURE ) { pdo_raise_impl_error(dbh, NULL, "HY000", "PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); " @@ -868,10 +868,10 @@ fail: static PHP_METHOD(PDO, setAttribute) { pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC); - long attr; + php_int_t attr; zval *value; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz", &attr, &value)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iz", &attr, &value)) { RETURN_FALSE; } @@ -890,9 +890,9 @@ static PHP_METHOD(PDO, setAttribute) static PHP_METHOD(PDO, getAttribute) { pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC); - long attr; + php_int_t attr; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &attr)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &attr)) { RETURN_FALSE; } @@ -955,10 +955,10 @@ static PHP_METHOD(PDO, exec) { pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC); char *statement; - int statement_len; - long ret; + zend_str_size_int statement_len; + php_int_t ret; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &statement, &statement_len)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &statement, &statement_len)) { RETURN_FALSE; } @@ -985,9 +985,9 @@ static PHP_METHOD(PDO, lastInsertId) { pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC); char *name = NULL; - int namelen; + zend_str_size_int namelen; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &name, &namelen)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S!", &name, &namelen)) { RETURN_FALSE; } @@ -997,7 +997,7 @@ static PHP_METHOD(PDO, lastInsertId) pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support lastInsertId()" TSRMLS_CC); RETURN_FALSE; } else { - Z_STRVAL_P(return_value) = dbh->methods->last_id(dbh, name, (unsigned int *)&Z_STRLEN_P(return_value) TSRMLS_CC); + Z_STRVAL_P(return_value) = dbh->methods->last_id(dbh, name, &Z_STRSIZE_P(return_value) TSRMLS_CC); if (!Z_STRVAL_P(return_value)) { PDO_HANDLE_DBH_ERR(); RETURN_FALSE; @@ -1088,7 +1088,7 @@ static PHP_METHOD(PDO, query) pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC); pdo_stmt_t *stmt; char *statement; - int statement_len; + zend_str_size_int statement_len; /* Return a meaningful error when no parameters were passed */ if (!ZEND_NUM_ARGS()) { @@ -1096,7 +1096,7 @@ static PHP_METHOD(PDO, query) RETURN_FALSE; } - if (FAILURE == zend_parse_parameters(1 TSRMLS_CC, "s", &statement, + if (FAILURE == zend_parse_parameters(1 TSRMLS_CC, "S", &statement, &statement_len)) { RETURN_FALSE; } @@ -1164,12 +1164,12 @@ static PHP_METHOD(PDO, quote) { pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC); char *str; - int str_len; - long paramtype = PDO_PARAM_STR; + zend_str_size_int str_len; + php_int_t paramtype = PDO_PARAM_STR; char *qstr; - int qlen; + zend_str_size_int qlen; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len, &paramtype)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|i", &str, &str_len, &paramtype)) { RETURN_FALSE; } @@ -1356,7 +1356,7 @@ static union _zend_function *dbh_method_get( #else zval *object, #endif - char *method_name, int method_len, const zend_literal *key TSRMLS_DC) + char *method_name, zend_str_size_int method_len, const zend_literal *key TSRMLS_DC) { zend_function *fbc = NULL; char *lc_method_name; @@ -1411,13 +1411,13 @@ void pdo_dbh_init(TSRMLS_D) pdo_dbh_object_handlers.get_method = dbh_method_get; pdo_dbh_object_handlers.compare_objects = dbh_compare; - REGISTER_PDO_CLASS_CONST_LONG("PARAM_BOOL", (long)PDO_PARAM_BOOL); - REGISTER_PDO_CLASS_CONST_LONG("PARAM_NULL", (long)PDO_PARAM_NULL); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_BOOL", (php_int_t)PDO_PARAM_BOOL); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_NULL", (php_int_t)PDO_PARAM_NULL); REGISTER_PDO_CLASS_CONST_LONG("PARAM_INT", (long)PDO_PARAM_INT); REGISTER_PDO_CLASS_CONST_LONG("PARAM_STR", (long)PDO_PARAM_STR); REGISTER_PDO_CLASS_CONST_LONG("PARAM_LOB", (long)PDO_PARAM_LOB); - REGISTER_PDO_CLASS_CONST_LONG("PARAM_STMT", (long)PDO_PARAM_STMT); - REGISTER_PDO_CLASS_CONST_LONG("PARAM_INPUT_OUTPUT", (long)PDO_PARAM_INPUT_OUTPUT); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_STMT", (php_int_t)PDO_PARAM_STMT); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_INPUT_OUTPUT", (php_int_t)PDO_PARAM_INPUT_OUTPUT); REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_ALLOC", (long)PDO_PARAM_EVT_ALLOC); REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FREE", (long)PDO_PARAM_EVT_FREE); @@ -1427,16 +1427,16 @@ void pdo_dbh_init(TSRMLS_D) REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_POST", (long)PDO_PARAM_EVT_FETCH_POST); REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_NORMALIZE", (long)PDO_PARAM_EVT_NORMALIZE); - REGISTER_PDO_CLASS_CONST_LONG("FETCH_LAZY", (long)PDO_FETCH_LAZY); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_LAZY", (php_int_t)PDO_FETCH_LAZY); REGISTER_PDO_CLASS_CONST_LONG("FETCH_ASSOC",(long)PDO_FETCH_ASSOC); REGISTER_PDO_CLASS_CONST_LONG("FETCH_NUM", (long)PDO_FETCH_NUM); - REGISTER_PDO_CLASS_CONST_LONG("FETCH_BOTH", (long)PDO_FETCH_BOTH); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_BOTH", (php_int_t)PDO_FETCH_BOTH); REGISTER_PDO_CLASS_CONST_LONG("FETCH_OBJ", (long)PDO_FETCH_OBJ); REGISTER_PDO_CLASS_CONST_LONG("FETCH_BOUND",(long)PDO_FETCH_BOUND); REGISTER_PDO_CLASS_CONST_LONG("FETCH_COLUMN",(long)PDO_FETCH_COLUMN); REGISTER_PDO_CLASS_CONST_LONG("FETCH_CLASS",(long)PDO_FETCH_CLASS); - REGISTER_PDO_CLASS_CONST_LONG("FETCH_INTO", (long)PDO_FETCH_INTO); - REGISTER_PDO_CLASS_CONST_LONG("FETCH_FUNC", (long)PDO_FETCH_FUNC); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_INTO", (php_int_t)PDO_FETCH_INTO); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_FUNC", (php_int_t)PDO_FETCH_FUNC); REGISTER_PDO_CLASS_CONST_LONG("FETCH_GROUP",(long)PDO_FETCH_GROUP); REGISTER_PDO_CLASS_CONST_LONG("FETCH_UNIQUE",(long)PDO_FETCH_UNIQUE); REGISTER_PDO_CLASS_CONST_LONG("FETCH_KEY_PAIR",(long)PDO_FETCH_KEY_PAIR); @@ -1483,15 +1483,15 @@ void pdo_dbh_init(TSRMLS_D) REGISTER_PDO_CLASS_CONST_STRING("ERR_NONE", PDO_ERR_NONE); - REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_NEXT", (long)PDO_FETCH_ORI_NEXT); - REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_PRIOR", (long)PDO_FETCH_ORI_PRIOR); - REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_FIRST", (long)PDO_FETCH_ORI_FIRST); - REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_LAST", (long)PDO_FETCH_ORI_LAST); - REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_ABS", (long)PDO_FETCH_ORI_ABS); - REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_REL", (long)PDO_FETCH_ORI_REL); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_NEXT", (php_int_t)PDO_FETCH_ORI_NEXT); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_PRIOR", (php_int_t)PDO_FETCH_ORI_PRIOR); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_FIRST", (php_int_t)PDO_FETCH_ORI_FIRST); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_LAST", (php_int_t)PDO_FETCH_ORI_LAST); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_ABS", (php_int_t)PDO_FETCH_ORI_ABS); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_REL", (php_int_t)PDO_FETCH_ORI_REL); - REGISTER_PDO_CLASS_CONST_LONG("CURSOR_FWDONLY", (long)PDO_CURSOR_FWDONLY); - REGISTER_PDO_CLASS_CONST_LONG("CURSOR_SCROLL", (long)PDO_CURSOR_SCROLL); + REGISTER_PDO_CLASS_CONST_LONG("CURSOR_FWDONLY", (php_int_t)PDO_CURSOR_FWDONLY); + REGISTER_PDO_CLASS_CONST_LONG("CURSOR_SCROLL", (php_int_t)PDO_CURSOR_SCROLL); #if 0 REGISTER_PDO_CLASS_CONST_LONG("ERR_CANT_MAP", (long)PDO_ERR_CANT_MAP); diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c index 37d8752..f43922f 100644 --- a/ext/pdo/pdo_sql_parser.c +++ b/ext/pdo/pdo_sql_parser.c @@ -426,23 +426,23 @@ yy45: struct placeholder { char *pos; - int len; + zend_str_size_int len; int bindno; - int qlen; /* quoted length of value */ + zend_str_size_int qlen; /* quoted length of value */ char *quoted; /* quoted value */ int freeq; struct placeholder *next; }; -PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, - char **outquery, int *outquery_len TSRMLS_DC) +PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, zend_str_size_int inquery_len, + char **outquery, zend_str_size_int *outquery_len TSRMLS_DC) { Scanner s; char *ptr, *newbuffer; int t; int bindno = 0; int ret = 0; - int newbuffer_len; + zend_str_size_int newbuffer_len; HashTable *params; struct pdo_bound_param_data *param; int query_type = PDO_PLACEHOLDER_NONE; @@ -456,7 +456,7 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, while((t = scan(&s)) != PDO_PARSER_EOI) { if (t == PDO_PARSER_BIND || t == PDO_PARSER_BIND_POS) { if (t == PDO_PARSER_BIND) { - int len = s.cur - s.tok; + ptrdiff_t len = s.cur - s.tok; if ((inquery < (s.cur - len)) && isalnum(*(s.cur - len - 1))) { continue; } @@ -601,7 +601,7 @@ safe: case IS_LONG: case IS_DOUBLE: convert_to_string(&tmp_param); - plc->qlen = Z_STRLEN(tmp_param); + plc->qlen = Z_STRSIZE(tmp_param); plc->quoted = estrdup(Z_STRVAL(tmp_param)); plc->freeq = 1; break; @@ -609,7 +609,7 @@ safe: default: convert_to_string(&tmp_param); if (!stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL(tmp_param), - Z_STRLEN(tmp_param), &plc->quoted, &plc->qlen, + Z_STRSIZE(tmp_param), &plc->quoted, &plc->qlen, param->param_type TSRMLS_CC)) { /* bork */ ret = -1; @@ -622,7 +622,7 @@ safe: } } else { plc->quoted = Z_STRVAL_P(param->parameter); - plc->qlen = Z_STRLEN_P(param->parameter); + plc->qlen = Z_STRSIZE_P(param->parameter); } newbuffer_len += plc->qlen; } @@ -773,7 +773,7 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char bind placeholders are at least 2 characters, so the accommodate their own "'s */ - newbuffer_len += padding * Z_STRLEN_P(param->parameter); + newbuffer_len += padding * Z_STRSIZE_P(param->parameter); } zend_hash_move_forward(params); } @@ -809,16 +809,16 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char /* quote the bind value if necessary */ if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter), - Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen TSRMLS_CC)) + Z_STRSIZE_P(param->parameter), &quotedstr, &quotedstrlen TSRMLS_CC)) { memcpy(ptr, quotedstr, quotedstrlen); ptr += quotedstrlen; *outquery_len += quotedstrlen; efree(quotedstr); } else { - memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRLEN_P(param->parameter)); - ptr += Z_STRLEN_P(param->parameter); - *outquery_len += (Z_STRLEN_P(param->parameter)); + memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRSIZE_P(param->parameter)); + ptr += Z_STRSIZE_P(param->parameter); + *outquery_len += (Z_STRSIZE_P(param->parameter)); } } else { @@ -845,16 +845,16 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char /* quote the bind value if necessary */ if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter), - Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen TSRMLS_CC)) + Z_STRSIZE_P(param->parameter), &quotedstr, &quotedstrlen TSRMLS_CC)) { memcpy(ptr, quotedstr, quotedstrlen); ptr += quotedstrlen; *outquery_len += quotedstrlen; efree(quotedstr); } else { - memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRLEN_P(param->parameter)); - ptr += Z_STRLEN_P(param->parameter); - *outquery_len += (Z_STRLEN_P(param->parameter)); + memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRSIZE_P(param->parameter)); + ptr += Z_STRSIZE_P(param->parameter); + *outquery_len += (Z_STRSIZE_P(param->parameter)); } } else { diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index fa8ef18..e44b36b 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -76,15 +76,15 @@ struct placeholder { struct placeholder *next; }; -PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, - char **outquery, int *outquery_len TSRMLS_DC) +PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, zend_str_size_int inquery_len, + char **outquery, zend_str_size_int *outquery_len TSRMLS_DC) { Scanner s; char *ptr, *newbuffer; - int t; + ptrdiff_t t; int bindno = 0; int ret = 0; - int newbuffer_len; + zend_str_size_int newbuffer_len; HashTable *params; struct pdo_bound_param_data *param; int query_type = PDO_PLACEHOLDER_NONE; diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 04e7182..00fab50 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -446,8 +446,8 @@ static PHP_METHOD(PDOStatement, execute) if (input_params) { struct pdo_bound_param_data param; zval **tmp; - uint str_length; - ulong num_index; + zend_str_size_uint str_length; + php_uint_t num_index; if (stmt->bound_params) { zend_hash_destroy(stmt->bound_params); @@ -547,7 +547,7 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ { struct pdo_column_data *col; char *value = NULL; - unsigned long value_len = 0; + php_uint_t value_len = 0; int caller_frees = 0; int type, new_type; @@ -687,7 +687,7 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ /* }}} */ static int do_fetch_common(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, - long offset, int do_bind TSRMLS_DC) /* {{{ */ + php_int_t offset, int do_bind TSRMLS_DC) /* {{{ */ { if (!stmt->executed) { return 0; @@ -851,7 +851,7 @@ static int do_fetch_opt_finish(pdo_stmt_t *stmt, int free_ctor_agrs TSRMLS_DC) / /* perform a fetch. If do_bind is true, update any bound columns. * If return_value is not null, store values into it according to HOW. */ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, - enum pdo_fetch_type how, enum pdo_fetch_orientation ori, long offset, zval *return_all TSRMLS_DC) /* {{{ */ + enum pdo_fetch_type how, enum pdo_fetch_orientation ori, php_int_t offset, zval *return_all TSRMLS_DC) /* {{{ */ { int flags, idx, old_arg_count = 0; zend_class_entry *ce = NULL, *old_ce = NULL; @@ -951,7 +951,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, fetch_value(stmt, &val, i++, NULL TSRMLS_CC); if (Z_TYPE(val) != IS_NULL) { convert_to_string(&val); - if (zend_lookup_class(Z_STRVAL(val), Z_STRLEN(val), &cep TSRMLS_CC) == FAILURE) { + if (zend_lookup_class(Z_STRVAL(val), Z_STRSIZE(val), &cep TSRMLS_CC) == FAILURE) { stmt->fetch.cls.ce = ZEND_STANDARD_CLASS_DEF_PTR; } else { stmt->fetch.cls.ce = *cep; @@ -1060,7 +1060,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, zend_hash_index_update((return_all ? Z_ARRVAL_P(return_all) : Z_ARRVAL_P(return_value)), Z_LVAL_P(val), &tmp, sizeof(zval *), NULL); } else { convert_to_string(val); - zend_symtable_update((return_all ? Z_ARRVAL_P(return_all) : Z_ARRVAL_P(return_value)), Z_STRVAL_P(val), Z_STRLEN_P(val) + 1, &tmp, sizeof(zval *), NULL); + zend_symtable_update((return_all ? Z_ARRVAL_P(return_all) : Z_ARRVAL_P(return_value)), Z_STRVAL_P(val), Z_STRSIZE_P(val) + 1, &tmp, sizeof(zval *), NULL); } zval_ptr_dtor(&val); return 1; @@ -1134,7 +1134,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, php_unserialize_data_t var_hash; PHP_VAR_UNSERIALIZE_INIT(var_hash); - if (php_var_unserialize(&return_value, (const unsigned char**)&Z_STRVAL_P(val), Z_STRVAL_P(val)+Z_STRLEN_P(val), NULL TSRMLS_CC) == FAILURE) { + if (php_var_unserialize(&return_value, (const unsigned char**)&Z_STRVAL_P(val), Z_STRVAL_P(val)+Z_STRSIZE_P(val), NULL TSRMLS_CC) == FAILURE) { pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize data" TSRMLS_CC); PHP_VAR_UNSERIALIZE_DESTROY(var_hash); return 0; @@ -1146,7 +1146,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, zval_ptr_dtor(&val); pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class" TSRMLS_CC); return 0; - } else if (ce->unserialize(&return_value, ce, (unsigned char *)(Z_TYPE_P(val) == IS_STRING ? Z_STRVAL_P(val) : ""), Z_TYPE_P(val) == IS_STRING ? Z_STRLEN_P(val) : 0, NULL TSRMLS_CC) == FAILURE) { + } else if (ce->unserialize(&return_value, ce, (unsigned char *)(Z_TYPE_P(val) == IS_STRING ? Z_STRVAL_P(val) : ""), Z_TYPE_P(val) == IS_STRING ? Z_STRSIZE_P(val) : 0, NULL TSRMLS_CC) == FAILURE) { zval_ptr_dtor(&val); pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class" TSRMLS_CC); zval_dtor(return_value); @@ -1222,7 +1222,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, if ((flags & PDO_FETCH_UNIQUE) == PDO_FETCH_UNIQUE) { add_assoc_zval(return_all, Z_STRVAL(grp_val), return_value); } else { - if (zend_symtable_find(Z_ARRVAL_P(return_all), Z_STRVAL(grp_val), Z_STRLEN(grp_val)+1, (void**)&pgrp) == FAILURE) { + if (zend_symtable_find(Z_ARRVAL_P(return_all), Z_STRVAL(grp_val), Z_STRSIZE(grp_val)+1, (void**)&pgrp) == FAILURE) { MAKE_STD_ZVAL(grp); array_init(grp); add_assoc_zval(return_all, Z_STRVAL(grp_val), grp); @@ -1240,7 +1240,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, } /* }}} */ -static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, long mode, int fetch_all TSRMLS_DC) /* {{{ */ +static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, php_int_t mode, int fetch_all TSRMLS_DC) /* {{{ */ { int flags = mode & PDO_FETCH_FLAGS; @@ -1303,12 +1303,12 @@ static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, long mode, int fetch_all TSRML Fetches the next row and returns it, or false if there are no more rows */ static PHP_METHOD(PDOStatement, fetch) { - long how = PDO_FETCH_USE_DEFAULT; - long ori = PDO_FETCH_ORI_NEXT; - long off = 0; + php_int_t how = PDO_FETCH_USE_DEFAULT; + php_int_t ori = PDO_FETCH_ORI_NEXT; + php_int_t off = 0; PHP_STMT_GET_OBJ; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lll", &how, + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|iii", &how, &ori, &off)) { RETURN_FALSE; } @@ -1330,18 +1330,18 @@ static PHP_METHOD(PDOStatement, fetch) Fetches the next row and returns it as an object. */ static PHP_METHOD(PDOStatement, fetchObject) { - long how = PDO_FETCH_CLASS; - long ori = PDO_FETCH_ORI_NEXT; - long off = 0; + php_int_t how = PDO_FETCH_CLASS; + php_int_t ori = PDO_FETCH_ORI_NEXT; + php_int_t off = 0; char *class_name = NULL; - int class_name_len; + zend_str_size_int class_name_len; zend_class_entry *old_ce; zval *old_ctor_args, *ctor_args = NULL; int error = 0, old_arg_count; PHP_STMT_GET_OBJ; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!a", &class_name, &class_name_len, &ctor_args)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S!a", &class_name, &class_name_len, &ctor_args)) { RETURN_FALSE; } @@ -1398,10 +1398,10 @@ static PHP_METHOD(PDOStatement, fetchObject) Returns a data of the specified column in the result set. */ static PHP_METHOD(PDOStatement, fetchColumn) { - long col_n = 0; + php_int_t col_n = 0; PHP_STMT_GET_OBJ; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &col_n)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &col_n)) { RETURN_FALSE; } @@ -1420,7 +1420,7 @@ static PHP_METHOD(PDOStatement, fetchColumn) Returns an array of all of the results. */ static PHP_METHOD(PDOStatement, fetchAll) { - long how = PDO_FETCH_USE_DEFAULT; + php_int_t how = PDO_FETCH_USE_DEFAULT; zval *data, *return_all; zval *arg2; zend_class_entry *old_ce; @@ -1428,7 +1428,7 @@ static PHP_METHOD(PDOStatement, fetchAll) int error = 0, flags, old_arg_count; PHP_STMT_GET_OBJ; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lzz", &how, &arg2, &ctor_args)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|izz", &how, &arg2, &ctor_args)) { RETURN_FALSE; } @@ -1466,7 +1466,7 @@ static PHP_METHOD(PDOStatement, fetchAll) error = 1; break; } else { - stmt->fetch.cls.ce = zend_fetch_class(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); + stmt->fetch.cls.ce = zend_fetch_class(Z_STRVAL_P(arg2), Z_STRSIZE_P(arg2), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); if (!stmt->fetch.cls.ce) { pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not find user-specified class" TSRMLS_CC); error = 1; @@ -1582,14 +1582,14 @@ static PHP_METHOD(PDOStatement, fetchAll) static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int is_param) /* {{{ */ { struct pdo_bound_param_data param = {0}; - long param_type = PDO_PARAM_STR; + php_int_t param_type = PDO_PARAM_STR; param.paramno = -1; if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, - "lz|llz!", &param.paramno, &param.parameter, &param_type, &param.max_value_len, + "iz|iiz!", &param.paramno, &param.parameter, &param_type, &param.max_value_len, &param.driver_params)) { - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|llz!", &param.name, + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|iiz!", &param.name, &param.namelen, &param.parameter, &param_type, &param.max_value_len, &param.driver_params)) { return 0; @@ -1621,14 +1621,14 @@ static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, static PHP_METHOD(PDOStatement, bindValue) { struct pdo_bound_param_data param = {0}; - long param_type = PDO_PARAM_STR; + php_int_t param_type = PDO_PARAM_STR; PHP_STMT_GET_OBJ; param.paramno = -1; if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, - "lz/|l", &param.paramno, &param.parameter, &param_type)) { - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/|l", &param.name, + "iz/|i", &param.paramno, &param.parameter, &param_type)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz/|i", &param.name, &param.namelen, &param.parameter, &param_type)) { RETURN_FALSE; } @@ -1740,11 +1740,11 @@ static PHP_METHOD(PDOStatement, errorInfo) Set an attribute */ static PHP_METHOD(PDOStatement, setAttribute) { - long attr; + php_int_t attr; zval *value = NULL; PHP_STMT_GET_OBJ; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz!", &attr, &value)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iz!", &attr, &value)) { RETURN_FALSE; } @@ -1782,10 +1782,10 @@ static int generic_stmt_attr_get(pdo_stmt_t *stmt, zval *return_value, long attr static PHP_METHOD(PDOStatement, getAttribute) { - long attr; + php_int_t attr; PHP_STMT_GET_OBJ; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &attr)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &attr)) { RETURN_FALSE; } @@ -1835,11 +1835,11 @@ static PHP_METHOD(PDOStatement, columnCount) Returns meta data for a numbered column */ static PHP_METHOD(PDOStatement, getColumnMeta) { - long colno; + php_int_t colno; struct pdo_column_data *col; PHP_STMT_GET_OBJ; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &colno)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &colno)) { RETURN_FALSE; } if(colno < 0) { @@ -1875,7 +1875,7 @@ static PHP_METHOD(PDOStatement, getColumnMeta) int pdo_stmt_setup_fetch_mode(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int skip) { - long mode = PDO_FETCH_BOTH; + php_int_t mode = PDO_FETCH_BOTH; int flags = 0, argc = ZEND_NUM_ARGS() - skip; zval ***args; zend_class_entry **cep; @@ -1969,7 +1969,7 @@ int pdo_stmt_setup_fetch_mode(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, in pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "classname must be a string" TSRMLS_CC); } else { retval = zend_lookup_class(Z_STRVAL_PP(args[skip+1]), - Z_STRLEN_PP(args[skip+1]), &cep TSRMLS_CC); + Z_STRSIZE_PP(args[skip+1]), &cep TSRMLS_CC); if (SUCCESS == retval && cep && *cep) { stmt->fetch.cls.ce = *cep; @@ -2169,8 +2169,8 @@ static PHP_METHOD(PDOStatement, debugDumpParams) while (SUCCESS == zend_hash_get_current_data_ex(stmt->bound_params, (void**)&param, &pos)) { char *str; - uint len; - ulong num; + zend_str_size_uint len; + php_uint_t num; int res; res = zend_hash_get_current_key_ex(stmt->bound_params, &str, &len, &num, 0, &pos); @@ -2267,7 +2267,7 @@ static union _zend_function *dbstmt_method_get( #else zval *object, #endif - char *method_name, int method_len, const zend_literal *key TSRMLS_DC) + char *method_name, zend_str_size_int method_len, const zend_literal *key TSRMLS_DC) { zend_function *fbc = NULL; char *lc_method_name; @@ -2339,7 +2339,7 @@ static zend_object_value dbstmt_clone_obj(zval *zobject TSRMLS_DC) } zend_object_handlers pdo_dbstmt_object_handlers; -static int pdo_row_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC); +static int pdo_row_serialize(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC); void pdo_stmt_init(TSRMLS_D) { @@ -2702,7 +2702,7 @@ static union _zend_function *row_method_get( #else zval *object, #endif - char *method_name, int method_len, const zend_literal *key TSRMLS_DC) + char *method_name, zend_str_size_int method_len, const zend_literal *key TSRMLS_DC) { zend_function *fbc; char *lc_method_name; @@ -2742,7 +2742,7 @@ static zend_class_entry *row_get_ce(const zval *object TSRMLS_DC) return pdo_row_ce; } -static int row_get_classname(const zval *object, const char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC) +static int row_get_classname(const zval *object, const char **class_name, zend_str_size_uint *class_name_len, int parent TSRMLS_DC) { if (parent) { return FAILURE; @@ -2805,7 +2805,7 @@ zend_object_value pdo_row_new(zend_class_entry *ce TSRMLS_DC) return retval; } -static int pdo_row_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC) +static int pdo_row_serialize(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "PDORow instances may not be serialized"); return FAILURE; diff --git a/ext/pdo/php_pdo.h b/ext/pdo/php_pdo.h index f8a8ce3..c9fc0f7 100644 --- a/ext/pdo/php_pdo.h +++ b/ext/pdo/php_pdo.h @@ -53,7 +53,7 @@ PHP_MSHUTDOWN_FUNCTION(pdo); PHP_MINFO_FUNCTION(pdo); ZEND_BEGIN_MODULE_GLOBALS(pdo) - long global_value; + php_int_t global_value; ZEND_END_MODULE_GLOBALS(pdo) #ifdef ZTS @@ -63,12 +63,12 @@ ZEND_END_MODULE_GLOBALS(pdo) #endif #define REGISTER_PDO_CLASS_CONST_LONG(const_name, value) \ - zend_declare_class_constant_long(php_pdo_get_dbh_ce(), const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); + zend_declare_class_constant_long(php_pdo_get_dbh_ce(), const_name, sizeof(const_name)-1, (php_int_t)value TSRMLS_CC); #define REGISTER_PDO_CONST_LONG(const_name, value) { \ zend_class_entry **pce; \ if (zend_hash_find(CG(class_table), "pdo", sizeof("pdo"), (void **) &pce) != FAILURE) \ - zend_declare_class_constant_long(*pce, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); \ + zend_declare_class_constant_long(*pce, const_name, sizeof(const_name)-1, (php_int_t)value TSRMLS_CC); \ } \ #define REGISTER_PDO_CLASS_CONST_STRING(const_name, value) \ diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h index ede2d6f..228987a 100644 --- a/ext/pdo/php_pdo_driver.h +++ b/ext/pdo/php_pdo_driver.h @@ -192,7 +192,7 @@ enum pdo_null_handling { }; /* {{{ utils for reading attributes set as driver_options */ -static inline long pdo_attr_lval(zval *options, enum pdo_attribute_type option_name, long defval TSRMLS_DC) +static inline php_int_t pdo_attr_lval(zval *options, enum pdo_attribute_type option_name, php_int_t defval TSRMLS_DC) { zval **v; @@ -208,7 +208,7 @@ static inline char *pdo_attr_strval(zval *options, enum pdo_attribute_type optio if (options && SUCCESS == zend_hash_index_find(Z_ARRVAL_P(options), option_name, (void**)&v)) { convert_to_string_ex(v); - return estrndup(Z_STRVAL_PP(v), Z_STRLEN_PP(v)); + return estrndup(Z_STRVAL_PP(v), Z_STRSIZE_PP(v)); } return defval ? estrdup(defval) : NULL; } @@ -218,8 +218,8 @@ static inline char *pdo_attr_strval(zval *options, enum pdo_attribute_type optio * initialized */ typedef struct { const char *driver_name; - unsigned long driver_name_len; - unsigned long api_version; /* needs to be compatible with PDO */ + php_uint_t driver_name_len; + php_uint_t api_version; /* needs to be compatible with PDO */ #define PDO_DRIVER_HEADER(name) \ #name, sizeof(#name)-1, \ @@ -242,23 +242,23 @@ typedef struct { typedef int (*pdo_dbh_close_func)(pdo_dbh_t *dbh TSRMLS_DC); /* prepare a statement and stash driver specific portion into stmt */ -typedef int (*pdo_dbh_prepare_func)(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC); +typedef int (*pdo_dbh_prepare_func)(pdo_dbh_t *dbh, const char *sql, php_uint_t sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC); /* execute a statement (that does not return a result set) */ -typedef long (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC); +typedef php_int_t (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const char *sql, php_uint_t sql_len TSRMLS_DC); /* quote a string */ -typedef int (*pdo_dbh_quote_func)(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC); +typedef int (*pdo_dbh_quote_func)(pdo_dbh_t *dbh, const char *unquoted, zend_str_size_int unquotedlen, char **quoted, zend_str_size_int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC); /* transaction related */ typedef int (*pdo_dbh_txn_func)(pdo_dbh_t *dbh TSRMLS_DC); /* setting of attributes */ -typedef int (*pdo_dbh_set_attr_func)(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC); +typedef int (*pdo_dbh_set_attr_func)(pdo_dbh_t *dbh, php_int_t attr, zval *val TSRMLS_DC); /* return last insert id. NULL indicates error condition, otherwise, the return value * MUST be an emalloc'd NULL terminated string. */ -typedef char *(*pdo_dbh_last_id_func)(pdo_dbh_t *dbh, const char *name, unsigned int *len TSRMLS_DC); +typedef char *(*pdo_dbh_last_id_func)(pdo_dbh_t *dbh, const char *name, zend_str_size_uint *len TSRMLS_DC); /* fetch error information. if stmt is not null, fetch information pertaining * to the statement, otherwise fetch global error information. The driver @@ -269,7 +269,7 @@ typedef char *(*pdo_dbh_last_id_func)(pdo_dbh_t *dbh, const char *name, unsigned typedef int (*pdo_dbh_fetch_error_func)(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS_DC); /* fetching of attributes */ -typedef int (*pdo_dbh_get_attr_func)(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC); +typedef int (*pdo_dbh_get_attr_func)(pdo_dbh_t *dbh, php_int_t attr, zval *val TSRMLS_DC); /* checking/pinging persistent connections; return SUCCESS if the connection * is still alive and ready to be used, FAILURE otherwise. @@ -327,7 +327,7 @@ typedef int (*pdo_stmt_execute_func)(pdo_stmt_t *stmt TSRMLS_DC); * more rows. The ori and offset params modify which row should be returned, * if the stmt represents a scrollable cursor */ typedef int (*pdo_stmt_fetch_func)(pdo_stmt_t *stmt, - enum pdo_fetch_orientation ori, long offset TSRMLS_DC); + enum pdo_fetch_orientation ori, php_int_t offset TSRMLS_DC); /* queries information about the type of a column, by index (0 based). * Driver should populate stmt->columns[colno] with appropriate info */ @@ -339,7 +339,7 @@ typedef int (*pdo_stmt_describe_col_func)(pdo_stmt_t *stmt, int colno TSRMLS_DC) * If the driver sets caller_frees, ptr should point to emalloc'd memory * and PDO will free it as soon as it is done using it. */ -typedef int (*pdo_stmt_get_col_data_func)(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len, int *caller_frees TSRMLS_DC); +typedef int (*pdo_stmt_get_col_data_func)(pdo_stmt_t *stmt, int colno, char **ptr, php_uint_t *len, int *caller_frees TSRMLS_DC); /* hook for bound params */ enum pdo_param_event { @@ -355,10 +355,10 @@ enum pdo_param_event { typedef int (*pdo_stmt_param_hook_func)(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo_param_event event_type TSRMLS_DC); /* setting of attributes */ -typedef int (*pdo_stmt_set_attr_func)(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC); +typedef int (*pdo_stmt_set_attr_func)(pdo_stmt_t *stmt, php_int_t attr, zval *val TSRMLS_DC); /* fetching of attributes */ -typedef int (*pdo_stmt_get_attr_func)(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC); +typedef int (*pdo_stmt_get_attr_func)(pdo_stmt_t *stmt, php_int_t attr, zval *val TSRMLS_DC); /* retrieves meta data for a numbered column. * Returns SUCCESS/FAILURE. @@ -388,7 +388,7 @@ typedef int (*pdo_stmt_get_attr_func)(pdo_stmt_t *stmt, long attr, zval *val TSR * or * 'flags' => array('not_null', 'mysql:some_flag'); // to add data to an existing key */ -typedef int (*pdo_stmt_get_column_meta_func)(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC); +typedef int (*pdo_stmt_get_column_meta_func)(pdo_stmt_t *stmt, php_int_t colno, zval *return_value TSRMLS_DC); /* advances the statement to the next rowset of the batch. * If it returns 1, PDO will tear down its idea of columns @@ -475,7 +475,7 @@ struct _pdo_dbh_t { /* data source string used to open this handle */ const char *data_source; - unsigned long data_source_len; + php_uint_t data_source_len; /* the global error code. */ pdo_error_type error_code; @@ -486,7 +486,7 @@ struct _pdo_dbh_t { /* persistent hash key associated with this handle */ const char *persistent_id; - int persistent_id_len; + zend_str_size_int persistent_id_len; unsigned int refcount; /* driver specific "class" methods for the dbh and stmt */ @@ -513,9 +513,9 @@ struct _pdo_dbh_t { struct pdo_column_data { char *name; int namelen; - unsigned long maxlen; + php_uint_t maxlen; enum pdo_param_type param_type; - unsigned long precision; + php_uint_t precision; /* don't touch this unless your name is dbdo */ void *dbdo_data; @@ -523,11 +523,11 @@ struct pdo_column_data { /* describes a bound parameter */ struct pdo_bound_param_data { - long paramno; /* if -1, then it has a name, and we don't know the index *yet* */ + php_int_t paramno; /* if -1, then it has a name, and we don't know the index *yet* */ char *name; - int namelen; + zend_str_size_int namelen; - long max_value_len; /* as a hint for pre-allocation */ + php_int_t max_value_len; /* as a hint for pre-allocation */ zval *parameter; /* the variable itself */ enum pdo_param_type param_type; /* desired or suggested type */ @@ -583,15 +583,15 @@ struct _pdo_stmt_t { HashTable *bound_columns; /* not always meaningful */ - long row_count; + php_int_t row_count; /* used to hold the statement's current query */ char *query_string; - int query_stringlen; + zend_str_size_int query_stringlen; /* the copy of the query with expanded binds ONLY for emulated-prepare drivers */ char *active_query_string; - int active_query_stringlen; + zend_str_size_int active_query_stringlen; /* the cursor specific error code. */ pdo_error_type error_code; @@ -599,7 +599,7 @@ struct _pdo_stmt_t { /* for lazy fetches, we always return the same lazy object handle. * Let's keep it here. */ zval lazy_object_ref; - unsigned long refcount; + php_uint_t refcount; /* defaults for fetches */ enum pdo_fetch_type default_fetch_type; @@ -643,14 +643,14 @@ struct pdo_data_src_parser { }; PDO_API int php_pdo_parse_data_source(const char *data_source, - unsigned long data_source_len, struct pdo_data_src_parser *parsed, + php_uint_t data_source_len, struct pdo_data_src_parser *parsed, int nparams); PDO_API zend_class_entry *php_pdo_get_dbh_ce(void); PDO_API zend_class_entry *php_pdo_get_exception(void); -PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, - char **outquery, int *outquery_len TSRMLS_DC); +PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, zend_str_size_int inquery_len, + char **outquery, zend_str_size_int *outquery_len TSRMLS_DC); PDO_API void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate, const char *supp TSRMLS_DC); diff --git a/ext/pdo/php_pdo_int.h b/ext/pdo/php_pdo_int.h index 59dbaf9..5863928 100644 --- a/ext/pdo/php_pdo_int.h +++ b/ext/pdo/php_pdo_int.h @@ -55,7 +55,7 @@ extern zend_object_handlers pdo_row_object_handlers; zend_object_iterator *php_pdo_dbstmt_iter_get(zend_class_entry *ce, zval *object TSRMLS_DC); -extern pdo_driver_t *pdo_find_driver(const char *name, int namelen); +extern pdo_driver_t *pdo_find_driver(const char *name, zend_str_size_int namelen); int pdo_sqlstate_init_error_table(void); void pdo_sqlstate_fini_error_table(void);
« previous php.cvs (#74217) next »