@@ -4385,88 +4385,87 @@ PHP_FUNCTION(pg_meta_data)
4385
4385
/* }}} */
4386
4386
4387
4387
/* {{{ php_pgsql_get_data_type */
4388
- static php_pgsql_data_type php_pgsql_get_data_type (const char * type_name , size_t len )
4388
+ static php_pgsql_data_type php_pgsql_get_data_type (const zend_string * type_name )
4389
4389
{
4390
- /* This is stupid way to do. I'll fix it when I decied how to support
4390
+ /* This is stupid way to do. I'll fix it when I decide how to support
4391
4391
user defined types. (Yasuo) */
4392
-
4393
4392
/* boolean */
4394
- if (! strcmp (type_name , "bool" )|| ! strcmp (type_name , "boolean" ))
4393
+ if (zend_string_equals_literal (type_name , "bool" )|| zend_string_equals_literal (type_name , "boolean" ))
4395
4394
return PG_BOOL ;
4396
4395
/* object id */
4397
- if (! strcmp (type_name , "oid" ))
4396
+ if (zend_string_equals_literal (type_name , "oid" ))
4398
4397
return PG_OID ;
4399
4398
/* integer */
4400
- if (! strcmp (type_name , "int2" ) || ! strcmp (type_name , "smallint" ))
4399
+ if (zend_string_equals_literal (type_name , "int2" ) || zend_string_equals_literal (type_name , "smallint" ))
4401
4400
return PG_INT2 ;
4402
- if (! strcmp (type_name , "int4" ) || ! strcmp (type_name , "integer" ))
4401
+ if (zend_string_equals_literal (type_name , "int4" ) || zend_string_equals_literal (type_name , "integer" ))
4403
4402
return PG_INT4 ;
4404
- if (! strcmp (type_name , "int8" ) || ! strcmp (type_name , "bigint" ))
4403
+ if (zend_string_equals_literal (type_name , "int8" ) || zend_string_equals_literal (type_name , "bigint" ))
4405
4404
return PG_INT8 ;
4406
4405
/* real and other */
4407
- if (! strcmp (type_name , "float4" ) || ! strcmp (type_name , "real" ))
4406
+ if (zend_string_equals_literal (type_name , "float4" ) || zend_string_equals_literal (type_name , "real" ))
4408
4407
return PG_FLOAT4 ;
4409
- if (! strcmp (type_name , "float8" ) || ! strcmp (type_name , "double precision" ))
4408
+ if (zend_string_equals_literal (type_name , "float8" ) || zend_string_equals_literal (type_name , "double precision" ))
4410
4409
return PG_FLOAT8 ;
4411
- if (! strcmp (type_name , "numeric" ))
4410
+ if (zend_string_equals_literal (type_name , "numeric" ))
4412
4411
return PG_NUMERIC ;
4413
- if (! strcmp (type_name , "money" ))
4412
+ if (zend_string_equals_literal (type_name , "money" ))
4414
4413
return PG_MONEY ;
4415
4414
/* character */
4416
- if (! strcmp (type_name , "text" ))
4415
+ if (zend_string_equals_literal (type_name , "text" ))
4417
4416
return PG_TEXT ;
4418
- if (! strcmp (type_name , "bpchar" ) || ! strcmp (type_name , "character" ))
4417
+ if (zend_string_equals_literal (type_name , "bpchar" ) || zend_string_equals_literal (type_name , "character" ))
4419
4418
return PG_CHAR ;
4420
- if (! strcmp (type_name , "varchar" ) || ! strcmp (type_name , "character varying" ))
4419
+ if (zend_string_equals_literal (type_name , "varchar" ) || zend_string_equals_literal (type_name , "character varying" ))
4421
4420
return PG_VARCHAR ;
4422
4421
/* time and interval */
4423
- if (! strcmp (type_name , "abstime" ))
4422
+ if (zend_string_equals_literal (type_name , "abstime" ))
4424
4423
return PG_UNIX_TIME ;
4425
- if (! strcmp (type_name , "reltime" ))
4424
+ if (zend_string_equals_literal (type_name , "reltime" ))
4426
4425
return PG_UNIX_TIME_INTERVAL ;
4427
- if (! strcmp (type_name , "tinterval" ))
4426
+ if (zend_string_equals_literal (type_name , "tinterval" ))
4428
4427
return PG_UNIX_TIME_INTERVAL ;
4429
- if (! strcmp (type_name , "date" ))
4428
+ if (zend_string_equals_literal (type_name , "date" ))
4430
4429
return PG_DATE ;
4431
- if (! strcmp (type_name , "time" ))
4430
+ if (zend_string_equals_literal (type_name , "time" ))
4432
4431
return PG_TIME ;
4433
- if (! strcmp (type_name , "time with time zone" ) || ! strcmp (type_name , "timetz" ))
4432
+ if (zend_string_equals_literal (type_name , "time with time zone" ) || zend_string_equals_literal (type_name , "timetz" ))
4434
4433
return PG_TIME_WITH_TIMEZONE ;
4435
- if (! strcmp (type_name , "timestamp without time zone" ) || ! strcmp (type_name , "timestamp" ))
4434
+ if (zend_string_equals_literal (type_name , "timestamp without time zone" ) || zend_string_equals_literal (type_name , "timestamp" ))
4436
4435
return PG_TIMESTAMP ;
4437
- if (! strcmp (type_name , "timestamp with time zone" ) || ! strcmp (type_name , "timestamptz" ))
4436
+ if (zend_string_equals_literal (type_name , "timestamp with time zone" ) || zend_string_equals_literal (type_name , "timestamptz" ))
4438
4437
return PG_TIMESTAMP_WITH_TIMEZONE ;
4439
- if (! strcmp (type_name , "interval" ))
4438
+ if (zend_string_equals_literal (type_name , "interval" ))
4440
4439
return PG_INTERVAL ;
4441
4440
/* binary */
4442
- if (! strcmp (type_name , "bytea" ))
4441
+ if (zend_string_equals_literal (type_name , "bytea" ))
4443
4442
return PG_BYTEA ;
4444
4443
/* network */
4445
- if (! strcmp (type_name , "cidr" ))
4444
+ if (zend_string_equals_literal (type_name , "cidr" ))
4446
4445
return PG_CIDR ;
4447
- if (! strcmp (type_name , "inet" ))
4446
+ if (zend_string_equals_literal (type_name , "inet" ))
4448
4447
return PG_INET ;
4449
- if (! strcmp (type_name , "macaddr" ))
4448
+ if (zend_string_equals_literal (type_name , "macaddr" ))
4450
4449
return PG_MACADDR ;
4451
4450
/* bit */
4452
- if (! strcmp (type_name , "bit" ))
4451
+ if (zend_string_equals_literal (type_name , "bit" ))
4453
4452
return PG_BIT ;
4454
- if (! strcmp (type_name , "bit varying" ))
4453
+ if (zend_string_equals_literal (type_name , "bit varying" ))
4455
4454
return PG_VARBIT ;
4456
4455
/* geometric */
4457
- if (! strcmp (type_name , "line" ))
4456
+ if (zend_string_equals_literal (type_name , "line" ))
4458
4457
return PG_LINE ;
4459
- if (! strcmp (type_name , "lseg" ))
4458
+ if (zend_string_equals_literal (type_name , "lseg" ))
4460
4459
return PG_LSEG ;
4461
- if (! strcmp (type_name , "box" ))
4460
+ if (zend_string_equals_literal (type_name , "box" ))
4462
4461
return PG_BOX ;
4463
- if (! strcmp (type_name , "path" ))
4462
+ if (zend_string_equals_literal (type_name , "path" ))
4464
4463
return PG_PATH ;
4465
- if (! strcmp (type_name , "point" ))
4464
+ if (zend_string_equals_literal (type_name , "point" ))
4466
4465
return PG_POINT ;
4467
- if (! strcmp (type_name , "polygon" ))
4466
+ if (zend_string_equals_literal (type_name , "polygon" ))
4468
4467
return PG_POLYGON ;
4469
- if (! strcmp (type_name , "circle" ))
4468
+ if (zend_string_equals_literal (type_name , "circle" ))
4470
4469
return PG_CIRCLE ;
4471
4470
4472
4471
return PG_UNKNOWN ;
@@ -4554,7 +4553,7 @@ static int php_pgsql_add_quotes(zval *src, bool should_free)
4554
4553
4555
4554
/* Raise E_NOTICE to E_WARNING or Error? */
4556
4555
#define PGSQL_CONV_CHECK_IGNORE () \
4557
- if (!err && Z_TYPE(new_val) == IS_STRING && !strcmp(Z_STRVAL (new_val), "NULL")) { \
4556
+ if (!err && Z_TYPE(new_val) == IS_STRING && zend_string_equals_literal(Z_STR (new_val), "NULL")) { \
4558
4557
/* if new_value is string "NULL" and field has default value, remove element to use default value */ \
4559
4558
if (!(opt & PGSQL_CONV_IGNORE_DEFAULT ) && Z_TYPE_P (has_default ) == IS_TRUE ) { \
4560
4559
zval_ptr_dtor (& new_val ); \
@@ -4636,7 +4635,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
4636
4635
/* enums need to be treated like strings */
4637
4636
data_type = PG_TEXT ;
4638
4637
} else {
4639
- data_type = php_pgsql_get_data_type (Z_STRVAL_P ( type ), Z_STRLEN_P (type ));
4638
+ data_type = php_pgsql_get_data_type (Z_STR_P (type ));
4640
4639
}
4641
4640
4642
4641
/* TODO: Should E_NOTICE be converted to type error if PHP type cannot be converted to field type? */
@@ -4649,18 +4648,18 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
4649
4648
ZVAL_STRING (& new_val , "NULL" );
4650
4649
}
4651
4650
else {
4652
- if (! strcmp ( Z_STRVAL_P (val ), "t" ) || ! strcmp ( Z_STRVAL_P (val ), "T" ) ||
4653
- ! strcmp ( Z_STRVAL_P (val ), "y" ) || ! strcmp ( Z_STRVAL_P (val ), "Y" ) ||
4654
- ! strcmp ( Z_STRVAL_P (val ), "true" ) || ! strcmp ( Z_STRVAL_P (val ), "True" ) ||
4655
- ! strcmp ( Z_STRVAL_P (val ), "yes" ) || ! strcmp ( Z_STRVAL_P (val ), "Yes" ) ||
4656
- ! strcmp ( Z_STRVAL_P (val ), "1" )) {
4651
+ if (zend_string_equals_literal ( Z_STR_P (val ), "t" ) || zend_string_equals_literal ( Z_STR_P (val ), "T" ) ||
4652
+ zend_string_equals_literal ( Z_STR_P (val ), "y" ) || zend_string_equals_literal ( Z_STR_P (val ), "Y" ) ||
4653
+ zend_string_equals_literal ( Z_STR_P (val ), "true" ) || zend_string_equals_literal ( Z_STR_P (val ), "True" ) ||
4654
+ zend_string_equals_literal ( Z_STR_P (val ), "yes" ) || zend_string_equals_literal ( Z_STR_P (val ), "Yes" ) ||
4655
+ zend_string_equals_literal ( Z_STR_P (val ), "1" )) {
4657
4656
ZVAL_STRINGL (& new_val , "'t'" , sizeof ("'t'" )- 1 );
4658
4657
}
4659
- else if (! strcmp ( Z_STRVAL_P (val ), "f" ) || ! strcmp ( Z_STRVAL_P (val ), "F" ) ||
4660
- ! strcmp ( Z_STRVAL_P (val ), "n" ) || ! strcmp ( Z_STRVAL_P (val ), "N" ) ||
4661
- ! strcmp ( Z_STRVAL_P (val ), "false" ) || ! strcmp ( Z_STRVAL_P (val ), "False" ) ||
4662
- ! strcmp ( Z_STRVAL_P (val ), "no" ) || ! strcmp ( Z_STRVAL_P (val ), "No" ) ||
4663
- ! strcmp ( Z_STRVAL_P (val ), "0" )) {
4658
+ else if (zend_string_equals_literal ( Z_STR_P (val ), "f" ) || zend_string_equals_literal ( Z_STR_P (val ), "F" ) ||
4659
+ zend_string_equals_literal ( Z_STR_P (val ), "n" ) || zend_string_equals_literal ( Z_STR_P (val ), "N" ) ||
4660
+ zend_string_equals_literal ( Z_STR_P (val ), "false" ) || zend_string_equals_literal ( Z_STR_P (val ), "False" ) ||
4661
+ zend_string_equals_literal ( Z_STR_P (val ), "no" ) || zend_string_equals_literal ( Z_STR_P (val ), "No" ) ||
4662
+ zend_string_equals_literal ( Z_STR_P (val ), "0" )) {
4664
4663
ZVAL_STRINGL (& new_val , "'f'" , sizeof ("'f'" )- 1 );
4665
4664
}
4666
4665
else {
@@ -5540,7 +5539,8 @@ static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr,
5540
5539
} else {
5541
5540
smart_str_appendl (querystr , ZSTR_VAL (fld ), ZSTR_LEN (fld ));
5542
5541
}
5543
- if (where_cond && (Z_TYPE_P (val ) == IS_TRUE || Z_TYPE_P (val ) == IS_FALSE || (Z_TYPE_P (val ) == IS_STRING && !strcmp (Z_STRVAL_P (val ), "NULL" )))) {
5542
+ if (where_cond && (Z_TYPE_P (val ) == IS_TRUE || Z_TYPE_P (val ) == IS_FALSE ||
5543
+ (Z_TYPE_P (val ) == IS_STRING && zend_string_equals_literal (Z_STR_P (val ), "NULL" )))) {
5544
5544
smart_str_appends (querystr , " IS " );
5545
5545
} else {
5546
5546
smart_str_appendc (querystr , '=' );
0 commit comments