]> granicus.if.org Git - php/commitdiff
size_t cleanup for PDO
authorStanislav Malyshev <stas@php.net>
Mon, 26 Jan 2015 21:53:16 +0000 (13:53 -0800)
committerStanislav Malyshev <stas@php.net>
Tue, 27 Jan 2015 00:16:02 +0000 (16:16 -0800)
12 files changed:
UPGRADING.INTERNALS
ext/pdo/pdo_dbh.c
ext/pdo/pdo_sql_parser.c
ext/pdo/php_pdo_driver.h
ext/pdo_dblib/dblib_driver.c
ext/pdo_firebird/firebird_driver.c
ext/pdo_mysql/mysql_driver.c
ext/pdo_mysql/mysql_statement.c
ext/pdo_oci/oci_driver.c
ext/pdo_odbc/odbc_driver.c
ext/pdo_pgsql/pgsql_driver.c
ext/pdo_sqlite/sqlite_driver.c

index 426288d3c508e7d82e0e501b81825bbdc5b7ea27..ac0ada47c7abb3171ea0ead9150b7376cc199281 100644 (file)
@@ -16,6 +16,7 @@ PHP 7.0 INTERNALS UPGRADE NOTES
   o. Updated final class modifier
   p. TSRM changes
   q. gc_collect_cycles() is now hookable
+  r. PDO uses size_t for lengths
 
 2. Build system changes
   a. Unix build system changes
@@ -176,6 +177,9 @@ PHP 7.0 INTERNALS UPGRADE NOTES
      implementation has been renamed to zend_gc_collect_cycles(), and is
      exported with ZEND_API.
 
+  r. In accordance with general use of size_t as string length, all PDO API
+     functions now use size_t for string length.
+
 
 ========================
 2. Build system changes
