8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 22:03:03 +01:00
This commit is contained in:
asfernandes 2009-08-23 01:27:46 +00:00
parent e4ced1424e
commit 50102f6f4c
13 changed files with 70 additions and 74 deletions

View File

@ -270,6 +270,7 @@ void TempFile::extend(size_t delta)
const char* const buffer = zeros().getBuffer();
const size_t bufferSize = zeros().getSize();
const size_t newSize = size + delta;
for (size_t offset = size; offset < newSize; offset += bufferSize)
{
const size_t length = MIN(newSize - offset, bufferSize);

View File

@ -362,7 +362,7 @@ TempSpace::Block* TempSpace::findBlock(offset_t& offset) const
TempFile* TempSpace::setupFile(size_t size)
{
ISC_STATUS_ARRAY status_vector;
ISC_STATUS_ARRAY status_vector = {0};
for (size_t i = 0; i < tempDirs->getCount(); i++)
{

View File

@ -300,10 +300,9 @@ public:
SCHAR prf_unaligned_buffer[PREFETCH_MAX_TRANSFER + MIN_PAGE_SIZE];
};
const int PRF_active = 1; // prefetch block currently in use
const int PRF_active = 1; // prefetch block currently in use
#endif // SUPERSERVER_V2
} //namespace Jrd
#endif // JRD_CCH_H

View File

@ -187,8 +187,8 @@ void DYN_UTIL_generate_constraint_name( thread_db* tdbb, Global* gbl, Firebird::
jrd_req* request = NULL;
SSHORT id = -1;
try {
try
{
bool found = false;
do {
@ -212,7 +212,6 @@ void DYN_UTIL_generate_constraint_name( thread_db* tdbb, Global* gbl, Firebird::
DYN_REQUEST(drq_f_nxt_con) = request;
request = NULL;
} while (found);
}
catch (const Firebird::Exception& ex)
{
@ -260,8 +259,8 @@ void DYN_UTIL_generate_field_name( thread_db* tdbb, Global* gbl, Firebird::MetaN
jrd_req* request = NULL;
SSHORT id = -1;
try {
try
{
bool found = false;
do {
@ -284,7 +283,6 @@ void DYN_UTIL_generate_field_name( thread_db* tdbb, Global* gbl, Firebird::MetaN
DYN_REQUEST(drq_f_nxt_fld) = request;
request = NULL;
} while (found);
}
catch (const Firebird::Exception& ex)
{
@ -318,8 +316,8 @@ void DYN_UTIL_generate_field_position(thread_db* tdbb,
jrd_req* request = NULL;
try {
try
{
request = CMP_find_request(tdbb, drq_l_fld_pos, DYN_REQUESTS);
FOR(REQUEST_HANDLE request)
@ -336,7 +334,6 @@ void DYN_UTIL_generate_field_position(thread_db* tdbb,
END_FOR;
*field_pos = field_position;
}
catch (const Firebird::Exception& ex)
{
@ -367,8 +364,8 @@ void DYN_UTIL_generate_index_name(thread_db* tdbb, Global* gbl,
jrd_req* request = NULL;
SSHORT id = -1;
try {
try
{
bool found = false;
do {
@ -433,8 +430,8 @@ void DYN_UTIL_generate_trigger_name( thread_db* tdbb, Global* gbl, Firebird::Met
jrd_req* request = NULL;
SSHORT id = -1;
try {
try
{
bool found = false;
do {
@ -585,8 +582,8 @@ bool DYN_UTIL_get_prot(thread_db* tdbb,
jrd_req* request = CMP_find_request(tdbb, drq_l_prot_mask, DYN_REQUESTS);
try {
try
{
if (!request)
{
request = CMP_compile2(tdbb, prot_blr, sizeof(prot_blr), true);
@ -631,8 +628,8 @@ void DYN_UTIL_store_check_constraints(thread_db* tdbb,
jrd_req* request = CMP_find_request(tdbb, drq_s_chk_con, DYN_REQUESTS);
try {
try
{
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
CHK IN RDB$CHECK_CONSTRAINTS
strcpy(CHK.RDB$CONSTRAINT_NAME, constraint_name.c_str());

View File

@ -1434,4 +1434,3 @@ static void set_lock_attachment(Lock* lock, Attachment* attachment)
lock->lck_attachment = attachment;
}

View File

@ -5387,11 +5387,13 @@ static RecordSource* gen_sort(thread_db* tdbb,
DEV_BLKCHK(prior_rsb, type_rsb);
DEV_BLKCHK(sort, type_nod);
SET_TDBB(tdbb);
/* We already know the number of keys, but we also need to compute the
total number of fields, keys and non-keys, to be pumped thru sort. Starting
with the number of keys, count the other field referenced. Since a field
is often a key, check for overlap to keep the length of the sort record
down. */
/* Along with the record number, the transaction id of the
* record will also be stored in the sort file. This will
* be used to detect update conflict in read committed
@ -5472,6 +5474,7 @@ static RecordSource* gen_sort(thread_db* tdbb,
jrd_nod* node = *node_ptr;
dsc* desc = &descriptor;
CMP_get_desc(tdbb, csb, node, desc);
// Allow for "key" forms of International text to grow
if (IS_INTL_DATA(desc))
{
@ -5664,7 +5667,9 @@ static RecordSource* gen_sort(thread_db* tdbb,
ERR_post(Arg::Gds(isc_sort_rec_size_err) << Arg::Num(map_length));
// Msg438: sort record size of %ld bytes is too big
}
map->smb_length = (USHORT) map_length;
// That was most unpleasant. Never the less, it's done (except for the debugging).
// All that remains is to build the record source block for the sort.
RecordSource* rsb = FB_NEW_RPT(*tdbb->getDefaultPool(), 1) RecordSource();
@ -6496,6 +6501,7 @@ static jrd_nod* make_inference_node(CompilerScratch* csb, jrd_nod* boolean,
DEV_BLKCHK(arg1, type_nod);
DEV_BLKCHK(arg2, type_nod);
fb_assert(boolean->nod_count >= 2); // must be a conjunction boolean
// Clone the input predicate
jrd_nod* node = PAR_make_node(tdbb, boolean->nod_count);
node->nod_type = boolean->nod_type;
@ -6506,12 +6512,15 @@ static jrd_nod* make_inference_node(CompilerScratch* csb, jrd_nod* boolean,
// determined by its dependency on any of the fields
// If provisions above change the line below will have to be modified
node->nod_flags = boolean->nod_flags;
// But substitute new values for some of the predicate arguments
node->nod_arg[0] = CMP_clone_node_opt(tdbb, csb, arg1);
node->nod_arg[1] = CMP_clone_node_opt(tdbb, csb, arg2);
// Arguments after the first two are just cloned (eg: LIKE ESCAPE clause)
for (USHORT n = 2; n < boolean->nod_count; n++)
node->nod_arg[n] = CMP_clone_node_opt(tdbb, csb, boolean->nod_arg[n]);
// Share impure area for cached invariant value used to hold pre-compiled
// pattern for new LIKE and CONTAINING algorithms.
// Proper cloning of impure area for this node would require careful accounting
@ -6519,6 +6528,7 @@ static jrd_nod* make_inference_node(CompilerScratch* csb, jrd_nod* boolean,
// cached pattern value for all node clones. This is faster too.
if (node->nod_flags & nod_invariant)
node->nod_impure = boolean->nod_impure;
return node;
}

View File

@ -609,6 +609,7 @@ jrd_file* PIO_open(Database* dbb,
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("open") << Arg::Str(file_name) <<
Arg::Gds(isc_io_open_err) << Arg::Unix(errno));
}
// If this is the primary file, set Database flag to indicate that it is
// being opened ReadOnly. This flag will be used later to compare with
// the Header Page flag setting to make sure that the database is set ReadOnly.

View File

@ -1565,7 +1565,7 @@ void PAG_init2(thread_db* tdbb, USHORT shadow_number)
// which must be done with an exclusive lock on the database --
// if this changes, this policy will have to be reevaluated;
// at any rate there is a problem with getting a read lock
//because the corresponding page in the main database file may not exist
// because the corresponding page in the main database file may not exist
if (!file->fil_min_page)
CCH_FETCH(tdbb, &window, LCK_read, pag_header);

View File

@ -217,7 +217,7 @@ int SDW_add_file(thread_db* tdbb, const TEXT* file_name, SLONG start, USHORT sha
// we can use the same header page, suitably modified,
// because they all look pretty much the same at this point
/*******************
/*******************
Fix for bug 7925. drop_gdb wan not dropping secondary file in
multi-shadow files. The structure was not being filled with the
info. Commented some code so that the structure will always be filled.
@ -225,12 +225,13 @@ int SDW_add_file(thread_db* tdbb, const TEXT* file_name, SLONG start, USHORT sha
-Sudesh 07/06/95
The original code :
===
===
if (shadow_file == file)
copy_header(tdbb);
else
===
************************/
===
************************/
// Temporarly reverting the change ------- Sudesh 07/07/95 *******
if (shadow_file == file)
@ -1328,5 +1329,3 @@ static void update_dbb_to_sdw(Database* dbb)
pageSpace->file = shadow->sdw_file;
shadow->sdw_flags |= SDW_rollover;
}

View File

@ -1677,17 +1677,18 @@ static sort_record* get_merge(merge_control* merge, sort_context* scb
if (record)
{
if (merge->mrg_stream_a && !merge->mrg_record_a)
{
if (eof)
merge->mrg_stream_a = NULL;
else
merge->mrg_record_a = record;
}
else if (eof)
merge->mrg_stream_b = NULL;
else
merge->mrg_record_b = record;
}
// If either streams need a record and is still active, loop back to pick
// up the record. If either stream is dry, return the record of the other.
// If both are dry, indicate eof for this stream.

View File

@ -278,4 +278,3 @@ const int scb_sorted = 2; /* stream has been sorted */
} //namespace Jrd
#endif // JRD_SORT_H

View File

@ -32,20 +32,20 @@ namespace Jrd {
}
#ifdef SCROLLABLE_CURSORS
void SORT_diddle_key(UCHAR *, Jrd::sort_context*, bool);
void SORT_get(Jrd::thread_db*, Jrd::sort_context*, ULONG **, Jrd::rse_get_mode);
void SORT_read_block(TempSpace*, FB_UINT64, BLOB_PTR *, ULONG);
void SORT_diddle_key(UCHAR*, Jrd::sort_context*, bool);
void SORT_get(Jrd::thread_db*, Jrd::sort_context*, ULONG**, Jrd::rse_get_mode);
void SORT_read_block(TempSpace*, FB_UINT64, BLOB_PTR*, ULONG);
#else
void SORT_get(Jrd::thread_db*, Jrd::sort_context*, ULONG **);
FB_UINT64 SORT_read_block(TempSpace*, FB_UINT64, BLOB_PTR *, ULONG);
void SORT_get(Jrd::thread_db*, Jrd::sort_context*, ULONG**);
FB_UINT64 SORT_read_block(TempSpace*, FB_UINT64, BLOB_PTR*, ULONG);
#endif
void SORT_fini(Jrd::sort_context*, Jrd::Attachment*);
Jrd::sort_context* SORT_init(Jrd::thread_db*, USHORT, USHORT, USHORT, const Jrd::sort_key_def*,
Jrd::FPTR_REJECT_DUP_CALLBACK, void*); //, FB_UINT64);
void SORT_put(Jrd::thread_db*, Jrd::sort_context*, ULONG **);
void SORT_put(Jrd::thread_db*, Jrd::sort_context*, ULONG**);
void SORT_shutdown(Jrd::Attachment*);
void SORT_sort(Jrd::thread_db*, Jrd::sort_context*);
FB_UINT64 SORT_write_block(TempSpace*, FB_UINT64, BLOB_PTR *, ULONG);
FB_UINT64 SORT_write_block(TempSpace*, FB_UINT64, BLOB_PTR*, ULONG);
#endif // JRD_SORT_PROTO_H

View File

@ -387,7 +387,9 @@ namespace
public:
CAttachment(StoredAtt*, FB_API_HANDLE*, USHORT);
static void destroy(CAttachment*);
bool destroying()
{
return flagDestroying;
@ -419,7 +421,7 @@ namespace
public:
CTransaction(StoredTra* h, FB_API_HANDLE* pub, Attachment par)
: BaseHandle(hType(), pub, par), next(0), handle(h),
: BaseHandle(hType(), pub, par), next(0), handle(h),
blobs(getPool())
{
parent->transactions.toParent(this);
@ -546,7 +548,7 @@ namespace
private:
~CStatement()
{
{
if (parent->destroying())
{
release_dsql_support(das);
@ -689,8 +691,7 @@ namespace
return 0;
}
template <typename ToHandle>
RefPtr<ToHandle> translate(FB_API_HANDLE* handle)
template <typename ToHandle> RefPtr<ToHandle> translate(FB_API_HANDLE* handle)
{
if (shutdownStarted)
{
@ -2051,6 +2052,7 @@ ISC_STATUS API_ROUTINE GDS_CREATE_DATABASE(ISC_STATUS* user_status,
{
CALL(PROC_DROP_DATABASE, n) (temp, &handle);
}
destroy(attachment);
}
@ -3802,12 +3804,9 @@ ISC_STATUS API_ROUTINE GDS_GET_SLICE(ISC_STATUS* user_status,
status.setPrimaryHandle(attachment);
Transaction transaction = findTransaction(tra_handle, attachment);
CALL(PROC_GET_SLICE, attachment->implementation) (status, &attachment->handle, &transaction->handle,
array_id,
sdl_length, sdl,
param_length, param,
slice_length, slice,
return_length);
CALL(PROC_GET_SLICE, attachment->implementation) (status, &attachment->handle,
&transaction->handle, array_id, sdl_length, sdl, param_length, param,
slice_length, slice, return_length);
}
catch (const Exception& e)
{
@ -4020,11 +4019,9 @@ ISC_STATUS API_ROUTINE GDS_PUT_SLICE(ISC_STATUS* user_status,
status.setPrimaryHandle(attachment);
Transaction transaction = findTransaction(tra_handle, attachment);
CALL(PROC_PUT_SLICE, attachment->implementation) (status, &attachment->handle, &transaction->handle,
array_id,
sdl_length, sdl,
param_length, param,
slice_length, slice);
CALL(PROC_PUT_SLICE, attachment->implementation) (status, &attachment->handle,
&transaction->handle, array_id, sdl_length, sdl, param_length, param,
slice_length, slice);
}
catch (const Exception& e)
{
@ -4061,7 +4058,7 @@ ISC_STATUS API_ROUTINE GDS_QUE_EVENTS(ISC_STATUS* user_status,
status.setPrimaryHandle(attachment);
CALL(PROC_QUE_EVENTS, attachment->implementation) (status, &attachment->handle,
id, length, events, ast, arg);
id, length, events, ast, arg);
}
catch (const Exception& e)
{
@ -4184,8 +4181,7 @@ ISC_STATUS API_ROUTINE GDS_RECONNECT(ISC_STATUS* user_status,
status.setPrimaryHandle(attachment);
if (CALL(PROC_RECONNECT, attachment->implementation) (status, &attachment->handle,
&handle,
length, id))
&handle, length, id))
{
return status[1];
}
@ -4794,9 +4790,8 @@ ISC_STATUS API_ROUTINE GDS_START_MULTIPLE(ISC_STATUS* user_status,
attachment = translate<CAttachment>(vector->teb_database);
if (CALL(PROC_START_TRANSACTION, attachment->implementation) (status, &handle, 1, &attachment->handle,
vector->teb_tpb_length,
vector->teb_tpb))
if (CALL(PROC_START_TRANSACTION, attachment->implementation) (status, &handle, 1,
&attachment->handle, vector->teb_tpb_length, vector->teb_tpb))
{
status_exception::raise(status);
}
@ -4832,6 +4827,7 @@ ISC_STATUS API_ROUTINE GDS_START_MULTIPLE(ISC_STATUS* user_status,
CALL(PROC_ROLLBACK, sub->implementation) (temp, &sub->handle);
}
}
if (transaction)
{
destroy(transaction);
@ -4917,10 +4913,9 @@ ISC_STATUS API_ROUTINE GDS_TRANSACT_REQUEST(ISC_STATUS* user_status,
status.setPrimaryHandle(attachment);
Transaction transaction = findTransaction(tra_handle, attachment);
CALL(PROC_TRANSACT_REQUEST, attachment->implementation) (status, &attachment->handle, &transaction->handle,
blr_length, blr,
in_msg_length, in_msg,
out_msg_length, out_msg);
CALL(PROC_TRANSACT_REQUEST, attachment->implementation) (status, &attachment->handle,
&transaction->handle, blr_length, blr, in_msg_length, in_msg, out_msg_length,
out_msg);
}
catch (const Exception& e)
{
@ -4994,7 +4989,8 @@ ISC_STATUS API_ROUTINE GDS_TRANSACTION_INFO(ISC_STATUS* user_status,
{
SSHORT item_len = item_length;
SSHORT buffer_len = buffer_length;
for (Transaction sub = transaction->next; sub; sub = sub->next) {
for (Transaction sub = transaction->next; sub; sub = sub->next)
{
if (CALL(PROC_TRANSACTION_INFO, sub->implementation) (status, &sub->handle,
item_len, items,
buffer_len, buffer))
@ -5523,13 +5519,9 @@ static ISC_STATUS open_blob(ISC_STATUS* user_status,
gds__parse_bpb(bpb_length, bpb, &from, &to);
if (get_entrypoint(proc2, attachment->implementation) != no_entrypoint &&
CALL(proc2, attachment->implementation) (status,
&attachment->handle,
&transaction->handle,
&blob_handle,
blob_id,
bpb_length,
bpb) != isc_unavailable)
CALL(proc2, attachment->implementation) (status, &attachment->handle,
&transaction->handle, &blob_handle, blob_id, bpb_length,
bpb) != isc_unavailable)
{
flags = 0;
}
@ -5537,10 +5529,8 @@ static ISC_STATUS open_blob(ISC_STATUS* user_status,
{
// This code has no effect because jrd8_create_blob, jrd8_open_blob,
// REM_create_blob and REM_open_blob are defined as no_entrypoint in entry.h
CALL(proc, attachment->implementation) (status,
&attachment->handle,
&transaction->handle,
&blob_handle, blob_id);
CALL(proc, attachment->implementation) (status, &attachment->handle,
&transaction->handle, &blob_handle, blob_id);
}
if (status[1]) {