mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 04:29:02 -04:00
Python: Only use parameters if needed.
We always called kore_pgsql_query_param_fields() regardless if the params keyword was specified or not, instead only use it if actual parameters have been given. Otherwise use the kore_pgsql_query() function directly to execute the query.
This commit is contained in:
parent
0ac54eb48d
commit
599835e7fd
22
src/python.c
22
src/python.c
@ -5595,13 +5595,21 @@ pykore_pgsql_iternext(struct pykore_pgsql *pysql)
|
||||
}
|
||||
/* fallthrough */
|
||||
case PYKORE_PGSQL_QUERY:
|
||||
if (!kore_pgsql_query_param_fields(&pysql->sql,
|
||||
pysql->query, pysql->binary,
|
||||
pysql->param.count, pysql->param.values,
|
||||
pysql->param.lengths, pysql->param.formats)) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"pgsql error: %s", pysql->sql.error);
|
||||
return (NULL);
|
||||
if (pysql->param.count > 0) {
|
||||
if (!kore_pgsql_query_param_fields(&pysql->sql,
|
||||
pysql->query, pysql->binary,
|
||||
pysql->param.count, pysql->param.values,
|
||||
pysql->param.lengths, pysql->param.formats)) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"pgsql error: %s", pysql->sql.error);
|
||||
return (NULL);
|
||||
}
|
||||
} else {
|
||||
if (!kore_pgsql_query(&pysql->sql, pysql->query)) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"pgsql error: %s", pysql->sql.error);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
pysql->state = PYKORE_PGSQL_WAIT;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user