@@ -665,7 +665,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
665
665
PGresult * pg_result ;
666
666
667
667
ZEND_PARSE_PARAMETERS_START (1 , 2 )
668
- Z_PARAM_STRING (connstring , connstring_len )
668
+ Z_PARAM_PATH (connstring , connstring_len )
669
669
Z_PARAM_OPTIONAL
670
670
Z_PARAM_LONG (connect_type )
671
671
ZEND_PARSE_PARAMETERS_END ();
@@ -1123,7 +1123,7 @@ PHP_FUNCTION(pg_query)
1123
1123
zval * pgsql_link = NULL ;
1124
1124
char * query ;
1125
1125
size_t query_len ;
1126
- int leftover = 0 ;
1126
+ bool leftover = false ;
1127
1127
pgsql_link_handle * link ;
1128
1128
PGconn * pgsql ;
1129
1129
PGresult * pgsql_result ;
@@ -1157,7 +1157,7 @@ PHP_FUNCTION(pg_query)
1157
1157
}
1158
1158
while ((pgsql_result = PQgetResult (pgsql ))) {
1159
1159
PQclear (pgsql_result );
1160
- leftover = 1 ;
1160
+ leftover = true ;
1161
1161
}
1162
1162
if (leftover ) {
1163
1163
php_error_docref (NULL , E_NOTICE , "Found results on this connection. Use pg_get_result() to get these results first" );
@@ -1220,7 +1220,7 @@ PHP_FUNCTION(pg_query_params)
1220
1220
zval * pv_param_arr , * tmp ;
1221
1221
char * query ;
1222
1222
size_t query_len ;
1223
- int leftover = 0 ;
1223
+ bool leftover = false ;
1224
1224
int num_params = 0 ;
1225
1225
char * * params = NULL ;
1226
1226
pgsql_link_handle * link ;
@@ -1259,7 +1259,7 @@ PHP_FUNCTION(pg_query_params)
1259
1259
}
1260
1260
while ((pgsql_result = PQgetResult (pgsql ))) {
1261
1261
PQclear (pgsql_result );
1262
- leftover = 1 ;
1262
+ leftover = true ;
1263
1263
}
1264
1264
if (leftover ) {
1265
1265
php_error_docref (NULL , E_NOTICE , "Found results on this connection. Use pg_get_result() to get these results first" );
@@ -1335,7 +1335,7 @@ PHP_FUNCTION(pg_prepare)
1335
1335
zval * pgsql_link = NULL ;
1336
1336
char * query , * stmtname ;
1337
1337
size_t query_len , stmtname_len ;
1338
- int leftover = 0 ;
1338
+ bool leftover = false ;
1339
1339
PGconn * pgsql ;
1340
1340
pgsql_link_handle * link ;
1341
1341
PGresult * pgsql_result ;
@@ -1372,7 +1372,7 @@ PHP_FUNCTION(pg_prepare)
1372
1372
}
1373
1373
while ((pgsql_result = PQgetResult (pgsql ))) {
1374
1374
PQclear (pgsql_result );
1375
- leftover = 1 ;
1375
+ leftover = true ;
1376
1376
}
1377
1377
if (leftover ) {
1378
1378
php_error_docref (NULL , E_NOTICE , "Found results on this connection. Use pg_get_result() to get these results first" );
@@ -1422,7 +1422,7 @@ PHP_FUNCTION(pg_execute)
1422
1422
zval * pv_param_arr , * tmp ;
1423
1423
char * stmtname ;
1424
1424
size_t stmtname_len ;
1425
- int leftover = 0 ;
1425
+ bool leftover = false ;
1426
1426
int num_params = 0 ;
1427
1427
char * * params = NULL ;
1428
1428
PGconn * pgsql ;
@@ -1461,7 +1461,7 @@ PHP_FUNCTION(pg_execute)
1461
1461
}
1462
1462
while ((pgsql_result = PQgetResult (pgsql ))) {
1463
1463
PQclear (pgsql_result );
1464
- leftover = 1 ;
1464
+ leftover = true ;
1465
1465
}
1466
1466
if (leftover ) {
1467
1467
php_error_docref (NULL , E_NOTICE , "Found results on this connection. Use pg_get_result() to get these results first" );
@@ -1690,7 +1690,7 @@ PHP_FUNCTION(pg_field_table)
1690
1690
zval * result ;
1691
1691
pgsql_result_handle * pg_result ;
1692
1692
zend_long fnum = -1 ;
1693
- bool return_oid = 0 ;
1693
+ bool return_oid = false ;
1694
1694
1695
1695
ZEND_PARSE_PARAMETERS_START (2 , 3 )
1696
1696
Z_PARAM_OBJECT_OF_CLASS (result , pgsql_result_ce )
@@ -2770,7 +2770,7 @@ PHP_FUNCTION(pg_lo_write)
2770
2770
zval * pgsql_id ;
2771
2771
zend_string * str ;
2772
2772
zend_long z_len ;
2773
- bool z_len_is_null = 1 ;
2773
+ bool z_len_is_null = true ;
2774
2774
size_t nbytes ;
2775
2775
size_t len ;
2776
2776
pgLofp * pgsql ;
@@ -2794,6 +2794,10 @@ PHP_FUNCTION(pg_lo_write)
2794
2794
len = z_len ;
2795
2795
}
2796
2796
else {
2797
+ if (zend_str_has_nul_byte (str )) {
2798
+ zend_argument_value_error (2 , "must not contain any null bytes" );
2799
+ RETURN_THROWS ();
2800
+ }
2797
2801
len = ZSTR_LEN (str );
2798
2802
}
2799
2803
@@ -3346,7 +3350,7 @@ PHP_FUNCTION(pg_copy_to)
3346
3350
switch (status ) {
3347
3351
case PGRES_COPY_OUT :
3348
3352
if (pgsql_result ) {
3349
- int copydone = 0 ;
3353
+ bool copydone = false ;
3350
3354
3351
3355
PQclear (pgsql_result );
3352
3356
array_init (return_value );
@@ -3355,7 +3359,7 @@ PHP_FUNCTION(pg_copy_to)
3355
3359
int ret = PQgetCopyData (pgsql , & csv , 0 );
3356
3360
switch (ret ) {
3357
3361
case -1 :
3358
- copydone = 1 ;
3362
+ copydone = true ;
3359
3363
break ;
3360
3364
case 0 :
3361
3365
case -2 :
@@ -4654,7 +4658,7 @@ PHP_FUNCTION(pg_meta_data)
4654
4658
zval * pgsql_link ;
4655
4659
pgsql_link_handle * link ;
4656
4660
zend_string * table_name ;
4657
- bool extended = 0 ;
4661
+ bool extended = false ;
4658
4662
PGconn * pgsql ;
4659
4663
4660
4664
ZEND_PARSE_PARAMETERS_START (2 , 3 )
@@ -4832,7 +4836,7 @@ static zend_string *php_pgsql_add_quotes(zend_string *src)
4832
4836
/* if new_value is string "NULL" and field has default value, remove element to use default value */ \
4833
4837
if (!(opt & PGSQL_CONV_IGNORE_DEFAULT ) && Z_TYPE_P (has_default ) == IS_TRUE ) { \
4834
4838
zval_ptr_dtor (& new_val ); \
4835
- skip_field = 1 ; \
4839
+ skip_field = true ; \
4836
4840
} \
4837
4841
/* raise error if it's not null and cannot be ignored */ \
4838
4842
else if (!(opt & PGSQL_CONV_IGNORE_NOT_NULL ) && Z_TYPE_P (not_null ) == IS_TRUE ) { \
@@ -4848,7 +4852,8 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
4848
4852
{
4849
4853
zend_string * field = NULL ;
4850
4854
zval meta , * def , * type , * not_null , * has_default , * is_enum , * val , new_val ;
4851
- int err = 0 , skip_field ;
4855
+ int err = 0 ;
4856
+ bool skip_field ;
4852
4857
php_pgsql_data_type data_type ;
4853
4858
4854
4859
ZEND_ASSERT (pg_link != NULL );
@@ -4867,7 +4872,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
4867
4872
}
4868
4873
4869
4874
ZEND_HASH_FOREACH_STR_KEY_VAL (Z_ARRVAL_P (values ), field , val ) {
4870
- skip_field = 0 ;
4875
+ skip_field = false ;
4871
4876
ZVAL_DEREF (val );
4872
4877
ZVAL_NULL (& new_val );
4873
4878
@@ -6324,7 +6329,7 @@ PHP_FUNCTION(pg_close_stmt)
6324
6329
6325
6330
ZEND_PARSE_PARAMETERS_START (2 , 2 )
6326
6331
Z_PARAM_OBJECT_OF_CLASS (pgsql_link , pgsql_link_ce )
6327
- Z_PARAM_STR (stmt )
6332
+ Z_PARAM_PATH (stmt )
6328
6333
ZEND_PARSE_PARAMETERS_END ();
6329
6334
6330
6335
if (ZSTR_LEN (stmt ) == 0 ) {
0 commit comments