index 5d1a2ff2d2d7f755b5f12aa8348dd3772d9c77fb..1e282d0b437602f0ac278e510c8de912616b2f9c 100644 (file)
@@ -962,9 +962,9 @@ static PHP_METHOD(PDO, lastInsertId)
                pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support lastInsertId()");
                RETURN_FALSE;
        } else {
-               int id_len;
+               size_t id_len;
                char *id;
-               id = dbh->methods->last_id(dbh, name, (unsigned int *)&id_len);
+               id = dbh->methods->last_id(dbh, name, &id_len);
                if (!id) {
                        PDO_HANDLE_DBH_ERR();
                        RETURN_FALSE;
@@ -1136,7 +1136,7 @@ static PHP_METHOD(PDO, quote)
        size_t str_len;
        zend_long paramtype = PDO_PARAM_STR;
        char *qstr;
-       int qlen;
+       size_t qlen;
 
        if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &str, &str_len, &paramtype)) {
                RETURN_FALSE;
index 55320da740276559fc54caba0198b4179afd5bb6..e1acc171e43f20747313f2f75176284f8ef1533f 100644 (file)
@@ -407,9 +407,9 @@ yy45:
 struct placeholder {
        char *pos;
        char *quoted;   /* quoted value */
-       int len;
+       size_t len;
        int bindno;
-       int qlen;               /* quoted length of value */
+       size_t qlen;            /* quoted length of value */
        int freeq;
        struct placeholder *next;
 };
@@ -418,15 +418,15 @@ static void free_param_name(zval *el) {
        efree(Z_PTR_P(el));
 }
 
-PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len,
-       char **outquery, int *outquery_len)
+PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len,
+               char **outquery, size_t *outquery_len)
 {
        Scanner s;
        char *ptr, *newbuffer;
        int t;
        int bindno = 0;
        int ret = 0;
-       int newbuffer_len;
+       size_t newbuffer_len;
        HashTable *params;
        struct pdo_bound_param_data *param;
        int query_type = PDO_PLACEHOLDER_NONE;
index 58dcabd060623beb409a354da61f59bf19c1213b..e43bedd399d092d2b2d25f6e84e2fcb667661a91 100644 (file)
@@ -219,8 +219,8 @@ static inline char *pdo_attr_strval(zval *options, enum pdo_attribute_type optio
 /* This structure is registered with PDO when a PDO driver extension is
  * initialized */
 typedef struct {
-       const char              *driver_name;
-       zend_ulong      driver_name_len;
+       const char      *driver_name;
+       size_t          driver_name_len;
        zend_ulong      api_version; /* needs to be compatible with PDO */
 
 #define PDO_DRIVER_HEADER(name)        \
@@ -244,13 +244,13 @@ typedef struct {
 typedef int (*pdo_dbh_close_func)(pdo_dbh_t *dbh);
 
 /* prepare a statement and stash driver specific portion into stmt */
-typedef int (*pdo_dbh_prepare_func)(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options);
+typedef int (*pdo_dbh_prepare_func)(pdo_dbh_t *dbh, const char *sql, size_t sql_len, pdo_stmt_t *stmt, zval *driver_options);
 
 /* execute a statement (that does not return a result set) */
-typedef zend_long (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const char *sql, zend_long sql_len);
+typedef zend_long (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const char *sql, size_t sql_len);
 
 /* 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);
+typedef int (*pdo_dbh_quote_func)(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype);
 
 /* transaction related */
 typedef int (*pdo_dbh_txn_func)(pdo_dbh_t *dbh);
@@ -260,7 +260,7 @@ typedef int (*pdo_dbh_set_attr_func)(pdo_dbh_t *dbh, zend_long attr, zval *val);
 
 /* 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);
+typedef char *(*pdo_dbh_last_id_func)(pdo_dbh_t *dbh, const char *name, size_t *len);
 
 /* fetch error information.  if stmt is not null, fetch information pertaining
  * to the statement, otherwise fetch global error information.  The driver
@@ -341,7 +341,7 @@ typedef int (*pdo_stmt_describe_col_func)(pdo_stmt_t *stmt, int colno);
  * 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, zend_ulong *len, int *caller_frees);
+typedef int (*pdo_stmt_get_col_data_func)(pdo_stmt_t *stmt, int colno, char **ptr, size_t *len, int *caller_frees);
 
 /* hook for bound params */
 enum pdo_param_event {
@@ -469,7 +469,7 @@ struct _pdo_dbh_t {
 
        /* data source string used to open this handle */
        const char *data_source;
-       zend_ulong data_source_len;
+       size_t data_source_len;
 
        /* the global error code. */
        pdo_error_type error_code;
@@ -480,7 +480,7 @@ struct _pdo_dbh_t {
 
        /* persistent hash key associated with this handle */
        const char *persistent_id;
-       int persistent_id_len;
+       size_t persistent_id_len;
        unsigned int refcount;
 
        /* driver specific "class" methods for the dbh and stmt */
@@ -528,10 +528,10 @@ static inline pdo_dbh_object_t *php_pdo_dbh_fetch_object(zend_object *obj) {
 /* describes a column */
 struct pdo_column_data {
        char *name;
-       zend_ulong maxlen;
+       size_t maxlen;
        zend_ulong precision;
        enum pdo_param_type param_type;
-       int namelen;
+       size_t namelen;
 
        /* don't touch this unless your name is dbdo */
        void *dbdo_data;
@@ -598,11 +598,11 @@ struct _pdo_stmt_t {
 
        /* used to hold the statement's current query */
        char *query_string;
-       int query_stringlen;
+       size_t query_stringlen;
 
        /* the copy of the query with expanded binds ONLY for emulated-prepare drivers */
        char *active_query_string;
-       int active_query_stringlen;
+       size_t active_query_stringlen;
 
        /* the cursor specific error code. */
        pdo_error_type error_code;
@@ -678,8 +678,8 @@ PDO_API int php_pdo_parse_data_source(const char *data_source,
 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);
+PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len,
+       char **outquery, size_t *outquery_len);
 
 PDO_API void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt,
        const char *sqlstate, const char *supp);
index e6bd19f4e93f0a7456d778eaba60a67eaee00710..b3014a9fc00f63989bbc6b6d2e0a79e34c1f53e6 100644 (file)
@@ -92,7 +92,7 @@ static int dblib_handle_closer(pdo_dbh_t *dbh)
        return 0;
 }
 
-static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options)
+static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len, pdo_stmt_t *stmt, zval *driver_options)
 {
        pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
        pdo_dblib_stmt *S = ecalloc(1, sizeof(*S));
@@ -106,7 +106,7 @@ static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_
        return 1;
 }
 
-static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len)
+static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_len)
 {
        pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
        RETCODE ret, resret;
@@ -142,7 +142,7 @@ static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sq
        return DBCOUNT(H->link);
 }
 
-static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype)
+static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype)
 {
 
        int useBinaryEncoding = 0;
@@ -230,7 +230,7 @@ static int dblib_handle_rollback(pdo_dbh_t *dbh)
        return pdo_dblib_transaction_cmd("ROLLBACK TRANSACTION", dbh);
 }
 
-char *dblib_handle_last_id(pdo_dbh_t *dbh, const char *name, unsigned int *len)
+char *dblib_handle_last_id(pdo_dbh_t *dbh, const char *name, size_t *len)
 {
        pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
 
index 100dbb40d89e8229f12923a57ab6ed5199464c90..4bba4b6b1f66faa25d401da633e0dd4f58ba1082 100644 (file)
@@ -31,7 +31,7 @@
 #include "php_pdo_firebird.h"
 #include "php_pdo_firebird_int.h"
 
-static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, zend_long, XSQLDA*, isc_stmt_handle*,
+static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, size_t, XSQLDA*, isc_stmt_handle*,
        HashTable*);
 
 /* map driver specific error message to PDO error */
@@ -130,7 +130,7 @@ static int firebird_handle_closer(pdo_dbh_t *dbh) /* {{{ */
 /* }}} */
 
 /* called by PDO to prepare an SQL query */
-static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, /* {{{ */
+static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len, /* {{{ */
        pdo_stmt_t *stmt, zval *driver_options)
 {
        pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
@@ -216,7 +216,7 @@ static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long s
 /* }}} */
 
 /* called by PDO to execute a statement that doesn't produce a result set */
-static zend_long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len) /* {{{ */
+static zend_long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_len) /* {{{ */
 {
        pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
        isc_stmt_handle stmt = NULL;
@@ -270,8 +270,8 @@ static zend_long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long
 /* }}} */
 
 /* called by the PDO SQL parser to add quotes to values that are copied into SQL */
-static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, /* {{{ */
-       char **quoted, int *quotedlen, enum pdo_param_type paramtype)
+static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, /* {{{ */
+       char **quoted, size_t *quotedlen, enum pdo_param_type paramtype)
 {
        int qcount = 0;
        char const *co, *l, *r;
@@ -389,7 +389,7 @@ static int firebird_handle_rollback(pdo_dbh_t *dbh) /* {{{ */
 /* }}} */
 
 /* used by prepare and exec to allocate a statement handle and prepare the SQL */
-static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, /* {{{ */
+static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, size_t sql_len, /* {{{ */
        XSQLDA *out_sqlda, isc_stmt_handle *s, HashTable *named_params)
 {
        pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
index 467298ef1d27c42dcda2d08950fd78f7dcbd6e8e..4f55d96d00fc18b0fb69187aefc48d3f89d33191 100644 (file)
@@ -161,18 +161,18 @@ static int mysql_handle_closer(pdo_dbh_t *dbh)
 /* }}} */
 
 /* {{{ mysql_handle_preparer */
-static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options)
+static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len, pdo_stmt_t *stmt, zval *driver_options)
 {
        pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
        pdo_mysql_stmt *S = ecalloc(1, sizeof(pdo_mysql_stmt));
        char *nsql = NULL;
-       int nsql_len = 0;
+       size_t nsql_len = 0;
        int ret;
        int server_version;
 
        PDO_DBG_ENTER("mysql_handle_preparer");
        PDO_DBG_INF_FMT("dbh=%p", dbh);
-       PDO_DBG_INF_FMT("sql=%.*s", sql_len, sql);
+       PDO_DBG_INF_FMT("sql=%.*s", (int)sql_len, sql);
 
        S->H = H;
        stmt->driver_data = S;
@@ -253,12 +253,12 @@ end:
 /* }}} */
 
 /* {{{ mysql_handle_doer */
-static zend_long mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len)
+static zend_long mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_len)
 {
        pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
        PDO_DBG_ENTER("mysql_handle_doer");
        PDO_DBG_INF_FMT("dbh=%p", dbh);
-       PDO_DBG_INF_FMT("sql=%.*s", sql_len, sql);
+       PDO_DBG_INF_FMT("sql=%.*s", (int)sql_len, sql);
 
        if (mysql_real_query(H->server, sql, sql_len)) {
                pdo_mysql_error(dbh);
@@ -288,7 +288,7 @@ static zend_long mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sq
 /* }}} */
 
 /* {{{ pdo_mysql_last_insert_id */
-static char *pdo_mysql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned int *len)
+static char *pdo_mysql_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t *len)
 {
        pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
        char *id = php_pdo_int64_to_str(mysql_insert_id(H->server));
@@ -299,17 +299,17 @@ static char *pdo_mysql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned
 /* }}} */
 
 /* {{{ mysql_handle_quoter */
-static int mysql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype )
+static int mysql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype )
 {
        pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
        PDO_DBG_ENTER("mysql_handle_quoter");
        PDO_DBG_INF_FMT("dbh=%p", dbh);
-       PDO_DBG_INF_FMT("unquoted=%.*s", unquotedlen, unquoted);
+       PDO_DBG_INF_FMT("unquoted=%.*s", (int)unquotedlen, unquoted);
        *quoted = safe_emalloc(2, unquotedlen, 3);
        *quotedlen = mysql_real_escape_string(H->server, *quoted + 1, unquoted, unquotedlen);
        (*quoted)[0] =(*quoted)[++*quotedlen] = '\'';
        (*quoted)[++*quotedlen] = '\0';
-       PDO_DBG_INF_FMT("quoted=%.*s", *quotedlen, *quoted);
+       PDO_DBG_INF_FMT("quoted=%.*s", (int)*quotedlen, *quoted);
        PDO_DBG_RETURN(1);
 }
 /* }}} */
