mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 21:23:04 +01:00
1) Better organization between request and statement. 2) Consts.
This commit is contained in:
parent
124e614654
commit
173b23109c
@ -2533,6 +2533,14 @@ static dsql_req* prepareStatement(thread_db* tdbb, dsql_dbb* database, jrd_tra*
|
||||
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
|
||||
Arg::Gds(isc_malformed_string));
|
||||
}
|
||||
|
||||
UCharBuffer temp;
|
||||
|
||||
CsConvert conversor(charSet->getStruct(),
|
||||
INTL_charset_lookup(tdbb, CS_METADATA)->getStruct());
|
||||
conversor.convert(transformedText.length(), (const UCHAR*) transformedText.c_str(), temp);
|
||||
|
||||
transformedText.assign(temp.begin(), temp.getCount());
|
||||
}
|
||||
|
||||
statement->setSqlText(FB_NEW(pool) RefString(pool, transformedText));
|
||||
|
@ -555,6 +555,11 @@ DatabaseSnapshot::DatabaseSnapshot(thread_db* tdbb, MemoryPool& pool)
|
||||
// generic logic that covers all other relations
|
||||
else if (record && dbb_allowed && att_allowed)
|
||||
{
|
||||
// ASF: The statement text is always dumped in the metadata charset.
|
||||
AutoSetRestore<int> autoAttCharSet(&attachment_charset,
|
||||
rid == rel_mon_statements && fid == f_mon_stmt_sql_text ?
|
||||
ttype_metadata : attachment_charset);
|
||||
|
||||
putField(tdbb, record, dumpField, attachment_charset);
|
||||
fields_processed = true;
|
||||
dbb_processed = true;
|
||||
|
@ -52,7 +52,6 @@ JrdStatement::JrdStatement(thread_db* tdbb, MemoryPool* p, CompilerScratch* csb)
|
||||
fors(*p),
|
||||
execStmts(*p),
|
||||
invariants(*p),
|
||||
charset(CS_dynamic),
|
||||
blr(*p),
|
||||
mapFieldInfo(*p),
|
||||
mapItemInfo(*p)
|
||||
@ -61,7 +60,6 @@ JrdStatement::JrdStatement(thread_db* tdbb, MemoryPool* p, CompilerScratch* csb)
|
||||
accessList = csb->csb_access;
|
||||
externalList = csb->csb_external;
|
||||
mapFieldInfo.takeOwnership(csb->csb_map_field_info);
|
||||
charset = tdbb->getAttachment()->att_charset;
|
||||
resources = csb->csb_resources; // Assign array contents
|
||||
impureSize = csb->csb_impure;
|
||||
|
||||
@ -238,10 +236,7 @@ JrdStatement* JrdStatement::makeStatement(thread_db* tdbb, CompilerScratch* csb,
|
||||
}
|
||||
|
||||
if (internalFlag)
|
||||
{
|
||||
statement->charset = CS_METADATA;
|
||||
statement->flags |= FLAG_INTERNAL;
|
||||
}
|
||||
else
|
||||
tdbb->bumpStats(RuntimeStatistics::STMT_PREPARES);
|
||||
|
||||
@ -321,7 +316,7 @@ jrd_req* JrdStatement::findRequest(thread_db* tdbb)
|
||||
if (!clone)
|
||||
clone = getRequest(tdbb, n);
|
||||
|
||||
clone->req_attachment = attachment;
|
||||
clone->setAttachment(attachment);
|
||||
clone->req_stats.reset();
|
||||
clone->req_base_stats.reset();
|
||||
clone->req_flags |= req_in_use;
|
||||
@ -345,9 +340,8 @@ jrd_req* JrdStatement::getRequest(thread_db* tdbb, USHORT level)
|
||||
MemoryStats* const parentStats = (flags & FLAG_INTERNAL) ?
|
||||
&dbb->dbb_memory_stats : &attachment->att_memory_stats;
|
||||
|
||||
// Clone the request.
|
||||
jrd_req* request = FB_NEW(*pool) jrd_req(this, parentStats);
|
||||
request->req_attachment = attachment;
|
||||
// Create the request.
|
||||
jrd_req* request = FB_NEW(*pool) jrd_req(attachment, this, parentStats);
|
||||
request->req_id = fb_utils::genUniqueId();
|
||||
|
||||
requests[level] = request;
|
||||
|
@ -71,15 +71,14 @@ public:
|
||||
ExternalAccessList externalList; // Access to procedures/triggers to be checked
|
||||
AccessItemList accessList; // Access items to be checked
|
||||
ResourceList resources; // Resources (relations and indices)
|
||||
jrd_prc* procedure; // procedure, if any
|
||||
Function* function; // function, if any
|
||||
const jrd_prc* procedure; // procedure, if any
|
||||
const Function* function; // function, if any
|
||||
Firebird::MetaName triggerName; // name of request (trigger), if any
|
||||
jrd_nod* topNode; // top of execution tree
|
||||
Firebird::Array<RecordSource*> fors; // record sources
|
||||
Firebird::Array<const RecordSource*> fors; // record sources
|
||||
Firebird::Array<jrd_nod*> execStmts; // exec_into nodes
|
||||
Firebird::Array<jrd_nod*> invariants; // invariant nodes
|
||||
SSHORT charset; // Client charset for this request
|
||||
Firebird::RefStrPtr sqlText; // SQL text
|
||||
Firebird::RefStrPtr sqlText; // SQL text (encoded in the metadata charset)
|
||||
Firebird::Array<UCHAR> blr; // BLR for non-SQL query
|
||||
MapFieldInfo mapFieldInfo; // Map field name to field info
|
||||
MapItemInfo mapItemInfo; // Map item to item info
|
||||
|
@ -2143,8 +2143,7 @@ dsc* evlGetContext(thread_db* tdbb, const SysFunction*, jrd_nod* args,
|
||||
BLB_close(tdbb, blob);
|
||||
|
||||
dsc result;
|
||||
result.makeBlob(isc_blob_text, attachment->att_charset,
|
||||
(ISC_QUAD*) &impure->vlu_misc.vlu_bid);
|
||||
result.makeBlob(isc_blob_text, ttype_metadata, (ISC_QUAD*) &impure->vlu_misc.vlu_bid);
|
||||
EVL_make_value(tdbb, &result, impure);
|
||||
|
||||
request->req_flags &= ~req_null;
|
||||
|
@ -1458,7 +1458,7 @@ void EVL_validate(thread_db* tdbb, const Item& item, const ItemInfo* itemInfo, d
|
||||
|
||||
if (item.type == nod_variable)
|
||||
{
|
||||
jrd_prc* procedure = request->getStatement()->procedure;
|
||||
const jrd_prc* procedure = request->getStatement()->procedure;
|
||||
|
||||
if (procedure)
|
||||
{
|
||||
|
@ -931,7 +931,7 @@ void EXE_start(thread_db* tdbb, jrd_req* request, jrd_tra* transaction)
|
||||
ERR_post(Arg::Gds(isc_req_no_trans));
|
||||
|
||||
JrdStatement* statement = request->getStatement();
|
||||
jrd_prc* proc = statement->procedure;
|
||||
const jrd_prc* proc = statement->procedure;
|
||||
|
||||
if (proc && proc->isUndefined())
|
||||
{
|
||||
@ -1042,7 +1042,7 @@ void EXE_unwind(thread_db* tdbb, jrd_req* request)
|
||||
tdbb->setRequest(request);
|
||||
tdbb->setTransaction(request->req_transaction);
|
||||
|
||||
for (RecordSource* const* ptr = statement->fors.begin();
|
||||
for (const RecordSource* const* ptr = statement->fors.begin();
|
||||
ptr != statement->fors.end(); ++ptr)
|
||||
{
|
||||
(*ptr)->close(tdbb);
|
||||
|
@ -794,7 +794,7 @@ public:
|
||||
vec<jrd_nod*>* csb_variables; // Vector of variables, if any
|
||||
ResourceList csb_resources; // Resources (relations and indexes)
|
||||
NodeStack csb_dependencies; // objects this request depends upon
|
||||
Firebird::Array<RecordSource*> csb_fors; // record sources
|
||||
Firebird::Array<const RecordSource*> csb_fors; // record sources
|
||||
Firebird::Array<jrd_nod*> csb_exec_sta; // Array of exec_into nodes
|
||||
Firebird::Array<jrd_nod*> csb_invariants; // stack of invariant nodes
|
||||
Firebird::Array<jrd_node_base*> csb_current_nodes; // RecordSelExpr's and other invariant
|
||||
|
@ -6464,8 +6464,8 @@ void thread_db::setRequest(jrd_req* val)
|
||||
|
||||
SSHORT thread_db::getCharSet() const
|
||||
{
|
||||
if (request && request->getStatement()->charset != CS_dynamic)
|
||||
return request->getStatement()->charset;
|
||||
if (request && request->charSetId != CS_dynamic)
|
||||
return request->charSetId;
|
||||
|
||||
return attachment->att_charset;
|
||||
}
|
||||
|
@ -755,7 +755,7 @@ bool OPT_access_path(const jrd_req* request, UCHAR* buffer, SLONG buffer_length,
|
||||
|
||||
UCharBuffer infoBuffer;
|
||||
|
||||
Array<RecordSource*>& fors = request->getStatement()->fors;
|
||||
Array<const RecordSource*>& fors = request->getStatement()->fors;
|
||||
for (size_t i = 0; i < fors.getCount(); i++)
|
||||
fors[i]->dump(tdbb, infoBuffer);
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "../jrd/exe.h"
|
||||
#include "../jrd/sort.h"
|
||||
#include "../jrd/Attachment.h"
|
||||
#include "../jrd/JrdStatement.h"
|
||||
#include "../jrd/RecordNumber.h"
|
||||
#include "../jrd/ExtEngineManager.h"
|
||||
@ -198,7 +199,8 @@ private:
|
||||
class jrd_req : public pool_alloc<type_req>
|
||||
{
|
||||
public:
|
||||
jrd_req(/*const*/ JrdStatement* aStatement, Firebird::MemoryStats* parent_stats)
|
||||
jrd_req(Attachment* attachment, /*const*/ JrdStatement* aStatement,
|
||||
Firebird::MemoryStats* parent_stats)
|
||||
: statement(aStatement),
|
||||
req_pool(statement->pool),
|
||||
req_memory_stats(parent_stats),
|
||||
@ -213,6 +215,7 @@ public:
|
||||
req_rpb(*req_pool),
|
||||
impureArea(*req_pool)
|
||||
{
|
||||
setAttachment(attachment);
|
||||
req_rpb = statement->rpbsSetup;
|
||||
impureArea.grow(statement->impureSize);
|
||||
}
|
||||
@ -222,6 +225,13 @@ public:
|
||||
return statement;
|
||||
}
|
||||
|
||||
void setAttachment(Attachment* newAttachment)
|
||||
{
|
||||
req_attachment = newAttachment;
|
||||
charSetId = statement->flags & JrdStatement::FLAG_INTERNAL ?
|
||||
CS_METADATA : req_attachment->att_charset;
|
||||
}
|
||||
|
||||
private:
|
||||
/*const*/ JrdStatement* const statement;
|
||||
|
||||
@ -281,6 +291,7 @@ public:
|
||||
SortOwner req_sorts;
|
||||
Firebird::Array<record_param> req_rpb; // record parameter blocks
|
||||
Firebird::Array<UCHAR> impureArea; // impure area
|
||||
USHORT charSetId; // "client" character set of the request
|
||||
|
||||
enum req_ta {
|
||||
// Order should be maintained because the numbers are stored in BLR
|
||||
|
Loading…
Reference in New Issue
Block a user