mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 09:23:03 +01:00
Misc.
This commit is contained in:
parent
3a9567e868
commit
f8007f4071
@ -95,8 +95,8 @@ private:
|
|||||||
{
|
{
|
||||||
if ((offset < this->size) && (offset + _size <= this->size))
|
if ((offset < this->size) && (offset + _size <= this->size))
|
||||||
return ptr + offset;
|
return ptr + offset;
|
||||||
else
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sameFile(const TempFile* file) const
|
bool sameFile(const TempFile* file) const
|
||||||
|
@ -341,8 +341,8 @@ ULONG TextType::str_to_upper(ULONG srcLen,
|
|||||||
{
|
{
|
||||||
if (tt->texttype_fn_str_to_upper)
|
if (tt->texttype_fn_str_to_upper)
|
||||||
return (*tt->texttype_fn_str_to_upper)(tt, srcLen, src, dstLen, dst);
|
return (*tt->texttype_fn_str_to_upper)(tt, srcLen, src, dstLen, dst);
|
||||||
else
|
|
||||||
return Firebird::IntlUtil::toUpper(getCharSet(), srcLen, src, dstLen, dst, NULL);
|
return Firebird::IntlUtil::toUpper(getCharSet(), srcLen, src, dstLen, dst, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -353,8 +353,8 @@ ULONG TextType::str_to_lower(ULONG srcLen,
|
|||||||
{
|
{
|
||||||
if (tt->texttype_fn_str_to_lower)
|
if (tt->texttype_fn_str_to_lower)
|
||||||
return (*tt->texttype_fn_str_to_lower)(tt, srcLen, src, dstLen, dst);
|
return (*tt->texttype_fn_str_to_lower)(tt, srcLen, src, dstLen, dst);
|
||||||
else
|
|
||||||
return Firebird::IntlUtil::toLower(getCharSet(), srcLen, src, dstLen, dst, NULL);
|
return Firebird::IntlUtil::toLower(getCharSet(), srcLen, src, dstLen, dst, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -540,14 +540,14 @@ namespace {
|
|||||||
class HugeStaticBuffer
|
class HugeStaticBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HugeStaticBuffer(MemoryPool& p)
|
explicit HugeStaticBuffer(MemoryPool& p)
|
||||||
: zeroArray(p),
|
: zeroArray(p),
|
||||||
zeroBuff(zeroArray.getBuffer(ZERO_BUF_SIZE))
|
zeroBuff(zeroArray.getBuffer(ZERO_BUF_SIZE))
|
||||||
{
|
{
|
||||||
memset(zeroBuff, 0, ZERO_BUF_SIZE);
|
memset(zeroBuff, 0, ZERO_BUF_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* get() { return zeroBuff; }
|
const char* get() const { return zeroBuff; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Firebird::Array<char> zeroArray;
|
Firebird::Array<char> zeroArray;
|
||||||
|
@ -1106,9 +1106,8 @@ static SSHORT par_context(CompilerScratch* csb, SSHORT* context_ptr)
|
|||||||
if (csb->csb_g_flags & csb_reuse_context) {
|
if (csb->csb_g_flags & csb_reuse_context) {
|
||||||
return tail->csb_stream;
|
return tail->csb_stream;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
error(csb, isc_ctxinuse, 0);
|
error(csb, isc_ctxinuse, 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const SSHORT stream = csb->nextStream(false);
|
const SSHORT stream = csb->nextStream(false);
|
||||||
@ -1476,10 +1475,9 @@ static jrd_nod* par_function(thread_db* tdbb, CompilerScratch* csb)
|
|||||||
anode->nod_arg[e_fun_args] = par_args(tdbb, csb, VALUE);
|
anode->nod_arg[e_fun_args] = par_args(tdbb, csb, VALUE);
|
||||||
return anode;
|
return anode;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
csb->csb_running -= count;
|
csb->csb_running -= count;
|
||||||
error(csb, isc_funnotdef, isc_arg_string, ERR_cstring(name), 0);
|
error(csb, isc_funnotdef, isc_arg_string, ERR_cstring(name), 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UserFunction* homonyms;
|
UserFunction* homonyms;
|
||||||
@ -2441,17 +2439,17 @@ static jrd_nod* par_rse(thread_db* tdbb, CompilerScratch* csb, SSHORT rse_op)
|
|||||||
if (!rse->rse_jointype ||
|
if (!rse->rse_jointype ||
|
||||||
(rse->rse_count == 2 && rse->rse_boolean))
|
(rse->rse_count == 2 && rse->rse_boolean))
|
||||||
{
|
{
|
||||||
// Convert right outer joins to left joins to avoid
|
// Convert right outer joins to left joins to avoid
|
||||||
// RIGHT JOIN handling at lower engine levels
|
// RIGHT JOIN handling at lower engine levels
|
||||||
if (rse->rse_jointype == blr_right) {
|
if (rse->rse_jointype == blr_right) {
|
||||||
// Swap sub-streams
|
// Swap sub-streams
|
||||||
jrd_nod* temp = rse->rse_relation[0];
|
jrd_nod* temp = rse->rse_relation[0];
|
||||||
rse->rse_relation[0] = rse->rse_relation[1];
|
rse->rse_relation[0] = rse->rse_relation[1];
|
||||||
rse->rse_relation[1] = temp;
|
rse->rse_relation[1] = temp;
|
||||||
|
|
||||||
rse->rse_jointype = blr_left;
|
rse->rse_jointype = blr_left;
|
||||||
}
|
}
|
||||||
return (jrd_nod*) rse;
|
return (jrd_nod*) rse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
syntax_error(csb, (TEXT*)((rse_op == blr_rs_stream) ?
|
syntax_error(csb, (TEXT*)((rse_op == blr_rs_stream) ?
|
||||||
|
@ -246,7 +246,8 @@ void API_ROUTINE perf_get_info(FB_API_HANDLE* handle, PERF* perf)
|
|||||||
const char* p = buffer;
|
const char* p = buffer;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
switch (*p++) {
|
switch (*p++)
|
||||||
|
{
|
||||||
case isc_info_reads:
|
case isc_info_reads:
|
||||||
perf->perf_reads = get_parameter(&p);
|
perf->perf_reads = get_parameter(&p);
|
||||||
break;
|
break;
|
||||||
@ -283,12 +284,18 @@ void API_ROUTINE perf_get_info(FB_API_HANDLE* handle, PERF* perf)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case isc_info_error:
|
case isc_info_error:
|
||||||
if (p[2] == isc_info_marks)
|
switch (p[2])
|
||||||
|
{
|
||||||
|
case isc_info_marks:
|
||||||
perf->perf_marks = 0;
|
perf->perf_marks = 0;
|
||||||
else if (p[2] == isc_info_current_memory)
|
break;
|
||||||
|
case isc_info_current_memory:
|
||||||
perf->perf_current_memory = 0;
|
perf->perf_current_memory = 0;
|
||||||
else if (p[2] == isc_info_max_memory)
|
break;
|
||||||
|
case isc_info_max_memory:
|
||||||
perf->perf_max_memory = 0;
|
perf->perf_max_memory = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
{
|
{
|
||||||
const SLONG temp = isc_vax_integer(p, 2);
|
const SLONG temp = isc_vax_integer(p, 2);
|
||||||
fb_assert(temp <= MAX_SSHORT);
|
fb_assert(temp <= MAX_SSHORT);
|
||||||
|
@ -2241,47 +2241,51 @@ static bool get_record(thread_db* tdbb,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case rsb_skip:
|
case rsb_skip:
|
||||||
switch (mode) {
|
{
|
||||||
#ifdef SCROLLABLE_CURSORS
|
irsb_skip_n* skip = (irsb_skip_n*) impure;
|
||||||
case RSE_get_backward:
|
switch (mode)
|
||||||
if (((irsb_skip_n*) impure)->irsb_count > 0)
|
|
||||||
{
|
{
|
||||||
invalidate_child_rpbs(tdbb, rsb);
|
#ifdef SCROLLABLE_CURSORS
|
||||||
return false;
|
case RSE_get_backward:
|
||||||
}
|
if (skip->irsb_count > 0)
|
||||||
if (((irsb_skip_n*) impure)->irsb_count == 0)
|
{
|
||||||
{
|
|
||||||
((irsb_skip_n*) impure)->irsb_count++;
|
|
||||||
if (get_record(tdbb, rsb->rsb_next, NULL, mode))
|
|
||||||
invalidate_child_rpbs(tdbb, rsb);
|
invalidate_child_rpbs(tdbb, rsb);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
((irsb_skip_n*) impure)->irsb_count++;
|
if (skip->irsb_count == 0)
|
||||||
if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
|
{
|
||||||
return false;
|
skip->irsb_count++;
|
||||||
break;
|
if (get_record(tdbb, rsb->rsb_next, NULL, mode))
|
||||||
|
invalidate_child_rpbs(tdbb, rsb);
|
||||||
case RSE_get_current:
|
return false;
|
||||||
if (((irsb_skip_n*) impure)->irsb_count >= 1)
|
}
|
||||||
{
|
skip->irsb_count++;
|
||||||
invalidate_child_rpbs(tdbb, rsb);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case RSE_get_forward:
|
|
||||||
while (((irsb_skip_n*) impure)->irsb_count > 1) {
|
|
||||||
((irsb_skip_n*) impure)->irsb_count--;
|
|
||||||
if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
|
if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
|
||||||
return false;
|
return false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RSE_get_current:
|
||||||
|
if (skip->irsb_count >= 1)
|
||||||
|
{
|
||||||
|
invalidate_child_rpbs(tdbb, rsb);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case RSE_get_forward:
|
||||||
|
while (skip->irsb_count > 1) {
|
||||||
|
skip->irsb_count--;
|
||||||
|
if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
skip->irsb_count--;
|
||||||
|
if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
((irsb_skip_n*) impure)->irsb_count--;
|
|
||||||
if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -144,26 +144,26 @@ void SCL_check_access(const SecurityClass* s_class,
|
|||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Attachment* const attachment = tdbb->getAttachment();
|
const Attachment& attachment = *tdbb->getAttachment();
|
||||||
|
|
||||||
// Allow the database owner to back up a database even if he does not have
|
// Allow the database owner to back up a database even if he does not have
|
||||||
// read access to all the tables in the database
|
// read access to all the tables in the database
|
||||||
|
|
||||||
if ((attachment->att_flags & ATT_gbak_attachment) && (mask & SCL_read))
|
if ((attachment.att_flags & ATT_gbak_attachment) && (mask & SCL_read))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow the locksmith any access to database
|
// Allow the locksmith any access to database
|
||||||
|
|
||||||
if (attachment->locksmith())
|
if (attachment.locksmith())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool denied_db = false;
|
bool denied_db = false;
|
||||||
|
|
||||||
const SecurityClass* const att_class = attachment->att_security_class;
|
const SecurityClass* const att_class = attachment.att_security_class;
|
||||||
if (att_class && !(att_class->scl_flags & mask))
|
if (att_class && !(att_class->scl_flags & mask))
|
||||||
{
|
{
|
||||||
denied_db = true;
|
denied_db = true;
|
||||||
@ -974,6 +974,7 @@ static bool check_user_group(const UCHAR* acl,
|
|||||||
else // processing group name
|
else // processing group name
|
||||||
{
|
{
|
||||||
Firebird::UCharBuffer buffer;
|
Firebird::UCharBuffer buffer;
|
||||||
|
fb_assert(l < length); // Not sure how we can guarantee this.
|
||||||
UCHAR* user_group_name = buffer.getBuffer(length);
|
UCHAR* user_group_name = buffer.getBuffer(length);
|
||||||
do {
|
do {
|
||||||
const TEXT one_char = *acl++;
|
const TEXT one_char = *acl++;
|
||||||
|
@ -646,8 +646,10 @@ int TRA_get_state(thread_db* tdbb, SLONG number)
|
|||||||
return TPC_snapshot_state(tdbb, number);
|
return TPC_snapshot_state(tdbb, number);
|
||||||
|
|
||||||
if (number && dbb->dbb_pc_transactions)
|
if (number && dbb->dbb_pc_transactions)
|
||||||
|
{
|
||||||
if (TRA_precommited(tdbb, number, number))
|
if (TRA_precommited(tdbb, number, number))
|
||||||
return tra_precommitted;
|
return tra_precommitted;
|
||||||
|
}
|
||||||
|
|
||||||
return TRA_fetch_state(tdbb, number);
|
return TRA_fetch_state(tdbb, number);
|
||||||
}
|
}
|
||||||
@ -1069,7 +1071,7 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{ // scope
|
||||||
vec<jrd_rel*>& rels = *dbb->dbb_relations;
|
vec<jrd_rel*>& rels = *dbb->dbb_relations;
|
||||||
for (size_t i = 0; i < rels.count(); i++)
|
for (size_t i = 0; i < rels.count(); i++)
|
||||||
{
|
{
|
||||||
@ -1080,7 +1082,7 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // end scope
|
||||||
|
|
||||||
// Release the locks associated with the transaction
|
// Release the locks associated with the transaction
|
||||||
|
|
||||||
@ -1275,10 +1277,8 @@ void TRA_rollback(thread_db* tdbb, jrd_tra* transaction, const bool retaining_fl
|
|||||||
retain_context(tdbb, transaction, false, state);
|
retain_context(tdbb, transaction, false, state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
TRA_set_state(tdbb, transaction, transaction->tra_number, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
TRA_set_state(tdbb, transaction, transaction->tra_number, state);
|
||||||
TRA_release_transaction(tdbb, transaction);
|
TRA_release_transaction(tdbb, transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1352,16 +1352,15 @@ void TRA_set_state(thread_db* tdbb, jrd_tra* transaction, SLONG number, SSHORT s
|
|||||||
|
|
||||||
if (transaction && !(transaction->tra_flags & TRA_write))
|
if (transaction && !(transaction->tra_flags & TRA_write))
|
||||||
return;
|
return;
|
||||||
else {
|
|
||||||
{ //scope
|
{ //scope
|
||||||
Database::Checkout dcoHolder(dbb);
|
Database::Checkout dcoHolder(dbb);
|
||||||
THREAD_YIELD();
|
THREAD_YIELD();
|
||||||
}
|
|
||||||
tip = reinterpret_cast<tx_inv_page*>(CCH_FETCH(tdbb, &window, LCK_write, pag_transactions));
|
|
||||||
if (generation == tip->pag_generation)
|
|
||||||
CCH_MARK_MUST_WRITE(tdbb, &window);
|
|
||||||
CCH_RELEASE(tdbb, &window);
|
|
||||||
}
|
}
|
||||||
|
tip = reinterpret_cast<tx_inv_page*>(CCH_FETCH(tdbb, &window, LCK_write, pag_transactions));
|
||||||
|
if (generation == tip->pag_generation)
|
||||||
|
CCH_MARK_MUST_WRITE(tdbb, &window);
|
||||||
|
CCH_RELEASE(tdbb, &window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1450,8 +1449,8 @@ int TRA_snapshot_state(thread_db* tdbb, const jrd_tra* trans, SLONG number)
|
|||||||
int state = TPC_snapshot_state(tdbb, number);
|
int state = TPC_snapshot_state(tdbb, number);
|
||||||
if (state == tra_active)
|
if (state == tra_active)
|
||||||
return tra_committed;
|
return tra_committed;
|
||||||
else
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the transaction is a commited sub-transction - do the easy lookup.
|
// If the transaction is a commited sub-transction - do the easy lookup.
|
||||||
|
@ -4191,7 +4191,7 @@ ISC_STATUS API_ROUTINE GDS_RECONNECT(ISC_STATUS* user_status,
|
|||||||
&handle,
|
&handle,
|
||||||
length, id))
|
length, id))
|
||||||
{
|
{
|
||||||
return status[1];
|
return status[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
new Transaction(handle, tra_handle, dbb);
|
new Transaction(handle, tra_handle, dbb);
|
||||||
@ -5352,8 +5352,10 @@ static Transaction* find_transaction(Attachment* dbb,
|
|||||||
**************************************/
|
**************************************/
|
||||||
|
|
||||||
for (; transaction; transaction = transaction->next)
|
for (; transaction; transaction = transaction->next)
|
||||||
|
{
|
||||||
if (transaction->parent == dbb)
|
if (transaction->parent == dbb)
|
||||||
return transaction;
|
return transaction;
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -5741,6 +5743,7 @@ static ISC_STATUS prepare(ISC_STATUS* user_status,
|
|||||||
length = p - description;
|
length = p - description;
|
||||||
|
|
||||||
for (sub = transaction->next; sub; sub = sub->next)
|
for (sub = transaction->next; sub; sub = sub->next)
|
||||||
|
{
|
||||||
if (CALL(PROC_PREPARE, sub->implementation) (status,
|
if (CALL(PROC_PREPARE, sub->implementation) (status,
|
||||||
&sub->handle,
|
&sub->handle,
|
||||||
length, description))
|
length, description))
|
||||||
@ -5750,6 +5753,7 @@ static ISC_STATUS prepare(ISC_STATUS* user_status,
|
|||||||
}
|
}
|
||||||
return status[1];
|
return status[1];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (description != tdr_buffer)
|
if (description != tdr_buffer)
|
||||||
free_block(description);
|
free_block(description);
|
||||||
|
Loading…
Reference in New Issue
Block a user