@@ -559,8 +559,8 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
 #endif
                ;
 #if defined(PDO_USE_MYSQLND)
-       int dbname_len = 0;
-       int password_len = 0;
+       size_t dbname_len = 0;
+       size_t password_len = 0;
 #endif
 
 #ifdef CLIENT_MULTI_STATEMENTS
index 40d6fd032bc26e174e927e70ee237648a5dce53d..56728ed92df8fcab1c3f6050aeee9782d1c32fef 100644 (file)
@@ -722,7 +722,7 @@ static int pdo_mysql_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
 }
 /* }}} */
 
-static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, zend_ulong *len, int *caller_frees) /* {{{ */
+static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, size_t *len, int *caller_frees) /* {{{ */
 {
        pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
 
index b98fb22cb7fb20dbda200154f5db2cc84ef595d2..53edee0d33ee0e89eb71955d4ce52328957e4b96 100644 (file)
@@ -248,13 +248,13 @@ static int oci_handle_closer(pdo_dbh_t *dbh) /* {{{ */
 }
 /* }}} */
 
-static int oci_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options) /* {{{ */
+static int oci_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len, pdo_stmt_t *stmt, zval *driver_options) /* {{{ */
 {
        pdo_oci_db_handle *H = (pdo_oci_db_handle *)dbh->driver_data;
        pdo_oci_stmt *S = ecalloc(1, sizeof(*S));
        ub4 prefetch;
        char *nsql = NULL;
-       int nsql_len = 0;
+       size_t nsql_len = 0;
        int ret;
 
 #if HAVE_OCISTMTFETCH2
@@ -324,7 +324,7 @@ static int oci_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pd
 }
 /* }}} */
 
