@@ -278,11 +278,11 @@ static void _free_result(zend_resource *rsrc)
278
278
}
279
279
/* }}} */
280
280
281
- static int _php_pgsql_detect_identifier_escape (const char * identifier , size_t len ) /* {{{ */
281
+ static bool _php_pgsql_identifier_is_escaped (const char * identifier , size_t len ) /* {{{ */
282
282
{
283
283
/* Handle edge case. Cannot be a escaped string */
284
284
if (len <= 2 ) {
285
- return FAILURE ;
285
+ return false ;
286
286
}
287
287
/* Detect double quotes */
288
288
if (identifier [0 ] == '"' && identifier [len - 1 ] == '"' ) {
@@ -291,14 +291,14 @@ static int _php_pgsql_detect_identifier_escape(const char *identifier, size_t le
291
291
/* Detect wrong format of " inside of escaped string */
292
292
for (i = 1 ; i < len - 1 ; i ++ ) {
293
293
if (identifier [i ] == '"' && (identifier [++ i ] != '"' || i == len - 1 )) {
294
- return FAILURE ;
294
+ return false ;
295
295
}
296
296
}
297
297
} else {
298
- return FAILURE ;
298
+ return false ;
299
299
}
300
300
/* Escaped properly */
301
- return SUCCESS ;
301
+ return true ;
302
302
}
303
303
/* }}} */
304
304
@@ -5201,7 +5201,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
5201
5201
}
5202
5202
/* If field is NULL and HAS DEFAULT, should be skipped */
5203
5203
if (!skip_field ) {
5204
- if (_php_pgsql_detect_identifier_escape (ZSTR_VAL (field ), ZSTR_LEN (field )) == SUCCESS ) {
5204
+ if (_php_pgsql_identifier_is_escaped (ZSTR_VAL (field ), ZSTR_LEN (field ))) {
5205
5205
zend_hash_update (Z_ARRVAL_P (result ), field , & new_val );
5206
5206
} else {
5207
5207
char * escaped = PQescapeIdentifier (pg_link , ZSTR_VAL (field ), ZSTR_LEN (field ));
@@ -5292,7 +5292,7 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
5292
5292
/* schema.table should be "schema"."table" */
5293
5293
const char * dot = memchr (table , '.' , table_len );
5294
5294
size_t len = dot ? dot - table : table_len ;
5295
- if (_php_pgsql_detect_identifier_escape (table , len ) == SUCCESS ) {
5295
+ if (_php_pgsql_identifier_is_escaped (table , len )) {
5296
5296
smart_str_appendl (querystr , table , len );
5297
5297
} else {
5298
5298
char * escaped = PQescapeIdentifier (pg_link , table , len );
@@ -5303,7 +5303,7 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
5303
5303
const char * after_dot = dot + 1 ;
5304
5304
len = table_len - len - 1 ;
5305
5305
/* "schema"."table" format */
5306
- if (_php_pgsql_detect_identifier_escape (after_dot , len ) == SUCCESS ) {
5306
+ if (_php_pgsql_identifier_is_escaped (after_dot , len )) {
5307
5307
smart_str_appendc (querystr , '.' );
5308
5308
smart_str_appendl (querystr , after_dot , len );
5309
5309
} else {
0 commit comments