ported from pdo - pgsql, odbc, mysql, firebirt, dblib

This commit is contained in:
Anatol Belski 2014-08-19 19:02:07 +02:00
parent 92269d25a3
commit 4ed156d4df
17 changed files with 129 additions and 124 deletions

View file

@ -93,7 +93,7 @@ static int dblib_handle_closer(pdo_dbh_t *dbh TSRMLS_DC)
return 0; return 0;
} }
static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC) static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{ {
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data; pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
pdo_dblib_stmt *S = ecalloc(1, sizeof(*S)); pdo_dblib_stmt *S = ecalloc(1, sizeof(*S));
@ -107,7 +107,7 @@ static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
return 1; return 1;
} }
static long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC) static php_int_t dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len TSRMLS_DC)
{ {
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data; pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
RETCODE ret, resret; RETCODE ret, resret;

View file

@ -171,7 +171,7 @@ static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
} }
static int pdo_dblib_stmt_fetch(pdo_stmt_t *stmt, static int pdo_dblib_stmt_fetch(pdo_stmt_t *stmt,
enum pdo_fetch_orientation ori, long offset TSRMLS_DC) enum pdo_fetch_orientation ori, php_int_t offset TSRMLS_DC)
{ {
RETCODE ret; RETCODE ret;
@ -213,7 +213,7 @@ static int pdo_dblib_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
} }
static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr,
unsigned long *len, int *caller_frees TSRMLS_DC) php_uint_t *len, int *caller_frees TSRMLS_DC)
{ {
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data; pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
@ -287,7 +287,7 @@ static int pdo_dblib_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
return 1; return 1;
} }
static int pdo_dblib_stmt_get_column_meta(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC) static int pdo_dblib_stmt_get_column_meta(pdo_stmt_t *stmt, php_int_t colno, zval *return_value TSRMLS_DC)
{ {
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data; pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
pdo_dblib_db_handle *H = S->H; pdo_dblib_db_handle *H = S->H;

View file

@ -33,11 +33,11 @@
#include "php_pdo_firebird.h" #include "php_pdo_firebird.h"
#include "php_pdo_firebird_int.h" #include "php_pdo_firebird_int.h"
static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, long, XSQLDA*, isc_stmt_handle*, static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, php_int_t, XSQLDA*, isc_stmt_handle*,
HashTable* TSRMLS_DC); HashTable* TSRMLS_DC);
/* map driver specific error message to PDO error */ /* map driver specific error message to PDO error */
void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC) /* {{{ */ void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, php_int_t line TSRMLS_DC) /* {{{ */
{ {
#if 0 #if 0
pdo_firebird_db_handle *H = stmt ? ((pdo_firebird_stmt *)stmt->driver_data)->H pdo_firebird_db_handle *H = stmt ? ((pdo_firebird_stmt *)stmt->driver_data)->H
@ -132,7 +132,7 @@ static int firebird_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
/* }}} */ /* }}} */
/* called by PDO to prepare an SQL query */ /* called by PDO to prepare an SQL query */
static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, /* {{{ */ static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len, /* {{{ */
pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC) pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{ {
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data; pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
@ -218,7 +218,7 @@ static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_le
/* }}} */ /* }}} */
/* called by PDO to execute a statement that doesn't produce a result set */ /* called by PDO to execute a statement that doesn't produce a result set */
static long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC) /* {{{ */ static php_int_t firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len TSRMLS_DC) /* {{{ */
{ {
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data; pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
isc_stmt_handle stmt = NULL; isc_stmt_handle stmt = NULL;
@ -391,12 +391,12 @@ static int firebird_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
/* }}} */ /* }}} */
/* used by prepare and exec to allocate a statement handle and prepare the SQL */ /* 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, long sql_len, /* {{{ */ static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len, /* {{{ */
XSQLDA *out_sqlda, isc_stmt_handle *s, HashTable *named_params TSRMLS_DC) XSQLDA *out_sqlda, isc_stmt_handle *s, HashTable *named_params TSRMLS_DC)
{ {
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data; pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
char *c, *new_sql, in_quote, in_param, pname[64], *ppname; char *c, *new_sql, in_quote, in_param, pname[64], *ppname;
long l, pindex = -1; php_int_t l, pindex = -1;
/* Firebird allows SQL statements up to 64k, so bail if it doesn't fit */ /* Firebird allows SQL statements up to 64k, so bail if it doesn't fit */
if (sql_len > 65536) { if (sql_len > 65536) {
@ -470,7 +470,7 @@ static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, long sql
/* }}} */ /* }}} */
/* called by PDO to set a driver-specific dbh attribute */ /* called by PDO to set a driver-specific dbh attribute */
static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */ static int firebird_handle_set_attribute(pdo_dbh_t *dbh, php_int_t attr, zval *val TSRMLS_DC) /* {{{ */
{ {
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data; pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
@ -545,7 +545,7 @@ static void firebird_info_cb(void *arg, char const *s) /* {{{ */
/* }}} */ /* }}} */
/* called by PDO to get a driver-specific dbh attribute */ /* called by PDO to get a driver-specific dbh attribute */
static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, php_int_t attr, zval *val TSRMLS_DC) /* {{{ */
{ {
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data; pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
@ -606,7 +606,7 @@ static int pdo_firebird_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data; pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
const ISC_STATUS *s = H->isc_status; const ISC_STATUS *s = H->isc_status;
char buf[400]; char buf[400];
long i = 0, l, sqlcode = isc_sqlcode(s); php_int_t i = 0, l, sqlcode = isc_sqlcode(s);
if (sqlcode) { if (sqlcode) {
add_next_index_int(info, sqlcode); add_next_index_int(info, sqlcode);

View file

@ -88,7 +88,7 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
{ {
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data; pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H; pdo_firebird_db_handle *H = S->H;
unsigned long affected_rows = 0; php_uint_t affected_rows = 0;
static char info_count[] = {isc_info_sql_records}; static char info_count[] = {isc_info_sql_records};
char result[64]; char result[64];
@ -153,7 +153,7 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
/* called by PDO to fetch the next row from a statement */ /* called by PDO to fetch the next row from a statement */
static int firebird_stmt_fetch(pdo_stmt_t *stmt, /* {{{ */ static int firebird_stmt_fetch(pdo_stmt_t *stmt, /* {{{ */
enum pdo_fetch_orientation ori, long offset TSRMLS_DC) enum pdo_fetch_orientation ori, php_int_t offset TSRMLS_DC)
{ {
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data; pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H; pdo_firebird_db_handle *H = S->H;
@ -219,7 +219,7 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{
/* fetch a blob into a fetch buffer */ /* fetch a blob into a fetch buffer */
static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */ static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */
unsigned long *len, ISC_QUAD *blob_id TSRMLS_DC) php_uint_t *len, ISC_QUAD *blob_id TSRMLS_DC)
{ {
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data; pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H; pdo_firebird_db_handle *H = S->H;
@ -263,7 +263,7 @@ static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ *
/* we've found the blob's length, now fetch! */ /* we've found the blob's length, now fetch! */
if (*len) { if (*len) {
unsigned long cur_len; php_uint_t cur_len;
unsigned short seg_len; unsigned short seg_len;
ISC_STATUS stat; ISC_STATUS stat;
@ -296,7 +296,7 @@ fetch_blob_end:
/* }}} */ /* }}} */
static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */
unsigned long *len, int *caller_frees TSRMLS_DC) php_uint_t *len, int *caller_frees TSRMLS_DC)
{ {
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data; pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
XSQLVAR const *var = &S->out_sqlda.sqlvar[colno]; XSQLVAR const *var = &S->out_sqlda.sqlvar[colno];
@ -413,7 +413,7 @@ static int firebird_bind_blob(pdo_stmt_t *stmt, ISC_QUAD *blob_id, zval *param T
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data; pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H; pdo_firebird_db_handle *H = S->H;
isc_blob_handle h = NULL; isc_blob_handle h = NULL;
unsigned long put_cnt = 0, rem_cnt; php_uint_t put_cnt = 0, rem_cnt;
unsigned short chunk_size; unsigned short chunk_size;
int result = 1; int result = 1;
@ -495,7 +495,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
switch (event_type) { switch (event_type) {
char *value; char *value;
unsigned long value_len; php_uint_t value_len;
int caller_frees; int caller_frees;
zval *parameter; zval *parameter;
@ -551,9 +551,9 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
case IS_INT: case IS_INT:
/* keep the allow-NULL flag */ /* keep the allow-NULL flag */
var->sqltype = (sizeof(long) == 8 ? SQL_INT64 : SQL_LONG) | (var->sqltype & 1); var->sqltype = (sizeof(php_int_t) == 8 ? SQL_INT64 : SQL_LONG) | (var->sqltype & 1);
var->sqldata = (void*)&Z_IVAL_P(parameter); var->sqldata = (void*)&Z_IVAL_P(parameter);
var->sqllen = sizeof(long); var->sqllen = sizeof(php_int_t);
break; break;
case IS_DOUBLE: case IS_DOUBLE:
/* keep the allow-NULL flag */ /* keep the allow-NULL flag */
@ -626,7 +626,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
} }
case PDO_PARAM_INT: case PDO_PARAM_INT:
if (value) { if (value) {
ZVAL_INT(parameter, *(long*)value); ZVAL_INT(parameter, *(php_int_t*)value);
break; break;
} }
case PDO_PARAM_EVT_NORMALIZE: case PDO_PARAM_EVT_NORMALIZE:
@ -654,7 +654,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
} }
/* }}} */ /* }}} */
static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC) /* {{{ */ static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, php_int_t attr, zval *val TSRMLS_DC) /* {{{ */
{ {
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data; pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
@ -675,7 +675,7 @@ static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, long attr, zval *val TS
} }
/* }}} */ /* }}} */
static int firebird_stmt_get_attribute(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC) /* {{{ */ static int firebird_stmt_get_attribute(pdo_stmt_t *stmt, php_int_t attr, zval *val TSRMLS_DC) /* {{{ */
{ {
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data; pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;

View file

@ -62,9 +62,9 @@ ZEND_GET_MODULE(pdo_firebird)
PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */ PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
{ {
REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_DATE_FORMAT", (long) PDO_FB_ATTR_DATE_FORMAT); REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_DATE_FORMAT", (php_int_t) PDO_FB_ATTR_DATE_FORMAT);
REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_TIME_FORMAT", (long) PDO_FB_ATTR_TIME_FORMAT); REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_TIME_FORMAT", (php_int_t) PDO_FB_ATTR_TIME_FORMAT);
REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_TIMESTAMP_FORMAT", (long) PDO_FB_ATTR_TIMESTAMP_FORMAT); REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_TIMESTAMP_FORMAT", (php_int_t) PDO_FB_ATTR_TIMESTAMP_FORMAT);
php_pdo_register_driver(&pdo_firebird_driver); php_pdo_register_driver(&pdo_firebird_driver);

View file

@ -35,7 +35,7 @@
#define SHORT_MAX (1 << (8*sizeof(short)-1)) #define SHORT_MAX (1 << (8*sizeof(short)-1))
#if SIZEOF_LONG == 8 #if SIZEOF_ZEND_INT == 8 && !defined(PHP_WIN32)
# define LL_MASK "l" # define LL_MASK "l"
# define LL_LIT(lit) lit ## L # define LL_LIT(lit) lit ## L
#else #else
@ -128,7 +128,7 @@ extern pdo_driver_t pdo_firebird_driver;
extern struct pdo_stmt_methods firebird_stmt_methods; extern struct pdo_stmt_methods firebird_stmt_methods;
void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC); void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, php_int_t line TSRMLS_DC);
enum { enum {
PDO_FB_ATTR_DATE_FORMAT = PDO_ATTR_DRIVER_SPECIFIC, PDO_FB_ATTR_DATE_FORMAT = PDO_ATTR_DRIVER_SPECIFIC,

View file

@ -161,7 +161,7 @@ static int mysql_handle_closer(pdo_dbh_t *dbh TSRMLS_DC)
/* }}} */ /* }}} */
/* {{{ mysql_handle_preparer */ /* {{{ mysql_handle_preparer */
static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC) static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{ {
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data; pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
pdo_mysql_stmt *S = ecalloc(1, sizeof(pdo_mysql_stmt)); pdo_mysql_stmt *S = ecalloc(1, sizeof(pdo_mysql_stmt));
@ -235,7 +235,7 @@ static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
#else #else
S->params = ecalloc(S->num_params, sizeof(MYSQL_BIND)); S->params = ecalloc(S->num_params, sizeof(MYSQL_BIND));
S->in_null = ecalloc(S->num_params, sizeof(my_bool)); S->in_null = ecalloc(S->num_params, sizeof(my_bool));
S->in_length = ecalloc(S->num_params, sizeof(unsigned long)); S->in_length = ecalloc(S->num_params, sizeof(php_uint_t));
#endif #endif
} }
dbh->alloc_own_columns = 1; dbh->alloc_own_columns = 1;
@ -253,7 +253,7 @@ end:
/* }}} */ /* }}} */
/* {{{ mysql_handle_doer */ /* {{{ mysql_handle_doer */
static long mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC) static php_int_t mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len TSRMLS_DC)
{ {
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data; pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
PDO_DBG_ENTER("mysql_handle_doer"); PDO_DBG_ENTER("mysql_handle_doer");
@ -368,7 +368,7 @@ static inline int mysql_handle_autocommit(pdo_dbh_t *dbh TSRMLS_DC)
/* }}} */ /* }}} */
/* {{{ pdo_mysql_set_attribute */ /* {{{ pdo_mysql_set_attribute */
static int pdo_mysql_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) static int pdo_mysql_set_attribute(pdo_dbh_t *dbh, php_int_t attr, zval *val TSRMLS_DC)
{ {
PDO_DBG_ENTER("pdo_mysql_set_attribute"); PDO_DBG_ENTER("pdo_mysql_set_attribute");
PDO_DBG_INF_FMT("dbh=%p", dbh); PDO_DBG_INF_FMT("dbh=%p", dbh);
@ -419,7 +419,7 @@ static int pdo_mysql_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_D
/* }}} */ /* }}} */
/* {{{ pdo_mysql_get_attribute */ /* {{{ pdo_mysql_get_attribute */
static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value TSRMLS_DC) static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, php_int_t attr, zval *return_value TSRMLS_DC)
{ {
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data; pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
@ -596,13 +596,13 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
/* handle MySQL options */ /* handle MySQL options */
if (driver_options) { if (driver_options) {
long connect_timeout = pdo_attr_ival(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC); php_int_t connect_timeout = pdo_attr_ival(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
long local_infile = pdo_attr_ival(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0 TSRMLS_CC); php_int_t local_infile = pdo_attr_ival(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0 TSRMLS_CC);
char *init_cmd = NULL; char *init_cmd = NULL;
#ifndef PDO_USE_MYSQLND #ifndef PDO_USE_MYSQLND
char *default_file = NULL, *default_group = NULL; char *default_file = NULL, *default_group = NULL;
#endif #endif
long compress = 0; php_int_t compress = 0;
char *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, *ssl_capath = NULL, *ssl_cipher = NULL; char *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, *ssl_capath = NULL, *ssl_cipher = NULL;
H->buffered = pdo_attr_ival(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC); H->buffered = pdo_attr_ival(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);
@ -648,7 +648,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
* mysqlnd doesn't support reconnect, thus we don't have "|| defined(PDO_USE_MYSQLND)" * mysqlnd doesn't support reconnect, thus we don't have "|| defined(PDO_USE_MYSQLND)"
*/ */
{ {
long reconnect = 1; php_int_t reconnect = 1;
mysql_options(H->server, MYSQL_OPT_RECONNECT, (const char*)&reconnect); mysql_options(H->server, MYSQL_OPT_RECONNECT, (const char*)&reconnect);
} }
#endif #endif

View file

@ -116,10 +116,10 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
static void pdo_mysql_stmt_set_row_count(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ static void pdo_mysql_stmt_set_row_count(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
{ {
long row_count; php_int_t row_count;
pdo_mysql_stmt *S = stmt->driver_data; pdo_mysql_stmt *S = stmt->driver_data;
row_count = (long) mysql_stmt_affected_rows(S->stmt); row_count = (php_int_t) mysql_stmt_affected_rows(S->stmt);
if (row_count != (long)-1) { if (row_count != (php_int_t)-1) {
stmt->row_count = row_count; stmt->row_count = row_count;
} }
} }
@ -146,12 +146,12 @@ static int pdo_mysql_fill_stmt_from_result(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
PDO_DBG_RETURN(0); PDO_DBG_RETURN(0);
} }
stmt->row_count = (long) mysql_num_rows(S->result); stmt->row_count = (php_int_t) mysql_num_rows(S->result);
stmt->column_count = (int) mysql_num_fields(S->result); stmt->column_count = (int) mysql_num_fields(S->result);
S->fields = mysql_fetch_fields(S->result); S->fields = mysql_fetch_fields(S->result);
} else { } else {
/* this was a DML or DDL query (INSERT, UPDATE, DELETE, ... */ /* this was a DML or DDL query (INSERT, UPDATE, DELETE, ... */
stmt->row_count = (long) row_count; stmt->row_count = (php_int_t) row_count;
} }
PDO_DBG_RETURN(1); PDO_DBG_RETURN(1);
@ -200,7 +200,7 @@ static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt TSRMLS_DC)
stmt->column_count = (int)mysql_num_fields(S->result); stmt->column_count = (int)mysql_num_fields(S->result);
S->bound_result = ecalloc(stmt->column_count, sizeof(MYSQL_BIND)); S->bound_result = ecalloc(stmt->column_count, sizeof(MYSQL_BIND));
S->out_null = ecalloc(stmt->column_count, sizeof(my_bool)); S->out_null = ecalloc(stmt->column_count, sizeof(my_bool));
S->out_length = ecalloc(stmt->column_count, sizeof(unsigned long)); S->out_length = ecalloc(stmt->column_count, sizeof(php_uint_t));
/* summon memory to hold the row */ /* summon memory to hold the row */
for (i = 0; i < stmt->column_count; i++) { for (i = 0; i < stmt->column_count; i++) {
@ -343,7 +343,7 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
pdo_mysql_db_handle *H = S->H; pdo_mysql_db_handle *H = S->H;
#if PDO_USE_MYSQLND #if PDO_USE_MYSQLND
long row_count; php_int_t row_count;
#endif #endif
PDO_DBG_ENTER("pdo_mysql_stmt_next_rowset"); PDO_DBG_ENTER("pdo_mysql_stmt_next_rowset");
PDO_DBG_INF_FMT("stmt=%p", S->stmt); PDO_DBG_INF_FMT("stmt=%p", S->stmt);
@ -393,8 +393,8 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
} }
} }
} }
row_count = (long) mysql_stmt_affected_rows(S->stmt); row_count = (php_int_t) mysql_stmt_affected_rows(S->stmt);
if (row_count != (long)-1) { if (row_count != (php_int_t)-1) {
stmt->row_count = row_count; stmt->row_count = row_count;
} }
PDO_DBG_RETURN(1); PDO_DBG_RETURN(1);
@ -551,9 +551,9 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_VAR_STRING); mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_VAR_STRING);
break; break;
case IS_INT: case IS_INT:
#if SIZEOF_LONG==8 #if SIZEOF_ZEND_INT==8
mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONGLONG); mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONGLONG);
#elif SIZEOF_LONG==4 #elif SIZEOF_ZEND_INT==4
mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONG); mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONG);
#endif /* SIZEOF_LONG */ #endif /* SIZEOF_LONG */
break; break;
@ -608,7 +608,7 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
} }
/* }}} */ /* }}} */
static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, long offset TSRMLS_DC) /* {{{ */ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, php_int_t offset TSRMLS_DC) /* {{{ */
{ {
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
#if PDO_USE_MYSQLND #if PDO_USE_MYSQLND
@ -722,7 +722,7 @@ static int pdo_mysql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{
} }
/* }}} */ /* }}} */
static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len, int *caller_frees TSRMLS_DC) /* {{{ */ static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, php_uint_t *len, int *caller_frees TSRMLS_DC) /* {{{ */
{ {
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
@ -823,7 +823,7 @@ static char *type_to_name_native(int type) /* {{{ */
#undef PDO_MYSQL_NATIVE_TYPE_NAME #undef PDO_MYSQL_NATIVE_TYPE_NAME
} /* }}} */ } /* }}} */
static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC) /* {{{ */ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, php_int_t colno, zval *return_value TSRMLS_DC) /* {{{ */
{ {
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
const MYSQL_FIELD *F; const MYSQL_FIELD *F;

View file

@ -106,25 +106,25 @@ static PHP_MINIT_FUNCTION(pdo_mysql)
{ {
REGISTER_INI_ENTRIES(); REGISTER_INI_ENTRIES();
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_USE_BUFFERED_QUERY", (php_int_t)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_LOCAL_INFILE", (long)PDO_MYSQL_ATTR_LOCAL_INFILE); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_LOCAL_INFILE", (php_int_t)PDO_MYSQL_ATTR_LOCAL_INFILE);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_INIT_COMMAND", (php_int_t)PDO_MYSQL_ATTR_INIT_COMMAND);
#ifndef PDO_USE_MYSQLND #ifndef PDO_USE_MYSQLND
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_MAX_BUFFER_SIZE", (long)PDO_MYSQL_ATTR_MAX_BUFFER_SIZE); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_MAX_BUFFER_SIZE", (php_int_t)PDO_MYSQL_ATTR_MAX_BUFFER_SIZE);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_READ_DEFAULT_FILE", (long)PDO_MYSQL_ATTR_READ_DEFAULT_FILE); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_READ_DEFAULT_FILE", (php_int_t)PDO_MYSQL_ATTR_READ_DEFAULT_FILE);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_READ_DEFAULT_GROUP", (long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_READ_DEFAULT_GROUP", (php_int_t)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP);
#endif #endif
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_COMPRESS", (long)PDO_MYSQL_ATTR_COMPRESS); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_COMPRESS", (php_int_t)PDO_MYSQL_ATTR_COMPRESS);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_DIRECT_QUERY", (long)PDO_MYSQL_ATTR_DIRECT_QUERY); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_DIRECT_QUERY", (php_int_t)PDO_MYSQL_ATTR_DIRECT_QUERY);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_FOUND_ROWS", (long)PDO_MYSQL_ATTR_FOUND_ROWS); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_FOUND_ROWS", (php_int_t)PDO_MYSQL_ATTR_FOUND_ROWS);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_IGNORE_SPACE", (long)PDO_MYSQL_ATTR_IGNORE_SPACE); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_IGNORE_SPACE", (php_int_t)PDO_MYSQL_ATTR_IGNORE_SPACE);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SSL_KEY", (long)PDO_MYSQL_ATTR_SSL_KEY); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SSL_KEY", (php_int_t)PDO_MYSQL_ATTR_SSL_KEY);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SSL_CERT", (long)PDO_MYSQL_ATTR_SSL_CERT); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SSL_CERT", (php_int_t)PDO_MYSQL_ATTR_SSL_CERT);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SSL_CA", (long)PDO_MYSQL_ATTR_SSL_CA); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SSL_CA", (php_int_t)PDO_MYSQL_ATTR_SSL_CA);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SSL_CAPATH", (long)PDO_MYSQL_ATTR_SSL_CAPATH); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SSL_CAPATH", (php_int_t)PDO_MYSQL_ATTR_SSL_CAPATH);
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SSL_CIPHER", (long)PDO_MYSQL_ATTR_SSL_CIPHER); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SSL_CIPHER", (php_int_t)PDO_MYSQL_ATTR_SSL_CIPHER);
#if MYSQL_VERSION_ID > 50605 || defined(PDO_USE_MYSQLND) #if MYSQL_VERSION_ID > 50605 || defined(PDO_USE_MYSQLND)
REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SERVER_PUBLIC_KEY", (long)PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY); REGISTER_PDO_CLASS_CONST_INT("MYSQL_ATTR_SERVER_PUBLIC_KEY", (php_int_t)PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY);
#endif #endif