-static long oci_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len) /* {{{ */
+static long oci_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_len) /* {{{ */
 {
        pdo_oci_db_handle *H = (pdo_oci_db_handle *)dbh->driver_data;
        OCIStmt         *stmt;
@@ -368,7 +368,7 @@ static long oci_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len) /* {{
 }
 /* }}} */
 
-static int oci_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype ) /* {{{ */
+static int oci_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype ) /* {{{ */
 {
        int qcount = 0;
        char const *cu, *l, *r;
index e47db9fa1a00d333d1ffd627be15af477e0be9eb..54440d0068d782f6db8d7f22d3c48b4a0c72da24 100644 (file)
@@ -142,7 +142,7 @@ static int odbc_handle_closer(pdo_dbh_t *dbh)
        return 0;
 }
 
-static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options)
+static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len, pdo_stmt_t *stmt, zval *driver_options)
 {
        RETCODE rc;
        pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
@@ -150,7 +150,7 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_l
        enum pdo_cursor_type cursor_type = PDO_CURSOR_FWDONLY;
        int ret;
        char *nsql = NULL;
-       int nsql_len = 0;
+       size_t nsql_len = 0;
 
        S->H = H;
        S->assume_utf8 = H->assume_utf8;
@@ -220,7 +220,7 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_l
        return 1;
 }
 
-static zend_long odbc_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len)
+static zend_long odbc_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_len)
 {
        pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
        RETCODE rc;
@@ -261,7 +261,7 @@ out:
        return row_count;
 }
 
