mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
PDO: Store/pass query_string as zend_string
Rather than storing char* + size_t, use a zend_string*. Also avoid various copies of the query string.
This commit is contained in:
parent
c288b5294b
commit
2d51c203f0
15 changed files with 81 additions and 102 deletions
|
@ -100,7 +100,7 @@ static int pgsql_stmt_dtor(pdo_stmt_t *stmt)
|
|||
S->param_types = NULL;
|
||||
}
|
||||
if (S->query) {
|
||||
efree(S->query);
|
||||
zend_string_release(S->query);
|
||||
S->query = NULL;
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ static int pgsql_stmt_execute(pdo_stmt_t *stmt)
|
|||
efree(q);
|
||||
}
|
||||
|
||||
spprintf(&q, 0, "DECLARE %s SCROLL CURSOR WITH HOLD FOR %s", S->cursor_name, stmt->active_query_string);
|
||||
spprintf(&q, 0, "DECLARE %s SCROLL CURSOR WITH HOLD FOR %s", S->cursor_name, ZSTR_VAL(stmt->active_query_string));
|
||||
S->result = PQexec(H->server, q);
|
||||
efree(q);
|
||||
|
||||
|
@ -177,7 +177,7 @@ static int pgsql_stmt_execute(pdo_stmt_t *stmt)
|
|||
stmt_retry:
|
||||
/* we deferred the prepare until now, because we didn't
|
||||
* know anything about the parameter types; now we do */
|
||||
S->result = PQprepare(H->server, S->stmt_name, S->query,
|
||||
S->result = PQprepare(H->server, S->stmt_name, ZSTR_VAL(S->query),
|
||||
stmt->bound_params ? zend_hash_num_elements(stmt->bound_params) : 0,
|
||||
S->param_types);
|
||||
status = PQresultStatus(S->result);
|
||||
|
@ -222,7 +222,7 @@ stmt_retry:
|
|||
0);
|
||||
} else if (stmt->supports_placeholders == PDO_PLACEHOLDER_NAMED) {
|
||||
/* execute query with parameters */
|
||||
S->result = PQexecParams(H->server, S->query,
|
||||
S->result = PQexecParams(H->server, ZSTR_VAL(S->query),
|
||||
stmt->bound_params ? zend_hash_num_elements(stmt->bound_params) : 0,
|
||||
S->param_types,
|
||||
(const char**)S->param_values,
|
||||
|
@ -231,7 +231,7 @@ stmt_retry:
|
|||
0);
|
||||
} else {
|
||||
/* execute plain query (with embedded parameters) */
|
||||
S->result = PQexec(H->server, stmt->active_query_string);
|
||||
S->result = PQexec(H->server, ZSTR_VAL(stmt->active_query_string));
|
||||
}
|
||||
status = PQresultStatus(S->result);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue