diff options
Diffstat (limited to 'ext/pgsql/pgsql.c')
-rw-r--r-- | ext/pgsql/pgsql.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 704a919712..5681d2f2a8 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -1364,7 +1364,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) /* hash it up */ new_le.type = le_plink; new_le.ptr = pgsql; - if (zend_hash_str_update_mem(&EG(persistent_list), str.s->val, str.s->len, &new_le, sizeof(zend_resource)) == NULL) { + if (zend_hash_str_update_mem(&EG(persistent_list), ZSTR_VAL(str.s), ZSTR_LEN(str.s), &new_le, sizeof(zend_resource)) == NULL) { goto err; } PGG(num_links)++; @@ -2368,7 +2368,7 @@ static char *get_field_name(PGconn *pgsql, Oid oid, HashTable *list) continue; } - str.s->len = 0; + ZSTR_LEN(str.s) = 0; smart_str_appends(&str, "pgsql_oid_"); smart_str_appends(&str, tmp_oid); smart_str_0(&str); @@ -2453,7 +2453,7 @@ PHP_FUNCTION(pg_field_table) smart_str_append_unsigned(&querystr, oid); smart_str_0(&querystr); - if ((tmp_res = PQexec(pg_result->conn, querystr.s->val)) == NULL || PQresultStatus(tmp_res) != PGRES_TUPLES_OK) { + if ((tmp_res = PQexec(pg_result->conn, ZSTR_VAL(querystr.s))) == NULL || PQresultStatus(tmp_res) != PGRES_TUPLES_OK) { if (tmp_res) { PQclear(tmp_res); } @@ -2696,7 +2696,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_ ce = zend_fetch_class(class_name, ZEND_FETCH_CLASS_AUTO); } if (!ce) { - php_error_docref(NULL, E_WARNING, "Could not find class '%s'", class_name->val); + php_error_docref(NULL, E_WARNING, "Could not find class '%s'", ZSTR_VAL(class_name)); return; } result_type = PGSQL_ASSOC; @@ -3507,13 +3507,13 @@ PHP_FUNCTION(pg_lo_read) } buf = zend_string_alloc(buf_len, 0); - if ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf->val, buf->len))<0) { + if ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, ZSTR_VAL(buf), ZSTR_LEN(buf)))<0) { zend_string_free(buf); RETURN_FALSE; } - buf->len = nbytes; - buf->val[buf->len] = '\0'; + ZSTR_LEN(buf) = nbytes; + ZSTR_VAL(buf)[ZSTR_LEN(buf)] = '\0'; RETURN_NEW_STR(buf); } /* }}} */ @@ -4348,20 +4348,20 @@ PHP_FUNCTION(pg_escape_string) break; } - to = zend_string_alloc(from->len * 2, 0); + to = zend_string_alloc(ZSTR_LEN(from) * 2, 0); #ifdef HAVE_PQESCAPE_CONN if (link) { if ((pgsql = (PGconn *)zend_fetch_resource2(link, "PostgreSQL link", le_link, le_plink)) == NULL) { RETURN_FALSE; } - to->len = PQescapeStringConn(pgsql, to->val, from->val, from->len, NULL); + ZSTR_LEN(to) = PQescapeStringConn(pgsql, ZSTR_VAL(to), ZSTR_VAL(from), ZSTR_LEN(from), NULL); } else #endif { - to->len = PQescapeString(to->val, from->val, from->len); + ZSTR_LEN(to) = PQescapeString(ZSTR_VAL(to), ZSTR_VAL(from), ZSTR_LEN(from)); } - to = zend_string_truncate(to, to->len, 0); + to = zend_string_truncate(to, ZSTR_LEN(to), 0); RETURN_NEW_STR(to); } /* }}} */ @@ -5553,7 +5553,7 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z smart_str_0(&querystr); efree(src); - pg_result = PQexec(pg_link, querystr.s->val); + pg_result = PQexec(pg_link, ZSTR_VAL(querystr.s)); if (PQresultStatus(pg_result) != PGRES_TUPLES_OK || (num_rows = PQntuples(pg_result)) == 0) { php_error_docref(NULL, E_WARNING, "Table '%s' doesn't exists", table_name); smart_str_free(&querystr); @@ -5792,7 +5792,7 @@ static int php_pgsql_add_quotes(zval *src, zend_bool should_free) } \ /* raise error if it's not null and cannot be ignored */ \ else if (!(opt & PGSQL_CONV_IGNORE_NOT_NULL) && Z_TYPE_P(not_null) == IS_TRUE) { \ - php_error_docref(NULL, E_NOTICE, "Detected NULL for 'NOT NULL' field '%s'", field->val); \ + php_error_docref(NULL, E_NOTICE, "Detected NULL for 'NOT NULL' field '%s'", ZSTR_VAL(field)); \ err = 1; \ } \ } @@ -5834,7 +5834,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } if (!err && (def = zend_hash_find(Z_ARRVAL(meta), field)) == NULL) { - php_error_docref(NULL, E_NOTICE, "Invalid field name (%s) in values", field->val); + php_error_docref(NULL, E_NOTICE, "Invalid field name (%s) in values", ZSTR_VAL(field)); err = 1; } if (!err && (type = zend_hash_str_find(Z_ARRVAL_P(def), "type", sizeof("type") - 1)) == NULL) { @@ -5893,7 +5893,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con ZVAL_STRINGL(&new_val, "'f'", sizeof("'f'")-1); } else { - php_error_docref(NULL, E_NOTICE, "Detected invalid value (%s) for PostgreSQL %s field (%s)", Z_STRVAL_P(val), Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Detected invalid value (%s) for PostgreSQL %s field (%s)", Z_STRVAL_P(val), Z_STRVAL_P(type), ZSTR_VAL(field)); err = 1; } } @@ -5925,7 +5925,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects string, null, long or boolelan value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects string, null, long or boolelan value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -5967,7 +5967,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for pgsql '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for pgsql '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6013,7 +6013,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6050,8 +6050,8 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con /* PostgreSQL ignores \0 */ str = zend_string_alloc(Z_STRLEN_P(val) * 2, 0); /* better to use PGSQLescapeLiteral since PGescapeStringConn does not handle special \ */ - str->len = PQescapeStringConn(pg_link, str->val, Z_STRVAL_P(val), Z_STRLEN_P(val), NULL); - str = zend_string_truncate(str, str->len, 0); + ZSTR_LEN(str) = PQescapeStringConn(pg_link, ZSTR_VAL(str), Z_STRVAL_P(val), Z_STRLEN_P(val), NULL); + str = zend_string_truncate(str, ZSTR_LEN(str), 0); ZVAL_NEW_STR(&new_val, str); php_pgsql_add_quotes(&new_val, 1); } @@ -6076,7 +6076,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6118,7 +6118,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6150,7 +6150,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6183,7 +6183,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6214,7 +6214,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6245,7 +6245,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6324,7 +6324,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; #ifdef HAVE_PQESCAPE @@ -6372,7 +6372,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6403,13 +6403,13 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; default: /* should not happen */ - php_error_docref(NULL, E_NOTICE, "Unknown or system data type '%s' for '%s'. Report error", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Unknown or system data type '%s' for '%s'. Report error", Z_STRVAL_P(type), ZSTR_VAL(field)); err = 1; break; } /* switch */ @@ -6422,10 +6422,10 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con if (!skip_field) { char *escaped; - if (_php_pgsql_detect_identifier_escape(field->val, field->len) == SUCCESS) { + if (_php_pgsql_detect_identifier_escape(ZSTR_VAL(field), ZSTR_LEN(field)) == SUCCESS) { zend_hash_update(Z_ARRVAL_P(result), field, &new_val); } else { - escaped = PGSQLescapeIdentifier(pg_link, field->val, field->len); + escaped = PGSQLescapeIdentifier(pg_link, ZSTR_VAL(field), ZSTR_LEN(field)); add_assoc_zval(result, escaped, &new_val); PGSQLfree(escaped); } @@ -6483,14 +6483,14 @@ PHP_FUNCTION(pg_convert) static int do_exec(smart_str *querystr, int expect, PGconn *pg_link, zend_ulong opt) /* {{{ */ { if (opt & PGSQL_DML_ASYNC) { - if (PQsendQuery(pg_link, querystr->s->val)) { + if (PQsendQuery(pg_link, ZSTR_VAL(querystr->s))) { return 0; } } else { PGresult *pg_result; - pg_result = PQexec(pg_link, querystr->s->val); + pg_result = PQexec(pg_link, ZSTR_VAL(querystr->s)); if (PQresultStatus(pg_result) == expect) { PQclear(pg_result); return 0; @@ -6585,15 +6585,15 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var goto cleanup; } if (opt & PGSQL_DML_ESCAPE) { - tmp = PGSQLescapeIdentifier(pg_link, fld->val, fld->len + 1); + tmp = PGSQLescapeIdentifier(pg_link, ZSTR_VAL(fld), ZSTR_LEN(fld) + 1); smart_str_appends(&querystr, tmp); PGSQLfree(tmp); } else { - smart_str_appendl(&querystr, fld->val, fld->len); + smart_str_appendl(&querystr, ZSTR_VAL(fld), ZSTR_LEN(fld)); } smart_str_appendc(&querystr, ','); } ZEND_HASH_FOREACH_END(); - querystr.s->len--; + ZSTR_LEN(querystr.s)--; smart_str_appends(&querystr, ") VALUES ("); /* make values string */ @@ -6631,7 +6631,7 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var smart_str_appendc(&querystr, ','); } ZEND_HASH_FOREACH_END(); /* Remove the trailing "," */ - querystr.s->len--; + ZSTR_LEN(querystr.s)--; smart_str_appends(&querystr, ");"); no_values: @@ -6696,11 +6696,11 @@ PHP_FUNCTION(pg_insert) if (php_pgsql_insert(pg_link, table, values, option|PGSQL_DML_STRING, &sql) == FAILURE) { RETURN_FALSE; } - pg_result = PQexec(pg_link, sql->val); + pg_result = PQexec(pg_link, ZSTR_VAL(sql)); if ((PGG(auto_reset_persistent) & 2) && PQstatus(pg_link) != CONNECTION_OK) { PQclear(pg_result); PQreset(pg_link); - pg_result = PQexec(pg_link, sql->val); + pg_result = PQexec(pg_link, ZSTR_VAL(sql)); } efree(sql); @@ -6758,11 +6758,11 @@ static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr, return -1; } if (opt & PGSQL_DML_ESCAPE) { - tmp = PGSQLescapeIdentifier(pg_link, fld->val, fld->len + 1); + tmp = PGSQLescapeIdentifier(pg_link, ZSTR_VAL(fld), ZSTR_LEN(fld) + 1); smart_str_appends(querystr, tmp); PGSQLfree(tmp); } else { - smart_str_appendl(querystr, fld->val, fld->len); + smart_str_appendl(querystr, ZSTR_VAL(fld), ZSTR_LEN(fld)); } 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")))) { smart_str_appends(querystr, " IS "); @@ -6800,7 +6800,7 @@ static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr, smart_str_appendl(querystr, pad, pad_len); } ZEND_HASH_FOREACH_END(); if (querystr->s) { - querystr->s->len -= pad_len; + ZSTR_LEN(querystr->s) -= pad_len; } return 0; @@ -7079,11 +7079,11 @@ PHP_PGSQL_API int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids smart_str_appendc(&querystr, ';'); smart_str_0(&querystr); - pg_result = PQexec(pg_link, querystr.s->val); + pg_result = PQexec(pg_link, ZSTR_VAL(querystr.s)); if (PQresultStatus(pg_result) == PGRES_TUPLES_OK) { ret = php_pgsql_result2array(pg_result, ret_array); } else { - php_error_docref(NULL, E_NOTICE, "Failed to execute '%s'", querystr.s->val); + php_error_docref(NULL, E_NOTICE, "Failed to execute '%s'", ZSTR_VAL(querystr.s)); } PQclear(pg_result); |