From d8673a1623e33bbb7a557dd0ba5cdfc80dcc5a6d Mon Sep 17 00:00:00 2001 From: Iqbal Hassan Date: Tue, 9 Jan 2024 15:35:14 +0800 Subject: [PATCH] Only prepare for describe if statement type is 'SELECT' for Oracle backend --- src/backends/oracle/statement.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/backends/oracle/statement.cpp b/src/backends/oracle/statement.cpp index b0a4815cf..086a16743 100644 --- a/src/backends/oracle/statement.cpp +++ b/src/backends/oracle/statement.cpp @@ -164,21 +164,34 @@ std::string oracle_statement_backend::rewrite_for_procedure_call( int oracle_statement_backend::prepare_for_describe() { - sword res = OCIStmtExecute(session_.svchp_, stmtp_, session_.errhp_, - 1, 0, 0, 0, OCI_DESCRIBE_ONLY); + ub2 statementType = 0; + sword res = OCIAttrGet(static_cast(stmtp_), + static_cast(OCI_HTYPE_STMT), static_cast(&statementType), + 0, static_cast(OCI_ATTR_STMT_TYPE), session_.errhp_); if (res != OCI_SUCCESS) { throw_oracle_soci_error(res, session_.errhp_); } - int cols; - res = OCIAttrGet(static_cast(stmtp_), - static_cast(OCI_HTYPE_STMT), static_cast(&cols), - 0, static_cast(OCI_ATTR_PARAM_COUNT), session_.errhp_); - - if (res != OCI_SUCCESS) + int cols = 0; + if (statementType == OCI_STMT_SELECT) { - throw_oracle_soci_error(res, session_.errhp_); + res = OCIStmtExecute(session_.svchp_, stmtp_, session_.errhp_, + 1, 0, 0, 0, OCI_DESCRIBE_ONLY); + if (res != OCI_SUCCESS) + { + throw_oracle_soci_error(res, session_.errhp_); + } + + int cols; + res = OCIAttrGet(static_cast(stmtp_), + static_cast(OCI_HTYPE_STMT), static_cast(&cols), + 0, static_cast(OCI_ATTR_PARAM_COUNT), session_.errhp_); + + if (res != OCI_SUCCESS) + { + throw_oracle_soci_error(res, session_.errhp_); + } } return cols;