31
31
#include "php_pdo_firebird.h"
32
32
#include "php_pdo_firebird_int.h"
33
33
34
- static int firebird_alloc_prepare_stmt (pdo_dbh_t * , const zend_string * , XSQLDA * , isc_stmt_handle * ,
34
+ static int php_firebird_alloc_prepare_stmt (pdo_dbh_t * , const zend_string * , XSQLDA * , isc_stmt_handle * ,
35
35
HashTable * );
36
36
37
37
const char CHR_LETTER = 1 ;
@@ -173,7 +173,7 @@ static const char classes_array[] = {
173
173
/* 127 */ 0
174
174
};
175
175
176
- static inline char classes (char idx )
176
+ static inline char php_firebird_classes (char idx )
177
177
{
178
178
unsigned char uidx = (unsigned char ) idx ;
179
179
if (uidx > 127 ) return 0 ;
@@ -191,7 +191,7 @@ typedef enum {
191
191
ttOther
192
192
} FbTokenType ;
193
193
194
- static FbTokenType getToken (const char * * begin , const char * end )
194
+ static FbTokenType php_firebird_get_token (const char * * begin , const char * end )
195
195
{
196
196
FbTokenType ret = ttNone ;
197
197
const char * p = * begin ;
@@ -259,27 +259,27 @@ static FbTokenType getToken(const char** begin, const char* end)
259
259
break ;
260
260
261
261
default :
262
- if (classes (c ) & CHR_DIGIT )
262
+ if (php_firebird_classes (c ) & CHR_DIGIT )
263
263
{
264
- while (p < end && (classes (* p ) & CHR_DIGIT ))
264
+ while (p < end && (php_firebird_classes (* p ) & CHR_DIGIT ))
265
265
p ++ ;
266
266
ret = ttOther ;
267
267
}
268
- else if (classes (c ) & CHR_IDENT )
268
+ else if (php_firebird_classes (c ) & CHR_IDENT )
269
269
{
270
- while (p < end && (classes (* p ) & CHR_IDENT ))
270
+ while (p < end && (php_firebird_classes (* p ) & CHR_IDENT ))
271
271
p ++ ;
272
272
ret = ttIdent ;
273
273
}
274
- else if (classes (c ) & CHR_WHITE )
274
+ else if (php_firebird_classes (c ) & CHR_WHITE )
275
275
{
276
- while (p < end && (classes (* p ) & CHR_WHITE ))
276
+ while (p < end && (php_firebird_classes (* p ) & CHR_WHITE ))
277
277
p ++ ;
278
278
ret = ttWhite ;
279
279
}
280
280
else
281
281
{
282
- while (p < end && !(classes (* p ) & (CHR_DIGIT | CHR_IDENT | CHR_WHITE )) &&
282
+ while (p < end && !(php_firebird_classes (* p ) & (CHR_DIGIT | CHR_IDENT | CHR_WHITE )) &&
283
283
(* p != '/' ) && (* p != '-' ) && (* p != ':' ) && (* p != '?' ) &&
284
284
(* p != '\'' ) && (* p != '"' ))
285
285
{
@@ -293,21 +293,21 @@ static FbTokenType getToken(const char** begin, const char* end)
293
293
return ret ;
294
294
}
295
295
296
- int preprocess (const zend_string * sql , char * sql_out , HashTable * named_params )
296
+ static int php_firebird_preprocess (const zend_string * sql , char * sql_out , HashTable * named_params )
297
297
{
298
298
bool passAsIs = 1 , execBlock = 0 ;
299
299
zend_long pindex = -1 ;
300
300
char pname [254 ], ident [253 ], ident2 [253 ];
301
301
unsigned int l ;
302
302
const char * p = ZSTR_VAL (sql ), * end = ZSTR_VAL (sql ) + ZSTR_LEN (sql );
303
303
const char * start = p ;
304
- FbTokenType tok = getToken (& p , end );
304
+ FbTokenType tok = php_firebird_get_token (& p , end );
305
305
306
306
const char * i = start ;
307
307
while (p < end && (tok == ttComment || tok == ttWhite ))
308
308
{
309
309
i = p ;
310
- tok = getToken (& p , end );
310
+ tok = php_firebird_get_token (& p , end );
311
311
}
312
312
313
313
if (p >= end || tok != ttIdent )
@@ -331,11 +331,11 @@ int preprocess(const zend_string* sql, char* sql_out, HashTable* named_params)
331
331
/* For EXECUTE PROCEDURE and EXECUTE BLOCK statements, named parameters must be processed. */
332
332
/* However, in EXECUTE BLOCK this is done in a special way. */
333
333
const char * i2 = p ;
334
- tok = getToken (& p , end );
334
+ tok = php_firebird_get_token (& p , end );
335
335
while (p < end && (tok == ttComment || tok == ttWhite ))
336
336
{
337
337
i2 = p ;
338
- tok = getToken (& p , end );
338
+ tok = php_firebird_get_token (& p , end );
339
339
}
340
340
if (p >= end || tok != ttIdent )
341
341
{
@@ -374,11 +374,11 @@ int preprocess(const zend_string* sql, char* sql_out, HashTable* named_params)
374
374
while (p < end )
375
375
{
376
376
start = p ;
377
- tok = getToken (& p , end );
377
+ tok = php_firebird_get_token (& p , end );
378
378
switch (tok )
379
379
{
380
380
case ttParamMark :
381
- tok = getToken (& p , end );
381
+ tok = php_firebird_get_token (& p , end );
382
382
if (tok == ttIdent /*|| tok == ttString*/ )
383
383
{
384
384
++ pindex ;
@@ -460,7 +460,7 @@ int preprocess(const zend_string* sql, char* sql_out, HashTable* named_params)
460
460
}
461
461
462
462
/* map driver specific error message to PDO error */
463
- void _firebird_error (pdo_dbh_t * dbh , pdo_stmt_t * stmt , const char * state , const size_t state_len ,
463
+ void php_firebird_set_error (pdo_dbh_t * dbh , pdo_stmt_t * stmt , const char * state , const size_t state_len ,
464
464
const char * msg , const size_t msg_len ) /* {{{ */
465
465
{
466
466
pdo_error_type * const error_code = stmt ? & stmt -> error_code : & dbh -> error_code ;
@@ -529,17 +529,17 @@ static void firebird_handle_closer(pdo_dbh_t *dbh) /* {{{ */
529
529
if (dbh -> in_txn ) {
530
530
if (dbh -> auto_commit ) {
531
531
if (isc_commit_transaction (H -> isc_status , & H -> tr )) {
532
- firebird_error (dbh );
532
+ php_firebird_error (dbh );
533
533
}
534
534
} else {
535
535
if (isc_rollback_transaction (H -> isc_status , & H -> tr )) {
536
- firebird_error (dbh );
536
+ php_firebird_error (dbh );
537
537
}
538
538
}
539
539
}
540
540
541
541
if (isc_detach_database (H -> isc_status , & H -> db )) {
542
- firebird_error (dbh );
542
+ php_firebird_error (dbh );
543
543
}
544
544
545
545
if (H -> date_format ) {
@@ -582,7 +582,7 @@ static bool firebird_handle_preparer(pdo_dbh_t *dbh, zend_string *sql, /* {{{ */
582
582
zend_hash_init (np , 8 , NULL , NULL , 0 );
583
583
584
584
/* allocate and prepare statement */
585
- if (!firebird_alloc_prepare_stmt (dbh , sql , & num_sqlda , & s , np )) {
585
+ if (!php_firebird_alloc_prepare_stmt (dbh , sql , & num_sqlda , & s , np )) {
586
586
break ;
587
587
}
588
588
@@ -603,7 +603,7 @@ static bool firebird_handle_preparer(pdo_dbh_t *dbh, zend_string *sql, /* {{{ */
603
603
604
604
/* fill the output sqlda with information about the prepared query */
605
605
if (isc_dsql_describe (H -> isc_status , & s , PDO_FB_SQLDA_VERSION , & S -> out_sqlda )) {
606
- firebird_error (dbh );
606
+ php_firebird_error (dbh );
607
607
break ;
608
608
}
609
609
@@ -630,7 +630,7 @@ static bool firebird_handle_preparer(pdo_dbh_t *dbh, zend_string *sql, /* {{{ */
630
630
631
631
} while (0 );
632
632
633
- firebird_error (dbh );
633
+ php_firebird_error (dbh );
634
634
635
635
zend_hash_destroy (np );
636
636
FREE_HASHTABLE (np );
@@ -662,21 +662,21 @@ static zend_long firebird_handle_doer(pdo_dbh_t *dbh, const zend_string *sql) /*
662
662
out_sqlda .sqln = 1 ;
663
663
664
664
/* allocate and prepare statement */
665
- if (!firebird_alloc_prepare_stmt (dbh , sql , & out_sqlda , & stmt , 0 )) {
665
+ if (!php_firebird_alloc_prepare_stmt (dbh , sql , & out_sqlda , & stmt , 0 )) {
666
666
return -1 ;
667
667
}
668
668
669
669
/* execute the statement */
670
670
if (isc_dsql_execute2 (H -> isc_status , & H -> tr , & stmt , PDO_FB_SQLDA_VERSION , & in_sqlda , & out_sqlda )) {
671
- firebird_error (dbh );
671
+ php_firebird_error (dbh );
672
672
ret = -1 ;
673
673
goto free_statement ;
674
674
}
675
675
676
676
/* find out how many rows were affected */
677
677
if (isc_dsql_sql_info (H -> isc_status , & stmt , sizeof (info_count ), const_cast (info_count ),
678
678
sizeof (result ), result )) {
679
- firebird_error (dbh );
679
+ php_firebird_error (dbh );
680
680
ret = -1 ;
681
681
goto free_statement ;
682
682
}
@@ -704,13 +704,13 @@ static zend_long firebird_handle_doer(pdo_dbh_t *dbh, const zend_string *sql) /*
704
704
705
705
/* commit if we're in auto_commit mode */
706
706
if (dbh -> auto_commit && isc_commit_retaining (H -> isc_status , & H -> tr )) {
707
- firebird_error (dbh );
707
+ php_firebird_error (dbh );
708
708
}
709
709
710
710
free_statement :
711
711
712
712
if (isc_dsql_free_statement (H -> isc_status , & stmt , DSQL_drop )) {
713
- firebird_error (dbh );
713
+ php_firebird_error (dbh );
714
714
}
715
715
716
716
return ret ;
@@ -802,7 +802,7 @@ static bool firebird_handle_begin(pdo_dbh_t *dbh) /* {{{ */
802
802
}
803
803
#endif
804
804
if (isc_start_transaction (H -> isc_status , & H -> tr , 1 , & H -> db , (unsigned short )(ptpb - tpb ), tpb )) {
805
- firebird_error (dbh );
805
+ php_firebird_error (dbh );
806
806
return false;
807
807
}
808
808
return true;
@@ -815,7 +815,7 @@ static bool firebird_handle_commit(pdo_dbh_t *dbh) /* {{{ */
815
815
pdo_firebird_db_handle * H = (pdo_firebird_db_handle * )dbh -> driver_data ;
816
816
817
817
if (isc_commit_transaction (H -> isc_status , & H -> tr )) {
818
- firebird_error (dbh );
818
+ php_firebird_error (dbh );
819
819
return false;
820
820
}
821
821
return true;
@@ -828,15 +828,15 @@ static bool firebird_handle_rollback(pdo_dbh_t *dbh) /* {{{ */
828
828
pdo_firebird_db_handle * H = (pdo_firebird_db_handle * )dbh -> driver_data ;
829
829
830
830
if (isc_rollback_transaction (H -> isc_status , & H -> tr )) {
831
- firebird_error (dbh );
831
+ php_firebird_error (dbh );
832
832
return false;
833
833
}
834
834
return true;
835
835
}
836
836
/* }}} */
837
837
838
838
/* used by prepare and exec to allocate a statement handle and prepare the SQL */
839
- static int firebird_alloc_prepare_stmt (pdo_dbh_t * dbh , const zend_string * sql ,
839
+ static int php_firebird_alloc_prepare_stmt (pdo_dbh_t * dbh , const zend_string * sql ,
840
840
XSQLDA * out_sqlda , isc_stmt_handle * s , HashTable * named_params )
841
841
{
842
842
pdo_firebird_db_handle * H = (pdo_firebird_db_handle * )dbh -> driver_data ;
@@ -860,23 +860,23 @@ static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const zend_string *sql,
860
860
861
861
/* allocate the statement */
862
862
if (isc_dsql_allocate_statement (H -> isc_status , & H -> db , s )) {
863
- firebird_error (dbh );
863
+ php_firebird_error (dbh );
864
864
return 0 ;
865
865
}
866
866
867
867
/* in order to support named params, which Firebird itself doesn't,
868
868
we need to replace :foo by ?, and store the name we just replaced */
869
869
new_sql = emalloc (ZSTR_LEN (sql )+ 1 );
870
870
new_sql [0 ] = '\0' ;
871
- if (!preprocess (sql , new_sql , named_params )) {
871
+ if (!php_firebird_preprocess (sql , new_sql , named_params )) {
872
872
strcpy (dbh -> error_code , "07000" );
873
873
efree (new_sql );
874
874
return 0 ;
875
875
}
876
876
877
877
/* prepare the statement */
878
878
if (isc_dsql_prepare (H -> isc_status , & H -> tr , s , 0 , new_sql , H -> sql_dialect , out_sqlda )) {
879
- firebird_error (dbh );
879
+ php_firebird_error (dbh );
880
880
efree (new_sql );
881
881
return 0 ;
882
882
}
@@ -886,7 +886,7 @@ static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const zend_string *sql,
886
886
}
887
887
888
888
/* called by PDO to set a driver-specific dbh attribute */
889
- static bool firebird_handle_set_attribute (pdo_dbh_t * dbh , zend_long attr , zval * val ) /* {{{ */
889
+ static bool pdo_firebird_set_attribute (pdo_dbh_t * dbh , zend_long attr , zval * val ) /* {{{ */
890
890
{
891
891
pdo_firebird_db_handle * H = (pdo_firebird_db_handle * )dbh -> driver_data ;
892
892
bool bval ;
@@ -905,7 +905,7 @@ static bool firebird_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *
905
905
/* turning on auto_commit with an open transaction is illegal, because
906
906
we won't know what to do with it */
907
907
const char * msg = "Cannot enable auto-commit while a transaction is already open" ;
908
- firebird_error_with_info (dbh , "HY000" , strlen ("HY000" ), msg , strlen (msg ));
908
+ php_firebird_error_with_info (dbh , "HY000" , strlen ("HY000" ), msg , strlen (msg ));
909
909
return false;
910
910
} else {
911
911
/* close the transaction */
@@ -976,7 +976,7 @@ static bool firebird_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *
976
976
#define INFO_BUF_LEN 512
977
977
978
978
/* callback to used to report database server info */
979
- static void firebird_info_cb (void * arg , char const * s ) /* {{{ */
979
+ static void php_firebird_info_cb (void * arg , char const * s ) /* {{{ */
980
980
{
981
981
if (arg ) {
982
982
if (* (char * )arg ) { /* second call */
@@ -988,7 +988,7 @@ static void firebird_info_cb(void *arg, char const *s) /* {{{ */
988
988
/* }}} */
989
989
990
990
/* called by PDO to get a driver-specific dbh attribute */
991
- static int firebird_handle_get_attribute (pdo_dbh_t * dbh , zend_long attr , zval * val ) /* {{{ */
991
+ static int pdo_firebird_get_attribute (pdo_dbh_t * dbh , zend_long attr , zval * val ) /* {{{ */
992
992
{
993
993
pdo_firebird_db_handle * H = (pdo_firebird_db_handle * )dbh -> driver_data ;
994
994
@@ -1000,7 +1000,7 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *v
1000
1000
return 1 ;
1001
1001
1002
1002
case PDO_ATTR_CONNECTION_STATUS :
1003
- ZVAL_BOOL (val , !isc_version (& H -> db , firebird_info_cb , NULL ));
1003
+ ZVAL_BOOL (val , !isc_version (& H -> db , php_firebird_info_cb , NULL ));
1004
1004
return 1 ;
1005
1005
1006
1006
case PDO_ATTR_CLIENT_VERSION : {
@@ -1030,7 +1030,7 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *v
1030
1030
case PDO_ATTR_SERVER_INFO :
1031
1031
* tmp = 0 ;
1032
1032
1033
- if (!isc_version (& H -> db , firebird_info_cb , (void * )tmp )) {
1033
+ if (!isc_version (& H -> db , php_firebird_info_cb , (void * )tmp )) {
1034
1034
ZVAL_STRING (val , tmp );
1035
1035
return 1 ;
1036
1036
}
@@ -1066,10 +1066,10 @@ static const struct pdo_dbh_methods firebird_methods = { /* {{{ */
1066
1066
firebird_handle_begin ,
1067
1067
firebird_handle_commit ,
1068
1068
firebird_handle_rollback ,
1069
- firebird_handle_set_attribute ,
1069
+ pdo_firebird_set_attribute ,
1070
1070
NULL , /* last_id not supported */
1071
1071
pdo_firebird_fetch_error_func ,
1072
- firebird_handle_get_attribute ,
1072
+ pdo_firebird_get_attribute ,
1073
1073
NULL , /* check_liveness */
1074
1074
NULL , /* get driver methods */
1075
1075
NULL , /* request shutdown */
0 commit comments