View file

@ -122,9 +122,9 @@ typedef struct {
const MYSQL_FIELD *fields; const MYSQL_FIELD *fields;
MYSQL_ROW current_data; MYSQL_ROW current_data;
#if PDO_USE_MYSQLND #if PDO_USE_MYSQLND
unsigned long *current_lengths; php_uint_t *current_lengths;
#else #else
long *current_lengths; php_int_t *current_lengths;
#endif #endif
pdo_mysql_error_info einfo; pdo_mysql_error_info einfo;
#if PDO_USE_MYSQLND #if PDO_USE_MYSQLND
@ -136,11 +136,11 @@ typedef struct {
PDO_MYSQL_PARAM_BIND *params; PDO_MYSQL_PARAM_BIND *params;
#ifndef PDO_USE_MYSQLND #ifndef PDO_USE_MYSQLND
my_bool *in_null; my_bool *in_null;
unsigned long *in_length; php_uint_t *in_length;
#endif #endif
PDO_MYSQL_PARAM_BIND *bound_result; PDO_MYSQL_PARAM_BIND *bound_result;
my_bool *out_null; my_bool *out_null;
unsigned long *out_length; php_uint_t *out_length;
unsigned int params_given; unsigned int params_given;
unsigned max_length:1; unsigned max_length:1;
} pdo_mysql_stmt; } pdo_mysql_stmt;

