void PreparedStatement::init(thread_db* tdbb, Attachment* attachment, jrd_tra* transaction, const Firebird::string& text, bool isInternalRequest) { AutoSetRestore<SSHORT> autoAttCharset(&attachment->att_charset, (isInternalRequest ? CS_METADATA : attachment->att_charset)); request = NULL; try { const Database& dbb = *tdbb->getDatabase(); const int dialect = isInternalRequest || (dbb.dbb_flags & DBB_DB_SQL_dialect_3) ? SQL_DIALECT_V6 : SQL_DIALECT_V5; request = DSQL_prepare(tdbb, attachment, transaction, text.length(), text.c_str(), dialect, NULL, NULL, isInternalRequest); const DsqlCompiledStatement* statement = request->getStatement(); if (statement->getSendMsg()) parseDsqlMessage(statement->getSendMsg(), inValues, inMetadata, inMessage); if (statement->getReceiveMsg()) parseDsqlMessage(statement->getReceiveMsg(), outValues, outMetadata, outMessage); } catch (const Exception&) { if (request) { DSQL_free_statement(tdbb, request, DSQL_drop); } throw; } }
PreparedStatement::~PreparedStatement() { thread_db* tdbb = JRD_get_thread_data(); DSQL_free_statement(tdbb, request, DSQL_drop); if (resultSet) resultSet->stmt = NULL; }
ResultSet::~ResultSet() { if (!stmt) return; thread_db* tdbb = JRD_get_thread_data(); stmt->resultSet = NULL; if (stmt->request->req_type != REQ_EXEC_PROCEDURE) DSQL_free_statement(tdbb, stmt->request, DSQL_close); }
ResultSet::~ResultSet() { if (!stmt) return; thread_db* tdbb = JRD_get_thread_data(); stmt->resultSet = NULL; if (stmt->request->getStatement()->getType() != DsqlCompiledStatement::TYPE_EXEC_PROCEDURE) DSQL_free_statement(tdbb, stmt->request, DSQL_close); }