Skip to content

Commit 4ed156d

Browse files
committed
ported from pdo - pgsql, odbc, mysql, firebirt, dblib
1 parent 92269d2 commit 4ed156d

17 files changed

+129
-124
lines changed

ext/pdo_dblib/dblib_driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static int dblib_handle_closer(pdo_dbh_t *dbh TSRMLS_DC)
9393
return 0;
9494
}
9595

96-
static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
96+
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)
9797
{
9898
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
9999
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,
107107
return 1;
108108
}
109109

110-
static long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC)
110+
static php_int_t dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len TSRMLS_DC)
111111
{
112112
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
113113
RETCODE ret, resret;

ext/pdo_dblib/dblib_stmt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
171171
}
172172

173173
static int pdo_dblib_stmt_fetch(pdo_stmt_t *stmt,
174-
enum pdo_fetch_orientation ori, long offset TSRMLS_DC)
174+
enum pdo_fetch_orientation ori, php_int_t offset TSRMLS_DC)
175175
{
176176

177177
RETCODE ret;
@@ -213,7 +213,7 @@ static int pdo_dblib_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
213213
}
214214

215215
static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr,
216-
unsigned long *len, int *caller_frees TSRMLS_DC)
216+
php_uint_t *len, int *caller_frees TSRMLS_DC)
217217
{
218218

219219
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
287287
return 1;
288288
}
289289

290-
static int pdo_dblib_stmt_get_column_meta(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC)
290+
static int pdo_dblib_stmt_get_column_meta(pdo_stmt_t *stmt, php_int_t colno, zval *return_value TSRMLS_DC)
291291
{
292292
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
293293
pdo_dblib_db_handle *H = S->H;

ext/pdo_firebird/firebird_driver.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
#include "php_pdo_firebird.h"
3434
#include "php_pdo_firebird_int.h"
3535

36-
static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, long, XSQLDA*, isc_stmt_handle*,
36+
static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, php_int_t, XSQLDA*, isc_stmt_handle*,
3737
HashTable* TSRMLS_DC);
3838

3939
/* map driver specific error message to PDO error */
40-
void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC) /* {{{ */
40+
void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, php_int_t line TSRMLS_DC) /* {{{ */
4141
{
4242
#if 0
4343
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) /* {{{ */
132132
/* }}} */
133133