View file

@ -142,7 +142,7 @@ static int odbc_handle_closer(pdo_dbh_t *dbh TSRMLS_DC)
return 0; return 0;
} }
static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC) static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{ {
RETCODE rc; RETCODE rc;
pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data; pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
@ -220,7 +220,7 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, p
return 1; return 1;
} }
static long odbc_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC) static php_int_t odbc_handle_doer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len TSRMLS_DC)
{ {
pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data; pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
RETCODE rc; RETCODE rc;
@ -336,7 +336,7 @@ static int odbc_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC)
return 1; return 1;
} }
static int odbc_handle_set_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) static int odbc_handle_set_attr(pdo_dbh_t *dbh, php_int_t attr, zval *val TSRMLS_DC)
{ {
pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data; pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
switch (attr) { switch (attr) {
@ -351,7 +351,7 @@ static int odbc_handle_set_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC)
} }
} }
static int odbc_handle_get_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) static int odbc_handle_get_attr(pdo_dbh_t *dbh, php_int_t attr, zval *val TSRMLS_DC)
{ {
pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data; pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
switch (attr) { switch (attr) {

View file

@ -58,7 +58,7 @@ static int pdo_odbc_sqltype_is_unicode(pdo_odbc_stmt *S, SWORD sqltype)
} }
static int pdo_odbc_utf82ucs2(pdo_stmt_t *stmt, int is_unicode, const char *buf, static int pdo_odbc_utf82ucs2(pdo_stmt_t *stmt, int is_unicode, const char *buf,
unsigned long buflen, unsigned long *outlen) php_uint_t buflen, php_uint_t *outlen)
{ {
#ifdef PHP_WIN32 #ifdef PHP_WIN32
if (is_unicode && buflen) { if (is_unicode && buflen) {
@ -93,7 +93,7 @@ static int pdo_odbc_utf82ucs2(pdo_stmt_t *stmt, int is_unicode, const char *buf,
} }
static int pdo_odbc_ucs22utf8(pdo_stmt_t *stmt, int is_unicode, const char *buf, static int pdo_odbc_ucs22utf8(pdo_stmt_t *stmt, int is_unicode, const char *buf,
unsigned long buflen, unsigned long *outlen) php_uint_t buflen, php_uint_t *outlen)
{ {
#ifdef PHP_WIN32 #ifdef PHP_WIN32
if (is_unicode && buflen) { if (is_unicode && buflen) {
@ -190,7 +190,7 @@ static int odbc_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
} }
if (Z_TYPE_P(parameter) != IS_RESOURCE) { if (Z_TYPE_P(parameter) != IS_RESOURCE) {
/* they passed in a string */ /* they passed in a string */
unsigned long ulen; php_uint_t ulen;
convert_to_string(parameter); convert_to_string(parameter);
switch (pdo_odbc_utf82ucs2(stmt, P->is_unicode, switch (pdo_odbc_utf82ucs2(stmt, P->is_unicode,
@ -458,7 +458,7 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p
} else { } else {
convert_to_string(parameter); convert_to_string(parameter);
if (P->outbuf) { if (P->outbuf) {
unsigned long ulen; php_uint_t ulen;
switch (pdo_odbc_utf82ucs2(stmt, P->is_unicode, switch (pdo_odbc_utf82ucs2(stmt, P->is_unicode,
Z_STRVAL_P(parameter), Z_STRVAL_P(parameter),
Z_STRSIZE_P(parameter), Z_STRSIZE_P(parameter),
@ -483,9 +483,9 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p
P = param->driver_data; P = param->driver_data;
if (P->outbuf) { if (P->outbuf) {
unsigned long ulen; php_uint_t ulen;
char *srcbuf; char *srcbuf;
unsigned long srclen = 0; php_uint_t srclen = 0;
if (Z_ISREF(param->parameter)) { if (Z_ISREF(param->parameter)) {
parameter = Z_REFVAL(param->parameter); parameter = Z_REFVAL(param->parameter);
@ -524,7 +524,7 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p
} }
static int odbc_stmt_fetch(pdo_stmt_t *stmt, static int odbc_stmt_fetch(pdo_stmt_t *stmt,
enum pdo_fetch_orientation ori, long offset TSRMLS_DC) enum pdo_fetch_orientation ori, php_int_t offset TSRMLS_DC)
{ {
RETCODE rc; RETCODE rc;
SQLSMALLINT odbcori; SQLSMALLINT odbcori;
@ -628,15 +628,15 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
return 1; return 1;
} }
static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len, int *caller_frees TSRMLS_DC) static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, php_uint_t *len, int *caller_frees TSRMLS_DC)
{ {
pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data; pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;
pdo_odbc_column *C = &S->cols[colno]; pdo_odbc_column *C = &S->cols[colno];
unsigned long ulen; php_uint_t ulen;
/* if it is a column containing "long" data, perform late binding now */ /* if it is a column containing "long" data, perform late binding now */
if (C->is_long) { if (C->is_long) {
unsigned long used = 0; php_uint_t used = 0;
char *buf; char *buf;
RETCODE rc; RETCODE rc;
@ -755,7 +755,7 @@ in_data:
return 1; return 1;
} }
static int odbc_stmt_set_param(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC) static int odbc_stmt_set_param(pdo_stmt_t *stmt, php_int_t attr, zval *val TSRMLS_DC)
{ {
SQLRETURN rc; SQLRETURN rc;
pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data; pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;
@ -782,7 +782,7 @@ static int odbc_stmt_set_param(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC)
} }
} }
static int odbc_stmt_get_attr(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC) static int odbc_stmt_get_attr(pdo_stmt_t *stmt, php_int_t attr, zval *val TSRMLS_DC)
{ {
SQLRETURN rc; SQLRETURN rc;
pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data; pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;

View file

@ -135,7 +135,7 @@ typedef struct {
typedef struct { typedef struct {
char *data; char *data;
unsigned long datalen; php_uint_t datalen;
SQLLEN fetched_len; SQLLEN fetched_len;
SWORD coltype; SWORD coltype;
char colname[128]; char colname[128];
@ -150,7 +150,7 @@ typedef struct {
pdo_odbc_db_handle *H; pdo_odbc_db_handle *H;
pdo_odbc_errinfo einfo; pdo_odbc_errinfo einfo;
char *convbuf; char *convbuf;
unsigned long convbufsize; php_uint_t convbufsize;
unsigned going_long:1; unsigned going_long:1;
unsigned assume_utf8:1; unsigned assume_utf8:1;
unsigned _spare:30; unsigned _spare:30;

View file

@ -87,11 +87,11 @@ PHP_MINIT_FUNCTION(pdo_pgsql)
{ {
REGISTER_PDO_CLASS_CONST_INT("PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT", PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT); REGISTER_PDO_CLASS_CONST_INT("PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT", PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT);
REGISTER_PDO_CLASS_CONST_INT("PGSQL_ATTR_DISABLE_PREPARES", PDO_PGSQL_ATTR_DISABLE_PREPARES); REGISTER_PDO_CLASS_CONST_INT("PGSQL_ATTR_DISABLE_PREPARES", PDO_PGSQL_ATTR_DISABLE_PREPARES);
REGISTER_PDO_CLASS_CONST_INT("PGSQL_TRANSACTION_IDLE", (long)PGSQL_TRANSACTION_IDLE); REGISTER_PDO_CLASS_CONST_INT("PGSQL_TRANSACTION_IDLE", (php_int_t)PGSQL_TRANSACTION_IDLE);
REGISTER_PDO_CLASS_CONST_INT("PGSQL_TRANSACTION_ACTIVE", (long)PGSQL_TRANSACTION_ACTIVE); REGISTER_PDO_CLASS_CONST_INT("PGSQL_TRANSACTION_ACTIVE", (php_int_t)PGSQL_TRANSACTION_ACTIVE);
REGISTER_PDO_CLASS_CONST_INT("PGSQL_TRANSACTION_INTRANS", (long)PGSQL_TRANSACTION_INTRANS); REGISTER_PDO_CLASS_CONST_INT("PGSQL_TRANSACTION_INTRANS", (php_int_t)PGSQL_TRANSACTION_INTRANS);
REGISTER_PDO_CLASS_CONST_INT("PGSQL_TRANSACTION_INERROR", (long)PGSQL_TRANSACTION_INERROR); REGISTER_PDO_CLASS_CONST_INT("PGSQL_TRANSACTION_INERROR", (php_int_t)PGSQL_TRANSACTION_INERROR);
REGISTER_PDO_CLASS_CONST_INT("PGSQL_TRANSACTION_UNKNOWN", (long)PGSQL_TRANSACTION_UNKNOWN); REGISTER_PDO_CLASS_CONST_INT("PGSQL_TRANSACTION_UNKNOWN", (php_int_t)PGSQL_TRANSACTION_UNKNOWN);
php_pdo_register_driver(&pdo_pgsql_driver); php_pdo_register_driver(&pdo_pgsql_driver);
return SUCCESS; return SUCCESS;

View file

@ -151,8 +151,8 @@ static int pgsql_lob_flush(php_stream *stream TSRMLS_DC)
return 0; return 0;
} }
static int pgsql_lob_seek(php_stream *stream, off_t offset, int whence, static int pgsql_lob_seek(php_stream *stream, php_off_t offset, int whence,
off_t *newoffset TSRMLS_DC) php_off_t *newoffset TSRMLS_DC)
{ {
struct pdo_pgsql_lob_self *self = (struct pdo_pgsql_lob_self*)stream->abstract; struct pdo_pgsql_lob_self *self = (struct pdo_pgsql_lob_self*)stream->abstract;
int pos = lo_lseek(self->conn, self->lfd, offset, whence); int pos = lo_lseek(self->conn, self->lfd, offset, whence);
@ -214,7 +214,7 @@ static int pgsql_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */
static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC) static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{ {
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
pdo_pgsql_stmt *S = ecalloc(1, sizeof(pdo_pgsql_stmt)); pdo_pgsql_stmt *S = ecalloc(1, sizeof(pdo_pgsql_stmt));
@ -287,11 +287,11 @@ static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
return 1; return 1;
} }
static long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC) static php_int_t pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len TSRMLS_DC)
{ {
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
PGresult *res; PGresult *res;
long ret = 1; php_int_t ret = 1;
ExecStatusType qs; ExecStatusType qs;
if (!(res = PQexec(H->server, sql))) { if (!(res = PQexec(H->server, sql))) {
@ -306,7 +306,11 @@ static long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM
return -1; return -1;
} }
H->pgoid = PQoidValue(res); H->pgoid = PQoidValue(res);
ret = (qs == PGRES_COMMAND_OK) ? atol(PQcmdTuples(res)) : 0L; if (qs == PGRES_COMMAND_OK) {
ZEND_ATOI(ret, PQcmdTuples(res));
} else {
ret = Z_I(0);
}
PQclear(res); PQclear(res);
return ret; return ret;
@ -350,7 +354,7 @@ static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned
if (H->pgoid == InvalidOid) { if (H->pgoid == InvalidOid) {
return NULL; return NULL;
} }
*len = spprintf(&id, 0, "%ld", (long) H->pgoid); *len = spprintf(&id, 0, ZEND_INT_FMT, (php_int_t) H->pgoid);
} else { } else {
PGresult *res; PGresult *res;
ExecStatusType status; ExecStatusType status;
@ -373,7 +377,7 @@ static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned
return id; return id;
} }
static int pdo_pgsql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value TSRMLS_DC) static int pdo_pgsql_get_attribute(pdo_dbh_t *dbh, php_int_t attr, zval *return_value TSRMLS_DC)
{ {
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
@ -906,7 +910,7 @@ static PHP_METHOD(PDO, pgsqlLOBCreate)
lfd = lo_creat(H->server, INV_READ|INV_WRITE); lfd = lo_creat(H->server, INV_READ|INV_WRITE);
if (lfd != InvalidOid) { if (lfd != InvalidOid) {
zend_string *buf = strpprintf(0, "%lu", (long) lfd); zend_string *buf = strpprintf(0, ZEND_UINT_FMT, (php_int_t) lfd);
RETURN_STR(buf); RETURN_STR(buf);
} }
@ -1011,11 +1015,11 @@ static PHP_METHOD(PDO, pgsqlGetNotify)
{ {
pdo_dbh_t *dbh; pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H; pdo_pgsql_db_handle *H;
long result_type = PDO_FETCH_USE_DEFAULT; php_int_t result_type = PDO_FETCH_USE_DEFAULT;
long ms_timeout = 0; php_int_t ms_timeout = 0;
PGnotify *pgsql_notify; PGnotify *pgsql_notify;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ii",
&result_type, &ms_timeout)) { &result_type, &ms_timeout)) {
RETURN_FALSE; RETURN_FALSE;
} }
@ -1107,7 +1111,7 @@ static const zend_function_entry *pdo_pgsql_get_driver_methods(pdo_dbh_t *dbh, i
} }
} }
static int pdo_pgsql_set_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) static int pdo_pgsql_set_attr(pdo_dbh_t *dbh, php_int_t attr, zval *val TSRMLS_DC)
{ {
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
@ -1154,7 +1158,7 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
int ret = 0; int ret = 0;
char *conn_str, *p, *e; char *conn_str, *p, *e;
char *tmp_pass; char *tmp_pass;
long connect_timeout = 30; php_int_t connect_timeout = 30;
H = pecalloc(1, sizeof(pdo_pgsql_db_handle), dbh->is_persistent); H = pecalloc(1, sizeof(pdo_pgsql_db_handle), dbh->is_persistent);
dbh->driver_data = H; dbh->driver_data = H;

View file

@ -230,10 +230,10 @@ stmt_retry:
} }
if (status == PGRES_COMMAND_OK) { if (status == PGRES_COMMAND_OK) {
stmt->row_count = (long)atoi(PQcmdTuples(S->result)); ZEND_ATOI(stmt->row_count, PQcmdTuples(S->result));
H->pgoid = PQoidValue(S->result); H->pgoid = PQoidValue(S->result);
} else { } else {
stmt->row_count = (long)PQntuples(S->result); stmt->row_count = (php_int_t)PQntuples(S->result);
} }
return 1; return 1;
@ -256,14 +256,15 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
/* decode name from $1, $2 into 0, 1 etc. */ /* decode name from $1, $2 into 0, 1 etc. */
if (param->name) { if (param->name) {
if (param->name->val[0] == '$') { if (param->name->val[0] == '$') {
param->paramno = atoi(param->name->val + 1); ZEND_ATOI(param->paramno, param->name->val + 1);
} else { } else {
/* resolve parameter name to rewritten name */ /* resolve parameter name to rewritten name */
char *namevar; char *namevar;
if (stmt->bound_param_map && (namevar = zend_hash_find_ptr(stmt->bound_param_map, if (stmt->bound_param_map && (namevar = zend_hash_find_ptr(stmt->bound_param_map,
param->name)) != NULL) { param->name)) != NULL) {
param->paramno = atoi(namevar + 1) - 1; ZEND_ATOI(param->paramno, namevar + 1);
param->paramno--;
} else { } else {
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", param->name->val TSRMLS_CC); pdo_raise_impl_error(stmt->dbh, stmt, "HY093", param->name->val TSRMLS_CC);
return 0; return 0;
@ -390,7 +391,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
} }
static int pgsql_stmt_fetch(pdo_stmt_t *stmt, static int pgsql_stmt_fetch(pdo_stmt_t *stmt,
enum pdo_fetch_orientation ori, long offset TSRMLS_DC) enum pdo_fetch_orientation ori, php_int_t offset TSRMLS_DC)
{ {
pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data;
@ -404,8 +405,8 @@ static int pgsql_stmt_fetch(pdo_stmt_t *stmt,
case PDO_FETCH_ORI_PRIOR: spprintf(&ori_str, 0, "BACKWARD"); break; case PDO_FETCH_ORI_PRIOR: spprintf(&ori_str, 0, "BACKWARD"); break;
case PDO_FETCH_ORI_FIRST: spprintf(&ori_str, 0, "FIRST"); break; case PDO_FETCH_ORI_FIRST: spprintf(&ori_str, 0, "FIRST"); break;
case PDO_FETCH_ORI_LAST: spprintf(&ori_str, 0, "LAST"); break; case PDO_FETCH_ORI_LAST: spprintf(&ori_str, 0, "LAST"); break;
case PDO_FETCH_ORI_ABS: spprintf(&ori_str, 0, "ABSOLUTE %ld", offset); break; case PDO_FETCH_ORI_ABS: spprintf(&ori_str, 0, "ABSOLUTE %pd", offset); break;
case PDO_FETCH_ORI_REL: spprintf(&ori_str, 0, "RELATIVE %ld", offset); break; case PDO_FETCH_ORI_REL: spprintf(&ori_str, 0, "RELATIVE %pd", offset); break;
default: default:
return 0; return 0;
} }
@ -479,7 +480,7 @@ static int pgsql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
break; break;
case INT8OID: case INT8OID:
if (sizeof(long)>=8) { if (sizeof(php_int_t)>=8) {
cols[colno].param_type = PDO_PARAM_INT; cols[colno].param_type = PDO_PARAM_INT;
} else { } else {
cols[colno].param_type = PDO_PARAM_STR; cols[colno].param_type = PDO_PARAM_STR;
@ -497,7 +498,7 @@ static int pgsql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
return 1; return 1;
} }
static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len, int *caller_frees TSRMLS_DC) static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, php_uint_t *len, int *caller_frees TSRMLS_DC)
{ {
pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data;
struct pdo_column_data *cols = stmt->columns; struct pdo_column_data *cols = stmt->columns;
@ -518,9 +519,9 @@ static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned
switch (cols[colno].param_type) { switch (cols[colno].param_type) {
case PDO_PARAM_INT: case PDO_PARAM_INT:
S->cols[colno].intval = atol(*ptr); ZEND_ATOI(S->cols[colno].intval, *ptr);
*ptr = (char *) &(S->cols[colno].intval); *ptr = (char *) &(S->cols[colno].intval);
*len = sizeof(long); *len = sizeof(php_int_t);
break; break;
case PDO_PARAM_BOOL: case PDO_PARAM_BOOL:
@ -576,7 +577,7 @@ static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned
return 1; return 1;
} }
static int pgsql_stmt_get_column_meta(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC) static int pgsql_stmt_get_column_meta(pdo_stmt_t *stmt, php_int_t colno, zval *return_value TSRMLS_DC)
{ {
pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data;
PGresult *res; PGresult *res;

View file

@ -54,7 +54,7 @@ typedef struct {
typedef struct { typedef struct {
char *def; char *def;
Oid pgsql_type; Oid pgsql_type;
long intval; php_int_t intval;
zend_bool boolval; zend_bool boolval;
} pdo_pgsql_column; } pdo_pgsql_column;