-static int odbc_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type param_type )
+static int odbc_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type param_type )
 {
        /* pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data; */
        /* TODO: figure it out */
@@ -440,7 +440,7 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
 
        if (strchr(dbh->data_source, ';')) {
                char dsnbuf[1024];
-               short dsnbuflen;
+               SQLSMALLINT dsnbuflen;
 
                use_direct = 1;
 
index a581fecfcfc6d61143a279078f1c08ac6a8616a6..e4e202c9f9e390cdb2f35c2399d072408acfe49f 100644 (file)
@@ -214,14 +214,14 @@ static int pgsql_handle_closer(pdo_dbh_t *dbh) /* {{{ */
 }
 /* }}} */
 
-static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options)
+static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len, pdo_stmt_t *stmt, zval *driver_options)
 {
        pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
        pdo_pgsql_stmt *S = ecalloc(1, sizeof(pdo_pgsql_stmt));
        int scrollable;
        int ret;
        char *nsql = NULL;
-       int nsql_len = 0;
+       size_t nsql_len = 0;
        int emulate = 0;
        int execute_only = 0;
 
@@ -287,7 +287,7 @@ static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_
        return 1;
 }
 
-static zend_long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len)
+static zend_long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_len)
 {
        pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
        PGresult *res;
@@ -316,7 +316,7 @@ static zend_long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sq
        return ret;
 }
 
-static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype)
+static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype)
 {
        unsigned char *escaped;
        pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
@@ -325,8 +325,8 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote
        switch (paramtype) {
                case PDO_PARAM_LOB:
                        /* escapedlen returned by PQescapeBytea() accounts for trailing 0 */
-                       escaped = PQescapeByteaConn(H->server, (unsigned char *)unquoted, (size_t)unquotedlen, &tmp_len);
-                       *quotedlen = (int)tmp_len + 1;
+                       escaped = PQescapeByteaConn(H->server, (unsigned char *)unquoted, unquotedlen, &tmp_len);
+                       *quotedlen = tmp_len + 1;
                        *quoted = emalloc(*quotedlen + 1);
                        memcpy((*quoted)+1, escaped, *quotedlen-2);
                        (*quoted)[0] = '\'';
@@ -337,7 +337,7 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote
                default:
                        *quoted = safe_emalloc(2, unquotedlen, 3);
                        (*quoted)[0] = '\'';
-                       *quotedlen = PQescapeStringConn(H->server, *quoted + 1, unquoted, (size_t)unquotedlen, NULL);
+                       *quotedlen = PQescapeStringConn(H->server, *quoted + 1, unquoted, unquotedlen, NULL);
                        (*quoted)[*quotedlen + 1] = '\'';
                        (*quoted)[*quotedlen + 2] = '\0';
                        *quotedlen += 2;
@@ -345,7 +345,7 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote
        return 1;
 }
 
-static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned int *len)
+static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t *len)
 {
        pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
        char *id = NULL;
@@ -590,12 +590,12 @@ static PHP_METHOD(PDO, pgsqlCopyFromArray)
 
        if (status == PGRES_COPY_IN && pgsql_result) {
                int command_failed = 0;
-               int buffer_len = 0;
+               size_t buffer_len = 0;
                zval *tmp;
 
                PQclear(pgsql_result);
                ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pg_rows), tmp) {
-                       int query_len;
+                       size_t query_len;
                        convert_to_string_ex(tmp);
 
                        if (buffer_len < Z_STRLEN_P(tmp)) {
index 1aa7979cd354defe899edf93bd08891cd22d10f4..decc9dc43845ad6100ef0bb6716970ba7c57f080 100644 (file)
@@ -175,7 +175,7 @@ static int sqlite_handle_closer(pdo_dbh_t *dbh) /* {{{ */
 }
 /* }}} */
 
-static int sqlite_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options)
+static int sqlite_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len, pdo_stmt_t *stmt, zval *driver_options)
 {
        pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
        pdo_sqlite_stmt *S = ecalloc(1, sizeof(pdo_sqlite_stmt));
@@ -203,7 +203,7 @@ static int sqlite_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql
        return 0;
 }
 
-static zend_long sqlite_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len)
+static zend_long sqlite_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_len)
 {
        pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
        char *errmsg = NULL;
@@ -219,7 +219,7 @@ static zend_long sqlite_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long s
        }
 }
 
-static char *pdo_sqlite_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned int *len)
+static char *pdo_sqlite_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t *len)
 {
        pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
        char *id;
@@ -230,7 +230,7 @@ static char *pdo_sqlite_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigne
 }
 
 /* NB: doesn't handle binary strings... use prepared stmts for that */
-static int sqlite_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype )
+static int sqlite_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype )
 {
        *quoted = safe_emalloc(2, unquotedlen, 3);
        sqlite3_snprintf(2*unquotedlen + 3, *quoted, "'%q'", unquoted);