mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 13:23:02 +01:00
Some syntactic sugar
This commit is contained in:
parent
9545ef40f8
commit
7ff112a901
@ -593,8 +593,7 @@ void CommentOnNode::execute(thread_db* tdbb, jrd_tra* transaction)
|
||||
if (addWhere.hasData())
|
||||
sqlStmt += " and " + addWhere;
|
||||
|
||||
AutoPtr<PreparedStatement> ps(attachment->prepareStatement(tdbb,
|
||||
*tdbb->getDefaultPool(), transaction, sqlStmt));
|
||||
AutoPreparedStatement ps(attachment->prepareStatement(tdbb, transaction, sqlStmt));
|
||||
|
||||
int n = 0;
|
||||
|
||||
|
@ -161,24 +161,27 @@ Jrd::Attachment::~Attachment()
|
||||
}
|
||||
|
||||
|
||||
Jrd::PreparedStatement* Jrd::Attachment::prepareStatement(thread_db* tdbb, MemoryPool& pool,
|
||||
jrd_tra* transaction, const string& text)
|
||||
Jrd::PreparedStatement* Jrd::Attachment::prepareStatement(thread_db* tdbb, jrd_tra* transaction,
|
||||
const string& text, Firebird::MemoryPool* pool)
|
||||
{
|
||||
return FB_NEW(pool) PreparedStatement(tdbb, pool, this, transaction, text, true);
|
||||
pool = pool ? pool : tdbb->getDefaultPool();
|
||||
return FB_NEW(*pool) PreparedStatement(tdbb, *pool, this, transaction, text, true);
|
||||
}
|
||||
|
||||
|
||||
Jrd::PreparedStatement* Jrd::Attachment::prepareStatement(thread_db* tdbb, MemoryPool& pool,
|
||||
jrd_tra* transaction, const PreparedStatement::Builder& builder)
|
||||
Jrd::PreparedStatement* Jrd::Attachment::prepareStatement(thread_db* tdbb, jrd_tra* transaction,
|
||||
const PreparedStatement::Builder& builder, Firebird::MemoryPool* pool)
|
||||
{
|
||||
return FB_NEW(pool) PreparedStatement(tdbb, pool, this, transaction, builder, true);
|
||||
pool = pool ? pool : tdbb->getDefaultPool();
|
||||
return FB_NEW(*pool) PreparedStatement(tdbb, *pool, this, transaction, builder, true);
|
||||
}
|
||||
|
||||
|
||||
PreparedStatement* Jrd::Attachment::prepareUserStatement(thread_db* tdbb, MemoryPool& pool,
|
||||
jrd_tra* transaction, const string& text)
|
||||
PreparedStatement* Jrd::Attachment::prepareUserStatement(thread_db* tdbb, jrd_tra* transaction,
|
||||
const string& text, Firebird::MemoryPool* pool)
|
||||
{
|
||||
return FB_NEW(pool) PreparedStatement(tdbb, pool, this, transaction, text, false);
|
||||
pool = pool ? pool : tdbb->getDefaultPool();
|
||||
return FB_NEW(*pool) PreparedStatement(tdbb, *pool, this, transaction, text, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -176,13 +176,13 @@ public:
|
||||
|
||||
bool locksmith() const;
|
||||
|
||||
PreparedStatement* prepareStatement(thread_db* tdbb, Firebird::MemoryPool& pool,
|
||||
jrd_tra* transaction, const Firebird::string& text);
|
||||
PreparedStatement* prepareStatement(thread_db* tdbb, Firebird::MemoryPool& pool,
|
||||
jrd_tra* transaction, const PreparedStatement::Builder& builder);
|
||||
PreparedStatement* prepareStatement(thread_db* tdbb, jrd_tra* transaction,
|
||||
const Firebird::string& text, Firebird::MemoryPool* pool = NULL);
|
||||
PreparedStatement* prepareStatement(thread_db* tdbb, jrd_tra* transaction,
|
||||
const PreparedStatement::Builder& builder, Firebird::MemoryPool* pool = NULL);
|
||||
|
||||
PreparedStatement* prepareUserStatement(thread_db* tdbb, Firebird::MemoryPool& pool,
|
||||
jrd_tra* transaction, const Firebird::string& text);
|
||||
PreparedStatement* prepareUserStatement(thread_db* tdbb, jrd_tra* transaction,
|
||||
const Firebird::string& text, Firebird::MemoryPool* pool = NULL);
|
||||
|
||||
Firebird::MetaName nameToMetaCharSet(thread_db* tdbb, const Firebird::MetaName& name);
|
||||
Firebird::MetaName nameToUserCharSet(thread_db* tdbb, const Firebird::MetaName& name);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "../jrd/dsc.h"
|
||||
#include "../common/classes/alloc.h"
|
||||
#include "../common/classes/array.h"
|
||||
#include "../common/classes/auto.h"
|
||||
#include "../common/classes/fb_string.h"
|
||||
#include "../common/classes/MetaName.h"
|
||||
#include "../common/classes/TriState.h"
|
||||
@ -314,6 +315,8 @@ private:
|
||||
ResultSet* resultSet;
|
||||
};
|
||||
|
||||
typedef Firebird::AutoPtr<PreparedStatement> AutoPreparedStatement;
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
#ifndef JRD_RESULT_SET_H
|
||||
#define JRD_RESULT_SET_H
|
||||
|
||||
#include "../common/classes/auto.h"
|
||||
|
||||
struct dsc;
|
||||
|
||||
namespace Jrd {
|
||||
@ -52,6 +54,8 @@ private:
|
||||
bool firstFetchDone;
|
||||
};
|
||||
|
||||
typedef Firebird::AutoPtr<ResultSet> AutoResultSet;
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -2240,9 +2240,8 @@ static bool modify_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
|
||||
<< sql("rel.rdb$relation_type", rdbRelationType)
|
||||
<< "from rdb$indices idx join rdb$relations rel using (rdb$relation_name)"
|
||||
<< "where idx.rdb$index_name = " << work->dfw_name;
|
||||
AutoPtr<PreparedStatement> ps(attachment->prepareStatement(
|
||||
tdbb, *tdbb->getDefaultPool(), dbb->dbb_sys_trans, sql));
|
||||
AutoPtr<ResultSet> rs(ps->executeQuery(tdbb, dbb->dbb_sys_trans));
|
||||
AutoPreparedStatement ps(attachment->prepareStatement(tdbb, dbb->dbb_sys_trans, sql));
|
||||
AutoResultSet rs(ps->executeQuery(tdbb, dbb->dbb_sys_trans));
|
||||
|
||||
while (rs->fetch(tdbb))
|
||||
{
|
||||
|
@ -188,7 +188,7 @@ void DYN_modify_database( Global* gbl, const UCHAR** ptr)
|
||||
PreparedStatement::escapeName(collation).c_str());
|
||||
|
||||
AutoPtr<PreparedStatement> ps(attachment->prepareStatement(tdbb,
|
||||
*tdbb->getDefaultPool(), gbl->gbl_transaction, sql));
|
||||
gbl->gbl_transaction, sql));
|
||||
ps->execute(tdbb, gbl->gbl_transaction);
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ void ExecuteStatement::execute(Jrd::thread_db* tdbb, jrd_req* request, DSC* desc
|
||||
try
|
||||
{
|
||||
AutoPtr<PreparedStatement> stmt(attachment->prepareUserStatement(
|
||||
tdbb, *tdbb->getDefaultPool(), transaction, sqlStatementText));
|
||||
tdbb, transaction, sqlStatementText));
|
||||
|
||||
// Other requests appear to be incorrect in this context
|
||||
const long requests =
|
||||
@ -139,8 +139,7 @@ void ExecuteStatement::open(thread_db* tdbb, jrd_nod* sql, SSHORT nVars, bool si
|
||||
|
||||
try
|
||||
{
|
||||
stmt = attachment->prepareUserStatement(tdbb, *tdbb->getDefaultPool(),
|
||||
transaction, sqlText);
|
||||
stmt = attachment->prepareUserStatement(tdbb, transaction, sqlText);
|
||||
|
||||
if (stmt->getResultCount() == 0)
|
||||
{
|
||||
|
@ -300,8 +300,7 @@ void INI_format(const TEXT* owner, const TEXT* charset)
|
||||
<< "values (" << rdbRelationId << ", " << rdbRelationName << ", " << rdbFieldId << ", 0,"
|
||||
<< rdbSystemFlag << ", 8, " << ownerName << ", " << rdbRelationType << ")";
|
||||
|
||||
AutoPtr<PreparedStatement> ps(attachment->prepareStatement(
|
||||
tdbb, *tdbb->getDefaultPool(), transaction, sql));
|
||||
AutoPreparedStatement ps(attachment->prepareStatement(tdbb, transaction, sql));
|
||||
|
||||
jrd_req* handle1 = NULL;
|
||||
for (const int* relfld = relfields; relfld[RFLD_R_NAME]; relfld = fld + 1)
|
||||
@ -337,7 +336,7 @@ void INI_format(const TEXT* owner, const TEXT* charset)
|
||||
sql << "insert into rdb$database (rdb$relation_id, rdb$character_set_name) values ("
|
||||
<< rdbRelationId << ", " << rdbCharSetName << ")";
|
||||
|
||||
ps.reset(attachment->prepareStatement(tdbb, *tdbb->getDefaultPool(), transaction, sql));
|
||||
ps.reset(attachment->prepareStatement(tdbb, transaction, sql));
|
||||
|
||||
rdbRelationId = USER_DEF_REL_INIT_ID;
|
||||
ps->execute(tdbb, transaction);
|
||||
|
Loading…
Reference in New Issue
Block a user