mirror of https://git.kore.io/kore.git
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 */
|
/* fallthrough */
|
||||||
case PYKORE_PGSQL_QUERY:
|
case PYKORE_PGSQL_QUERY:
|
||||||
if (!kore_pgsql_query_param_fields(&pysql->sql,
|
if (pysql->param.count > 0) {
|
||||||
pysql->query, pysql->binary,
|
if (!kore_pgsql_query_param_fields(&pysql->sql,
|
||||||
pysql->param.count, pysql->param.values,
|
pysql->query, pysql->binary,
|
||||||
pysql->param.lengths, pysql->param.formats)) {
|
pysql->param.count, pysql->param.values,
|
||||||
PyErr_Format(PyExc_RuntimeError,
|
pysql->param.lengths, pysql->param.formats)) {
|
||||||
"pgsql error: %s", pysql->sql.error);
|
PyErr_Format(PyExc_RuntimeError,
|
||||||
return (NULL);
|
"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;
|
pysql->state = PYKORE_PGSQL_WAIT;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue