mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 18:43:03 +01:00
Cached charsets by id (not only by name) in dsql. Removed irq_cs_bpc request as unneeded anymore
This commit is contained in:
parent
75019cbb15
commit
f89e461887
@ -4136,7 +4136,7 @@ static dsql_dbb* init(FB_API_HANDLE* db_handle)
|
||||
}
|
||||
|
||||
DsqlMemoryPool* pool = DsqlMemoryPool::createPool();
|
||||
database = FB_NEW(*pool) dsql_dbb;
|
||||
database = FB_NEW(*pool) dsql_dbb(*pool);
|
||||
database->dbb_pool = pool;
|
||||
database->dbb_next = databases;
|
||||
databases = database;
|
||||
|
@ -109,6 +109,7 @@ inline blk* LLS_POP(dsql_lls** stack)
|
||||
class dsql_ctx;
|
||||
class dsql_str;
|
||||
class dsql_nod;
|
||||
class dsql_intlsym;
|
||||
typedef Firebird::Stack<dsql_ctx*> DsqlContextStack;
|
||||
typedef Firebird::Stack<dsql_str*> DsqlStrStack;
|
||||
typedef Firebird::Stack<dsql_nod*> DsqlNodStack;
|
||||
@ -140,12 +141,11 @@ enum irq_type_t {
|
||||
irq_col_default = 14, //!< lookup default for a column
|
||||
irq_domain_2 = 15, //!< lookup a domain
|
||||
irq_exception = 16, //!< lookup an exception
|
||||
irq_cs_bpc = 17, //!< lookup a charset bpc
|
||||
irq_cs_name = 18, //!< lookup a charset name
|
||||
irq_default_cs = 19, //!< lookup the default charset
|
||||
irq_rel_ids = 20, //!< check relation/field ids
|
||||
irq_cs_name = 17, //!< lookup a charset name
|
||||
irq_default_cs = 18, //!< lookup the default charset
|
||||
irq_rel_ids = 19, //!< check relation/field ids
|
||||
|
||||
irq_MAX = 21
|
||||
irq_MAX = 20
|
||||
};
|
||||
|
||||
// dsql_nod definition
|
||||
@ -154,6 +154,15 @@ enum irq_type_t {
|
||||
// blocks used to cache metadata
|
||||
|
||||
//! Database Block
|
||||
typedef Firebird::SortedArray
|
||||
<
|
||||
dsql_intlsym*,
|
||||
Firebird::EmptyStorage<dsql_intlsym*>,
|
||||
SSHORT,
|
||||
dsql_intlsym,
|
||||
Firebird::DefaultComparator<SSHORT>
|
||||
> IntlSymArray;
|
||||
|
||||
class dsql_dbb : public pool_alloc<dsql_type_dbb>
|
||||
{
|
||||
public:
|
||||
@ -169,6 +178,11 @@ public:
|
||||
USHORT dbb_flags;
|
||||
USHORT dbb_db_SQL_dialect;
|
||||
SSHORT dbb_att_charset; //!< characterset at time of attachment
|
||||
IntlSymArray dbb_charsets_by_id; // charsets sorted by charset_id
|
||||
|
||||
dsql_dbb(DsqlMemoryPool& p) :
|
||||
dbb_charsets_by_id(p, 16)
|
||||
{};
|
||||
};
|
||||
|
||||
//! values used in dbb_flags
|
||||
@ -341,6 +355,9 @@ public:
|
||||
SSHORT intlsym_collate_id;
|
||||
USHORT intlsym_bytes_per_char;
|
||||
TEXT intlsym_name[2];
|
||||
|
||||
static const SSHORT generate(const void*, const dsql_intlsym* Item)
|
||||
{ return Item->intlsym_charset_id; }
|
||||
};
|
||||
|
||||
// values used in intlsym_type
|
||||
|
@ -576,6 +576,8 @@ dsql_intlsym* METD_get_charset(dsql_req* request, USHORT length, const char* nam
|
||||
symbol->sym_dbb = dbb;
|
||||
HSHD_insert(symbol);
|
||||
|
||||
dbb->dbb_charsets_by_id.add(iname);
|
||||
|
||||
return iname;
|
||||
}
|
||||
|
||||
@ -596,37 +598,26 @@ USHORT METD_get_charset_bpc(dsql_req* request, SSHORT charset_id)
|
||||
* charset' id, not by name.
|
||||
*
|
||||
**************************************/
|
||||
dsql_dbb* dbb;
|
||||
USHORT bpc = 0;
|
||||
|
||||
dsql_dbb* dbb;
|
||||
USHORT bpc = 0;
|
||||
|
||||
ISC_STATUS_ARRAY isc_status = {0};
|
||||
dbb = request->req_dbb;
|
||||
isc_db_handle DB = dbb->dbb_database_handle;
|
||||
|
||||
if (charset_id == CS_dynamic)
|
||||
dbb = request->req_dbb;
|
||||
isc_db_handle DB = dbb->dbb_database_handle;
|
||||
|
||||
if (charset_id == CS_dynamic)
|
||||
charset_id = dbb->dbb_att_charset;
|
||||
|
||||
THREAD_EXIT();
|
||||
|
||||
FOR (REQUEST_HANDLE dbb->dbb_requests[irq_cs_bpc] TRANSACTION_HANDLE request->req_trans)
|
||||
Y IN RDB$CHARACTER_SETS
|
||||
WITH Y.RDB$CHARACTER_SET_ID EQ charset_id
|
||||
|
||||
THREAD_ENTER();
|
||||
|
||||
bpc = (Y.RDB$BYTES_PER_CHARACTER.NULL) ? 1 :
|
||||
(Y.RDB$BYTES_PER_CHARACTER);
|
||||
|
||||
THREAD_EXIT();
|
||||
END_FOR
|
||||
ON_ERROR
|
||||
THREAD_ENTER();
|
||||
ERRD_punt(isc_status);
|
||||
END_ERROR;
|
||||
|
||||
THREAD_ENTER();
|
||||
|
||||
return bpc;
|
||||
dsql_intlsym* cs_sym = 0;
|
||||
size_t pos = 0;
|
||||
if (dbb->dbb_charsets_by_id.find(charset_id, pos)) {
|
||||
cs_sym = dbb->dbb_charsets_by_id[pos];
|
||||
}
|
||||
else {
|
||||
Firebird::MetaName cs_name = METD_get_charset_name(request, charset_id);
|
||||
cs_sym = METD_get_charset(request, cs_name.length(), cs_name.c_str());
|
||||
}
|
||||
return cs_sym->intlsym_bytes_per_char;
|
||||
}
|
||||
|
||||
|
||||
@ -654,6 +645,12 @@ Firebird::MetaName METD_get_charset_name(dsql_req* request, SSHORT charset_id)
|
||||
if (charset_id == CS_dynamic)
|
||||
charset_id = dbb->dbb_att_charset;
|
||||
|
||||
size_t pos = 0;
|
||||
if (dbb->dbb_charsets_by_id.find(charset_id, pos))
|
||||
{
|
||||
return dbb->dbb_charsets_by_id[pos]->intlsym_name;
|
||||
}
|
||||
|
||||
THREAD_EXIT();
|
||||
|
||||
FOR (REQUEST_HANDLE dbb->dbb_requests[irq_cs_name] TRANSACTION_HANDLE request->req_trans)
|
||||
@ -673,6 +670,9 @@ Firebird::MetaName METD_get_charset_name(dsql_req* request, SSHORT charset_id)
|
||||
|
||||
THREAD_ENTER();
|
||||
|
||||
// put new charset into hash table if needed
|
||||
METD_get_charset(request, name.length(), name.c_str());
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user