134134
/* called by PDO to prepare an SQL query */
135-
static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, /* {{{ */
135+
static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len, /* {{{ */
136136
pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
137137
{
138138
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
218218
/* }}} */
219219

220220
/* called by PDO to execute a statement that doesn't produce a result set */
221-
static long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC) /* {{{ */
221+
static php_int_t firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len TSRMLS_DC) /* {{{ */
222222
{
223223
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
224224
isc_stmt_handle stmt = NULL;
@@ -391,12 +391,12 @@ static int firebird_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
391391
/* }}} */
392392

393393
/* used by prepare and exec to allocate a statement handle and prepare the SQL */
394-
static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, long sql_len, /* {{{ */
394+
static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len, /* {{{ */
395395
XSQLDA *out_sqlda, isc_stmt_handle *s, HashTable *named_params TSRMLS_DC)
396396
{
397397
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
398398
char *c, *new_sql, in_quote, in_param, pname[64], *ppname;
399-
long l, pindex = -1;
399+
php_int_t l, pindex = -1;
400400

401401
/* Firebird allows SQL statements up to 64k, so bail if it doesn't fit */
402402
if (sql_len > 65536) {
@@ -470,7 +470,7 @@ static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, long sql
470470
/* }}} */
471471

472472
/* called by PDO to set a driver-specific dbh attribute */
473-
static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */
473+
static int firebird_handle_set_attribute(pdo_dbh_t *dbh, php_int_t attr, zval *val TSRMLS_DC) /* {{{ */
474474
{
475475
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
476476

@@ -545,7 +545,7 @@ static void firebird_info_cb(void *arg, char const *s) /* {{{ */
545545
/* }}} */
546546

547547
/* called by PDO to get a driver-specific dbh attribute */
548-
static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */
548+
static int firebird_handle_get_attribute(pdo_dbh_t *dbh, php_int_t attr, zval *val TSRMLS_DC) /* {{{ */
549549
{
550550
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
551551

@@ -606,7 +606,7 @@ static int pdo_firebird_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval
606606
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
607607
const ISC_STATUS *s = H->isc_status;
608608
char buf[400];
609-
long i = 0, l, sqlcode = isc_sqlcode(s);
609+
php_int_t i = 0, l, sqlcode = isc_sqlcode(s);
610610

611611
if (sqlcode) {
612612
add_next_index_int(info, sqlcode);

ext/pdo_firebird/firebird_statement.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
8888
{
8989
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
9090
pdo_firebird_db_handle *H = S->H;
91-
unsigned long affected_rows = 0;
91+
php_uint_t affected_rows = 0;
9292
static char info_count[] = {isc_info_sql_records};
9393
char result[64];
9494

@@ -153,7 +153,7 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
153153

154154
/* called by PDO to fetch the next row from a statement */
155155
static int firebird_stmt_fetch(pdo_stmt_t *stmt, /* {{{ */
156-
enum pdo_fetch_orientation ori, long offset TSRMLS_DC)
156+
enum pdo_fetch_orientation ori, php_int_t offset TSRMLS_DC)
157157
{
158158
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
159159
pdo_firebird_db_handle *H = S->H;
@@ -219,7 +219,7 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{
219219

220220
/* fetch a blob into a fetch buffer */
221221
static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */
222-
unsigned long *len, ISC_QUAD *blob_id TSRMLS_DC)
222+
php_uint_t *len, ISC_QUAD *blob_id TSRMLS_DC)
223223
{
224224
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
225225
pdo_firebird_db_handle *H = S->H;
@@ -263,7 +263,7 @@ static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ *
263263
/* we've found the blob's length, now fetch! */
264264

265265
if (*len) {
266-
unsigned long cur_len;
266+
php_uint_t cur_len;
267267
unsigned short seg_len;
268268
ISC_STATUS stat;
269269

@@ -296,7 +296,7 @@ static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ *
296296
/* }}} */
297297

298298
static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */
299-
unsigned long *len, int *caller_frees TSRMLS_DC)
299+
php_uint_t *len, int *caller_frees TSRMLS_DC)
300300
{
301301
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
302302
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
413413
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
414414
pdo_firebird_db_handle *H = S->H;
415415
isc_blob_handle h = NULL;
416-
unsigned long put_cnt = 0, rem_cnt;
416+
php_uint_t put_cnt = 0, rem_cnt;
417417
unsigned short chunk_size;
418418
int result = 1;
419419

@@ -495,7 +495,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
495495

496496
switch (event_type) {
497497
char *value;
498-
unsigned long value_len;
498+
php_uint_t value_len;
499499
int caller_frees;
500500
zval *parameter;
501501

@@ -551,9 +551,9 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
551551

552552
case IS_INT:
553553
/* keep the allow-NULL flag */
554-
var->sqltype = (sizeof(long) == 8 ? SQL_INT64 : SQL_LONG) | (var->sqltype & 1);
554+
var->sqltype = (sizeof(php_int_t) == 8 ? SQL_INT64 : SQL_LONG) | (var->sqltype & 1);
555555
var->sqldata = (void*)&Z_IVAL_P(parameter);
556-
var->sqllen = sizeof(long);
556+
var->sqllen = sizeof(php_int_t);
557557
break;
558558
case IS_DOUBLE:
559559
/* keep the allow-NULL flag */
@@ -626,7 +626,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
626626
}
627627
case PDO_PARAM_INT:
628628
if (value) {
629-
ZVAL_INT(parameter, *(long*)value);
629+
ZVAL_INT(parameter, *(php_int_t*)value);
630630
break;
631631
}
632632
case PDO_PARAM_EVT_NORMALIZE:
@@ -654,7 +654,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
654654
}
655655
/* }}} */
656656

657-
static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC) /* {{{ */
657+
static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, php_int_t attr, zval *val TSRMLS_DC) /* {{{ */
658658
{
659659
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
660660

@@ -675,7 +675,7 @@ static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, long attr, zval *val TS
675675
}
676676
/* }}} */
677677

678-
static int firebird_stmt_get_attribute(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC) /* {{{ */
678+
static int firebird_stmt_get_attribute(pdo_stmt_t *stmt, php_int_t attr, zval *val TSRMLS_DC) /* {{{ */
679679
{
680680
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
681681

ext/pdo_firebird/pdo_firebird.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ ZEND_GET_MODULE(pdo_firebird)
6262

6363
PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
6464
{
65-
REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_DATE_FORMAT", (long) PDO_FB_ATTR_DATE_FORMAT);
66-
REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_TIME_FORMAT", (long) PDO_FB_ATTR_TIME_FORMAT);
67-
REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_TIMESTAMP_FORMAT", (long) PDO_FB_ATTR_TIMESTAMP_FORMAT);
65+
REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_DATE_FORMAT", (php_int_t) PDO_FB_ATTR_DATE_FORMAT);
66+
REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_TIME_FORMAT", (php_int_t) PDO_FB_ATTR_TIME_FORMAT);
67+
REGISTER_PDO_CLASS_CONST_INT("FB_ATTR_TIMESTAMP_FORMAT", (php_int_t) PDO_FB_ATTR_TIMESTAMP_FORMAT);
6868

6969
php_pdo_register_driver(&pdo_firebird_driver);
7070

ext/pdo_firebird/php_pdo_firebird_int.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
#define SHORT_MAX (1 << (8*sizeof(short)-1))
3737

38-
#if SIZEOF_LONG == 8
38+
#if SIZEOF_ZEND_INT == 8 && !defined(PHP_WIN32)
3939
# define LL_MASK "l"
4040
# define LL_LIT(lit) lit ## L
4141
#else
@@ -128,7 +128,7 @@ extern pdo_driver_t pdo_firebird_driver;
128128

129129
extern struct pdo_stmt_methods firebird_stmt_methods;
130130

131-
void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC);
131+
void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, php_int_t line TSRMLS_DC);
132132

133133
enum {
134134
PDO_FB_ATTR_DATE_FORMAT = PDO_ATTR_DRIVER_SPECIFIC,

ext/pdo_mysql/mysql_driver.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int mysql_handle_closer(pdo_dbh_t *dbh TSRMLS_DC)
161161
/* }}} */
162162

163163
/* {{{ mysql_handle_preparer */
164-
static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
164+
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)
165165
{
166166
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
167167
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,
235235
#else
236236
S->params = ecalloc(S->num_params, sizeof(MYSQL_BIND));
237237
S->in_null = ecalloc(S->num_params, sizeof(my_bool));
238-
S->in_length = ecalloc(S->num_params, sizeof(unsigned long));
238+
S->in_length = ecalloc(S->num_params, sizeof(php_uint_t));
239239
#endif
240240
}
241241
dbh->alloc_own_columns = 1;
@@ -253,7 +253,7 @@ static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
253253
/* }}} */
254254

255255
/* {{{ mysql_handle_doer */
256-
static long mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC)
256+
static php_int_t mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, php_int_t sql_len TSRMLS_DC)
257257
{
258258
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
259259
PDO_DBG_ENTER("mysql_handle_doer");
@@ -368,7 +368,7 @@ static inline int mysql_handle_autocommit(pdo_dbh_t *dbh TSRMLS_DC)
368368
/* }}} */
369369

370370
/* {{{ pdo_mysql_set_attribute */
371-
static int pdo_mysql_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC)
371+
static int pdo_mysql_set_attribute(pdo_dbh_t *dbh, php_int_t attr, zval *val TSRMLS_DC)
372372
{
373373
PDO_DBG_ENTER("pdo_mysql_set_attribute");
374374
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
419419
/* }}} */
420420

421421
/* {{{ pdo_mysql_get_attribute */
422-
static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value TSRMLS_DC)
422+
static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, php_int_t attr, zval *return_value TSRMLS_DC)
423423
{
424424
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
425425

@@ -596,13 +596,13 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
596596

597597
/* handle MySQL options */
598598
if (driver_options) {
599-
long connect_timeout = pdo_attr_ival(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
600-
long local_infile = pdo_attr_ival(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0 TSRMLS_CC);
599+
php_int_t connect_timeout = pdo_attr_ival(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
600+
php_int_t local_infile = pdo_attr_ival(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0 TSRMLS_CC);
601601
char *init_cmd = NULL;
602602
#ifndef PDO_USE_MYSQLND
603603
char *default_file = NULL, *default_group = NULL;
604604
#endif
605-
long compress = 0;
605+
php_int_t compress = 0;
606606
char *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, *ssl_capath = NULL, *ssl_cipher = NULL;
607607
H->buffered = pdo_attr_ival(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);
608608

@@ -648,7 +648,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
648648
* mysqlnd doesn't support reconnect, thus we don't have "|| defined(PDO_USE_MYSQLND)"
649649
*/
650650
{
651-
long reconnect = 1;
651+
php_int_t reconnect = 1;
652652
mysql_options(H->server, MYSQL_OPT_RECONNECT, (const char*)&reconnect);
653653
}
654654
#endif

0 commit comments

Comments
 (0)