8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 18:03:04 +01:00
This commit is contained in:
robocop 2009-07-13 10:00:43 +00:00
parent 84de7895d8
commit de4be11750
8 changed files with 262 additions and 201 deletions

View File

@ -1409,8 +1409,8 @@ void CVT_move_common(const dsc* from, dsc* to, Callbacks* cb)
((vary*) (to->dsc_address))->vary_length = from->dsc_length; ((vary*) (to->dsc_address))->vary_length = from->dsc_length;
break; break;
} }
return;
} }
return;
case dtype_varying: case dtype_varying:
case dtype_cstring: case dtype_cstring:

View File

@ -53,7 +53,8 @@ No need to worry about blr_blob or ?blr_blob_id
#include "../jrd/RecordNumber.h" #include "../jrd/RecordNumber.h"
static const USHORT gds_cvt_blr_dtype[DTYPE_BLR_MAX + 1] = static const USHORT gds_cvt_blr_dtype[DTYPE_BLR_MAX + 1] =
{ 0, 0, 0, 0, 0, 0, 0, {
0, 0, 0, 0, 0, 0, 0,
dtype_short, /* blr_short == 7 */ dtype_short, /* blr_short == 7 */
dtype_long, /* blr_long == 8 */ dtype_long, /* blr_long == 8 */
dtype_quad, /* blr_quad == 9 */ dtype_quad, /* blr_quad == 9 */
@ -77,7 +78,8 @@ static const USHORT gds_cvt_blr_dtype[DTYPE_BLR_MAX + 1] =
0, 0, 0, 0 0, 0, 0, 0
}; };
static const USHORT type_alignments[DTYPE_TYPE_MAX] = { static const USHORT type_alignments[DTYPE_TYPE_MAX] =
{
0, 0,
0, /* dtype_text */ 0, /* dtype_text */
0, /* dtype_cstring */ 0, /* dtype_cstring */
@ -105,7 +107,8 @@ static const USHORT type_alignments[DTYPE_TYPE_MAX] = {
sizeof(ULONG) /* dtype_dbkey */ sizeof(ULONG) /* dtype_dbkey */
}; };
static const USHORT type_lengths[DTYPE_TYPE_MAX] = { static const USHORT type_lengths[DTYPE_TYPE_MAX] =
{
0, 0,
0, /* dtype_text */ 0, /* dtype_text */
0, /* dtype_cstring */ 0, /* dtype_cstring */
@ -130,8 +133,10 @@ static const USHORT type_lengths[DTYPE_TYPE_MAX] = {
}; };
// This table is only used by gpre's cme.cpp.
// float, double are numbers from IEEE floating-point standard (IEEE 754) // float, double are numbers from IEEE floating-point standard (IEEE 754)
static const USHORT type_significant_bits[DTYPE_TYPE_MAX] = { static const USHORT type_significant_bits[DTYPE_TYPE_MAX] =
{
0, 0,
0, /* dtype_text */ 0, /* dtype_text */
0, /* dtype_cstring */ 0, /* dtype_cstring */

View File

@ -4537,7 +4537,7 @@ static bool make_version(thread_db* tdbb, SSHORT phase, DeferredWork* work,
} }
/* Make sure the text type specified is implemented */ /* Make sure the text type specified is implemented */
if (!(validate_text_type(tdbb, tfb))) if (!validate_text_type(tdbb, tfb))
{ {
EXE_unwind(tdbb, request_fmt1); EXE_unwind(tdbb, request_fmt1);
EXE_unwind(tdbb, request_fmtx); EXE_unwind(tdbb, request_fmtx);

View File

@ -2971,7 +2971,7 @@ static pointer_page* get_pointer_page(thread_db* tdbb,
{ {
DPM_scan_pages(tdbb); DPM_scan_pages(tdbb);
/* If the relation is gone, then we can't do anything anymore. */ /* If the relation is gone, then we can't do anything anymore. */
if ((!relation) || (!(vector = relPages->rel_pages))) { if (!relation || !(vector = relPages->rel_pages)) {
return NULL; return NULL;
} }
if (sequence < vector->count()) { if (sequence < vector->count()) {

View File

@ -3465,7 +3465,7 @@ static void seek_rsb(thread_db* tdbb,
while (offset) { while (offset) {
offset--; offset--;
if (!(RSE_get_record(tdbb, rsb, RSE_get_next))) if (!RSE_get_record(tdbb, rsb, RSE_get_next))
break; break;
} }
break; break;
@ -3476,7 +3476,7 @@ static void seek_rsb(thread_db* tdbb,
while (offset) { while (offset) {
offset--; offset--;
if (!(RSE_get_record(tdbb, rsb, RSE_get_next))) if (!RSE_get_record(tdbb, rsb, RSE_get_next))
break; break;
} }
break; break;
@ -3490,7 +3490,7 @@ static void seek_rsb(thread_db* tdbb,
while (offset) { while (offset) {
offset--; offset--;
if (!(RSE_get_record(tdbb, rsb, RSE_get_next))) if (!RSE_get_record(tdbb, rsb, RSE_get_next))
break; break;
} }
break; break;
@ -3512,7 +3512,7 @@ static void seek_rsb(thread_db* tdbb,
while (offset) { while (offset) {
offset--; offset--;
if (!(RSE_get_record(tdbb, rsb, RSE_get_next))) if (!RSE_get_record(tdbb, rsb, RSE_get_next))
break; break;
} }
break; break;

View File

@ -348,7 +348,8 @@ void Jrd::Trigger::compile(thread_db* tdbb)
delete csb; delete csb;
csb = NULL; csb = NULL;
if (request) { if (request)
{
CMP_release(tdbb, request); CMP_release(tdbb, request);
request = NULL; request = NULL;
} }
@ -897,7 +898,8 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
// Worry about encryption key // Worry about encryption key
if (dbb->dbb_decrypt) { if (dbb->dbb_decrypt)
{
if (dbb->dbb_filename.hasData() && if (dbb->dbb_filename.hasData() &&
(dbb->dbb_encrypt_key.hasData() || options.dpb_key.hasData())) (dbb->dbb_encrypt_key.hasData() || options.dpb_key.hasData()))
{ {
@ -999,7 +1001,8 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
INI_init2(tdbb); INI_init2(tdbb);
PAG_init(tdbb); PAG_init(tdbb);
if (options.dpb_set_page_buffers) { if (options.dpb_set_page_buffers)
{
#ifdef SUPERSERVER #ifdef SUPERSERVER
// Here we do not let anyone except SYSDBA (like DBO) to change dbb_page_buffers, // Here we do not let anyone except SYSDBA (like DBO) to change dbb_page_buffers,
// cause other flags is UserId can be set only when DB is opened. // cause other flags is UserId can be set only when DB is opened.
@ -1041,7 +1044,8 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
attachment->att_flags |= ATT_no_cleanup; attachment->att_flags |= ATT_no_cleanup;
} }
if (options.dpb_disable_wal) { if (options.dpb_disable_wal)
{
ERR_post(Arg::Gds(isc_lock_timeout) << ERR_post(Arg::Gds(isc_lock_timeout) <<
Arg::Gds(isc_obj_in_use) << Arg::Str(file_name)); Arg::Gds(isc_obj_in_use) << Arg::Str(file_name));
} }
@ -1068,17 +1072,18 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
switch (options.dpb_sql_dialect) switch (options.dpb_sql_dialect)
{ {
case 0: case 0:
{
// V6 Client --> V6 Server, dummy client SQL dialect 0 was passed // V6 Client --> V6 Server, dummy client SQL dialect 0 was passed
// It means that client SQL dialect was not set by user // It means that client SQL dialect was not set by user
// and takes DB SQL dialect as client SQL dialect // and takes DB SQL dialect as client SQL dialect
if (ENCODE_ODS(dbb->dbb_ods_version, dbb->dbb_minor_original) >= ODS_10_0) if (ENCODE_ODS(dbb->dbb_ods_version, dbb->dbb_minor_original) >= ODS_10_0)
{ {
if (dbb->dbb_flags & DBB_DB_SQL_dialect_3) { if (dbb->dbb_flags & DBB_DB_SQL_dialect_3)
{
// DB created in IB V6.0 by client SQL dialect 3 // DB created in IB V6.0 by client SQL dialect 3
options.dpb_sql_dialect = SQL_DIALECT_V6; options.dpb_sql_dialect = SQL_DIALECT_V6;
} }
else { else
{
// old DB was gbaked in IB V6.0 // old DB was gbaked in IB V6.0
options.dpb_sql_dialect = SQL_DIALECT_V5; options.dpb_sql_dialect = SQL_DIALECT_V5;
} }
@ -1086,7 +1091,6 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
else { else {
options.dpb_sql_dialect = SQL_DIALECT_V5; options.dpb_sql_dialect = SQL_DIALECT_V5;
} }
}
break; break;
case 99: case 99:
// V5 Client --> V6 Server, old client has no concept of dialect // V5 Client --> V6 Server, old client has no concept of dialect
@ -1166,13 +1170,15 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
try to get exclusive attachment to avoid a deadlock condition which happens try to get exclusive attachment to avoid a deadlock condition which happens
when a client tries to connect to the security database itself. */ when a client tries to connect to the security database itself. */
if (!options.dpb_sec_attach) { if (!options.dpb_sec_attach)
{
bool attachment_succeeded = true; bool attachment_succeeded = true;
if (dbb->dbb_ast_flags & DBB_shutdown_single) if (dbb->dbb_ast_flags & DBB_shutdown_single)
attachment_succeeded = CCH_exclusive_attachment(tdbb, LCK_none, -1); attachment_succeeded = CCH_exclusive_attachment(tdbb, LCK_none, -1);
else else
CCH_exclusive_attachment(tdbb, LCK_none, LCK_WAIT); CCH_exclusive_attachment(tdbb, LCK_none, LCK_WAIT);
if (attachment->att_flags & ATT_shutdown) { if (attachment->att_flags & ATT_shutdown)
{
if (dbb->dbb_ast_flags & DBB_shutdown) { if (dbb->dbb_ast_flags & DBB_shutdown) {
ERR_post(Arg::Gds(isc_shutdown) << Arg::Str(file_name)); ERR_post(Arg::Gds(isc_shutdown) << Arg::Str(file_name));
} }
@ -1193,16 +1199,20 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
ERR_post(Arg::Gds(isc_shutinprog) << Arg::Str(file_name)); ERR_post(Arg::Gds(isc_shutinprog) << Arg::Str(file_name));
} }
if (dbb->dbb_ast_flags & DBB_shutdown) { if (dbb->dbb_ast_flags & DBB_shutdown)
{
// Allow only SYSDBA/owner to access database that is shut down // Allow only SYSDBA/owner to access database that is shut down
bool allow_access = attachment->locksmith(); bool allow_access = attachment->locksmith();
// Handle special shutdown modes // Handle special shutdown modes
if (allow_access) { if (allow_access)
if (dbb->dbb_ast_flags & DBB_shutdown_full) { {
if (dbb->dbb_ast_flags & DBB_shutdown_full)
{
// Full shutdown. Deny access always // Full shutdown. Deny access always
allow_access = false; allow_access = false;
} }
else if (dbb->dbb_ast_flags & DBB_shutdown_single) { else if (dbb->dbb_ast_flags & DBB_shutdown_single)
{
// Single user maintenance. Allow access only if we were able to take exclusive lock // Single user maintenance. Allow access only if we were able to take exclusive lock
// Note that logic below this exclusive lock differs for SS and CS builds: // Note that logic below this exclusive lock differs for SS and CS builds:
// - CS keeps PW database lock from releasing in AST in single-user maintenance mode // - CS keeps PW database lock from releasing in AST in single-user maintenance mode
@ -1212,7 +1222,8 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
allow_access = CCH_exclusive(tdbb, LCK_PW, WAIT_PERIOD); allow_access = CCH_exclusive(tdbb, LCK_PW, WAIT_PERIOD);
} }
} }
if (!allow_access) { if (!allow_access)
{
// Note we throw exception here when entering full-shutdown mode // Note we throw exception here when entering full-shutdown mode
ERR_post(Arg::Gds(isc_shutdown) << Arg::Str(file_name)); ERR_post(Arg::Gds(isc_shutdown) << Arg::Str(file_name));
} }
@ -1275,28 +1286,33 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
attachment->att_flags |= ATT_no_db_triggers; attachment->att_flags |= ATT_no_db_triggers;
} }
if (options.dpb_set_db_sql_dialect) { if (options.dpb_set_db_sql_dialect)
{
validateAccess(attachment); validateAccess(attachment);
PAG_set_db_SQL_dialect(tdbb, options.dpb_set_db_sql_dialect); PAG_set_db_SQL_dialect(tdbb, options.dpb_set_db_sql_dialect);
} }
if (options.dpb_sweep_interval != -1) { if (options.dpb_sweep_interval != -1)
{
validateAccess(attachment); validateAccess(attachment);
PAG_sweep_interval(tdbb, options.dpb_sweep_interval); PAG_sweep_interval(tdbb, options.dpb_sweep_interval);
dbb->dbb_sweep_interval = options.dpb_sweep_interval; dbb->dbb_sweep_interval = options.dpb_sweep_interval;
} }
if (options.dpb_set_force_write) { if (options.dpb_set_force_write)
{
validateAccess(attachment); validateAccess(attachment);
PAG_set_force_write(tdbb, options.dpb_force_write); PAG_set_force_write(tdbb, options.dpb_force_write);
} }
if (options.dpb_set_no_reserve) { if (options.dpb_set_no_reserve)
{
validateAccess(attachment); validateAccess(attachment);
PAG_set_no_reserve(tdbb, options.dpb_no_reserve); PAG_set_no_reserve(tdbb, options.dpb_no_reserve);
} }
if (options.dpb_set_page_buffers) { if (options.dpb_set_page_buffers)
{
#ifdef SUPERSERVER #ifdef SUPERSERVER
validateAccess(attachment); validateAccess(attachment);
#else #else
@ -1305,9 +1321,11 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
PAG_set_page_buffers(tdbb, options.dpb_page_buffers); PAG_set_page_buffers(tdbb, options.dpb_page_buffers);
} }
if (options.dpb_set_db_readonly) { if (options.dpb_set_db_readonly)
{
validateAccess(attachment); validateAccess(attachment);
if (!CCH_exclusive(tdbb, LCK_EX, WAIT_PERIOD)) { if (!CCH_exclusive(tdbb, LCK_EX, WAIT_PERIOD))
{
ERR_post(Arg::Gds(isc_lock_timeout) << ERR_post(Arg::Gds(isc_lock_timeout) <<
Arg::Gds(isc_obj_in_use) << Arg::Str(file_name)); Arg::Gds(isc_obj_in_use) << Arg::Str(file_name));
} }
@ -1328,7 +1346,7 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
if (options.dpb_sweep & isc_dpb_records) if (options.dpb_sweep & isc_dpb_records)
{ {
if (!(TRA_sweep(tdbb, 0))) { if (!TRA_sweep(tdbb, 0)) {
ERR_punt(); ERR_punt();
} }
} }
@ -2079,7 +2097,8 @@ ISC_STATUS GDS_CREATE_DATABASE(ISC_STATUS* user_status,
SHUT_database(tdbb, options.dpb_shutdown, options.dpb_shutdown_delay); SHUT_database(tdbb, options.dpb_shutdown, options.dpb_shutdown_delay);
} }
if (options.dpb_sweep_interval != -1) { if (options.dpb_sweep_interval != -1)
{
PAG_sweep_interval(tdbb, options.dpb_sweep_interval); PAG_sweep_interval(tdbb, options.dpb_sweep_interval);
dbb->dbb_sweep_interval = options.dpb_sweep_interval; dbb->dbb_sweep_interval = options.dpb_sweep_interval;
} }
@ -2096,7 +2115,8 @@ ISC_STATUS GDS_CREATE_DATABASE(ISC_STATUS* user_status,
VIO_init(tdbb); VIO_init(tdbb);
#endif #endif
if (options.dpb_set_db_readonly) { if (options.dpb_set_db_readonly)
{
if (!CCH_exclusive (tdbb, LCK_EX, WAIT_PERIOD)) if (!CCH_exclusive (tdbb, LCK_EX, WAIT_PERIOD))
{ {
ERR_post(Arg::Gds(isc_lock_timeout) << ERR_post(Arg::Gds(isc_lock_timeout) <<
@ -2349,7 +2369,8 @@ ISC_STATUS GDS_DROP_DATABASE(ISC_STATUS* user_status, Attachment** handle)
// Check if same process has more attachments // Check if same process has more attachments
if (dbb->dbb_attachments && dbb->dbb_attachments->att_next) { if (dbb->dbb_attachments && dbb->dbb_attachments->att_next)
{
ERR_post(Arg::Gds(isc_no_meta_update) << ERR_post(Arg::Gds(isc_no_meta_update) <<
Arg::Gds(isc_obj_in_use) << Arg::Str("DATABASE")); Arg::Gds(isc_obj_in_use) << Arg::Str("DATABASE"));
} }
@ -2491,11 +2512,13 @@ ISC_STATUS GDS_GET_SLICE(ISC_STATUS* user_status,
jrd_tra* const transaction = find_transaction(tdbb, isc_segstr_wrong_db); jrd_tra* const transaction = find_transaction(tdbb, isc_segstr_wrong_db);
if (!array_id->gds_quad_low && !array_id->gds_quad_high) { if (!array_id->gds_quad_low && !array_id->gds_quad_high)
{
MOVE_CLEAR(slice, slice_length); MOVE_CLEAR(slice, slice_length);
*return_length = 0; *return_length = 0;
} }
else { else
{
*return_length = BLB_get_slice(tdbb, transaction, reinterpret_cast<bid*>(array_id), *return_length = BLB_get_slice(tdbb, transaction, reinterpret_cast<bid*>(array_id),
sdl, param_length, param, slice_length, slice); sdl, param_length, param, slice_length, slice);
} }
@ -3136,11 +3159,13 @@ ISC_STATUS GDS_SERVICE_QUERY(ISC_STATUS* user_status,
const UCHAR* recv_items2 = reinterpret_cast<const UCHAR*>(recv_items); const UCHAR* recv_items2 = reinterpret_cast<const UCHAR*>(recv_items);
UCHAR* buffer2 = reinterpret_cast<UCHAR*>(buffer); UCHAR* buffer2 = reinterpret_cast<UCHAR*>(buffer);
if (service->getVersion() == isc_spb_version1) { if (service->getVersion() == isc_spb_version1)
{
service->query(send_item_length, send_items2, recv_item_length, service->query(send_item_length, send_items2, recv_item_length,
recv_items2, buffer_length, buffer2); recv_items2, buffer_length, buffer2);
} }
else { else
{
// For SVC_query2, we are going to completly dismantle user_status (since at this point it is // For SVC_query2, we are going to completly dismantle user_status (since at this point it is
// meaningless anyway). The status vector returned by this function can hold information about // meaningless anyway). The status vector returned by this function can hold information about
// the call to query the service manager and/or a service thread that may have been running. // the call to query the service manager and/or a service thread that may have been running.
@ -3151,7 +3176,8 @@ ISC_STATUS GDS_SERVICE_QUERY(ISC_STATUS* user_status,
// If there is a status vector from a service thread, copy it into the thread status // If there is a status vector from a service thread, copy it into the thread status
int len, warning; int len, warning;
PARSE_STATUS(service->getStatus(), len, warning); PARSE_STATUS(service->getStatus(), len, warning);
if (len) { if (len)
{
memcpy(user_status, service->getStatus(), sizeof(ISC_STATUS) * len); memcpy(user_status, service->getStatus(), sizeof(ISC_STATUS) * len);
// Empty out the service status vector // Empty out the service status vector
memset(service->getStatus(), 0, sizeof(ISC_STATUS_ARRAY)); memset(service->getStatus(), 0, sizeof(ISC_STATUS_ARRAY));
@ -3436,7 +3462,8 @@ ISC_STATUS GDS_START_TRANSACTION(ISC_STATUS* user_status,
va_list ptr; va_list ptr;
va_start(ptr, count); va_start(ptr, count);
for (TEB* teb_iter = tebs.begin(); teb_iter < tebs.end(); teb_iter++) { for (TEB* teb_iter = tebs.begin(); teb_iter < tebs.end(); teb_iter++)
{
teb_iter->teb_database = va_arg(ptr, Attachment**); teb_iter->teb_database = va_arg(ptr, Attachment**);
teb_iter->teb_tpb_length = va_arg(ptr, int); teb_iter->teb_tpb_length = va_arg(ptr, int);
teb_iter->teb_tpb = va_arg(ptr, UCHAR*); teb_iter->teb_tpb = va_arg(ptr, UCHAR*);
@ -3536,7 +3563,8 @@ ISC_STATUS GDS_TRANSACT_REQUEST(ISC_STATUS* user_status,
USHORT len; USHORT len;
if (in_msg_length) if (in_msg_length)
{ {
if (in_message) { if (in_message)
{
const Format* format = (Format*) in_message->nod_arg[e_msg_format]; const Format* format = (Format*) in_message->nod_arg[e_msg_format];
len = format->fmt_length; len = format->fmt_length;
} }
@ -3555,7 +3583,8 @@ ISC_STATUS GDS_TRANSACT_REQUEST(ISC_STATUS* user_status,
EXE_start(tdbb, request, transaction); EXE_start(tdbb, request, transaction);
if (out_message) { if (out_message)
{
const Format* format = (Format*) out_message->nod_arg[e_msg_format]; const Format* format = (Format*) out_message->nod_arg[e_msg_format];
len = format->fmt_length; len = format->fmt_length;
} }
@ -3563,7 +3592,8 @@ ISC_STATUS GDS_TRANSACT_REQUEST(ISC_STATUS* user_status,
len = 0; len = 0;
} }
if (out_msg_length != len) { if (out_msg_length != len)
{
ERR_post(Arg::Gds(isc_port_len) << Arg::Num(out_msg_length) << ERR_post(Arg::Gds(isc_port_len) << Arg::Num(out_msg_length) <<
Arg::Num(len)); Arg::Num(len));
} }
@ -3954,7 +3984,8 @@ void JRD_print_procedure_info(thread_db* tdbb, const char* mesg)
gds__prefix(fname, "proc_info.log"); gds__prefix(fname, "proc_info.log");
FILE* fptr = fopen(fname, "a+"); FILE* fptr = fopen(fname, "a+");
if (!fptr) { if (!fptr)
{
gds__log("Failed to open %s\n", fname); gds__log("Failed to open %s\n", fname);
return; return;
} }
@ -3964,18 +3995,21 @@ void JRD_print_procedure_info(thread_db* tdbb, const char* mesg)
fprintf(fptr, "Prc Name , prc id , flags , Use Count , Alter Count\n"); fprintf(fptr, "Prc Name , prc id , flags , Use Count , Alter Count\n");
vec<jrd_prc*>* procedures = tdbb->getDatabase()->dbb_procedures; vec<jrd_prc*>* procedures = tdbb->getDatabase()->dbb_procedures;
if (procedures) { if (procedures)
{
vec<jrd_prc*>::iterator ptr, end; vec<jrd_prc*>::iterator ptr, end;
for (ptr = procedures->begin(), end = procedures->end(); ptr < end; ++ptr) for (ptr = procedures->begin(), end = procedures->end(); ptr < end; ++ptr)
{ {
const jrd_prc* procedure = *ptr; const jrd_prc* procedure = *ptr;
if (procedure) if (procedure)
{
fprintf(fptr, "%s , %d, %X, %d, %d\n", fprintf(fptr, "%s , %d, %X, %d, %d\n",
procedure->prc_name->hasData() ? procedure->prc_name->c_str() : "NULL", procedure->prc_name->hasData() ? procedure->prc_name->c_str() : "NULL",
procedure->prc_id, procedure->prc_flags, procedure->prc_use_count, procedure->prc_id, procedure->prc_flags, procedure->prc_use_count,
0); // procedure->prc_alter_count 0); // procedure->prc_alter_count
} }
} }
}
else else
fprintf(fptr, "No Cached Procedures\n"); fprintf(fptr, "No Cached Procedures\n");
@ -4121,7 +4155,8 @@ void jrd_vtof(const char* string, char* field, SSHORT length)
* *
**************************************/ **************************************/
while (*string) { while (*string)
{
*field++ = *string++; *field++ = *string++;
if (--length <= 0) { if (--length <= 0) {
return; return;
@ -4339,7 +4374,8 @@ static void find_intl_charset(thread_db* tdbb, Attachment* attachment, const Dat
**************************************/ **************************************/
SET_TDBB(tdbb); SET_TDBB(tdbb);
if (options->dpb_lc_ctype.isEmpty()) { if (options->dpb_lc_ctype.isEmpty())
{
// No declaration of character set, act like 3.x Interbase // No declaration of character set, act like 3.x Interbase
attachment->att_charset = DEFAULT_ATTACHMENT_CHARSET; attachment->att_charset = DEFAULT_ATTACHMENT_CHARSET;
return; return;
@ -4408,7 +4444,7 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
dpb_utf8_filename = rdr.find(isc_dpb_utf8_filename); dpb_utf8_filename = rdr.find(isc_dpb_utf8_filename);
for (rdr.rewind(); !(rdr.isEof()); rdr.moveNext()) for (rdr.rewind(); !rdr.isEof(); rdr.moveNext())
{ {
switch (rdr.getClumpTag()) switch (rdr.getClumpTag())
{ {
@ -4682,14 +4718,17 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
{ {
ClumpletReader address_stack(ClumpletReader::UnTagged, ClumpletReader address_stack(ClumpletReader::UnTagged,
rdr.getBytes(), rdr.getClumpLength()); rdr.getBytes(), rdr.getClumpLength());
while (!address_stack.isEof()) { while (!address_stack.isEof())
if (address_stack.getClumpTag() != isc_dpb_address) { {
if (address_stack.getClumpTag() != isc_dpb_address)
{
address_stack.moveNext(); address_stack.moveNext();
continue; continue;
} }
ClumpletReader address(ClumpletReader::UnTagged, ClumpletReader address(ClumpletReader::UnTagged,
address_stack.getBytes(), address_stack.getClumpLength()); address_stack.getBytes(), address_stack.getClumpLength());
while (!address.isEof()) { while (!address.isEof())
{
switch (address.getClumpTag()) switch (address.getClumpTag())
{ {
case isc_dpb_addr_protocol: case isc_dpb_addr_protocol:
@ -4859,7 +4898,8 @@ static Database* init(thread_db* tdbb,
// Lookup some external "hooks" // Lookup some external "hooks"
PluginManager::Plugin crypt_lib = PluginManager::enginePluginManager().findPlugin(CRYPT_IMAGE); PluginManager::Plugin crypt_lib = PluginManager::enginePluginManager().findPlugin(CRYPT_IMAGE);
if (crypt_lib) { if (crypt_lib)
{
string encrypt_entrypoint(ENCRYPT); string encrypt_entrypoint(ENCRYPT);
string decrypt_entrypoint(DECRYPT); string decrypt_entrypoint(DECRYPT);
dbb->dbb_encrypt = (Database::crypt_routine) crypt_lib.lookupSymbol(encrypt_entrypoint); dbb->dbb_encrypt = (Database::crypt_routine) crypt_lib.lookupSymbol(encrypt_entrypoint);
@ -4973,7 +5013,8 @@ static void prepare(thread_db* tdbb,
run_commit_triggers(tdbb, transaction); run_commit_triggers(tdbb, transaction);
} }
for (; transaction; transaction = transaction->tra_sibling) { for (; transaction; transaction = transaction->tra_sibling)
{
validateHandle(tdbb, transaction->tra_attachment); validateHandle(tdbb, transaction->tra_attachment);
tdbb->setTransaction(transaction); tdbb->setTransaction(transaction);
check_database(tdbb); check_database(tdbb);
@ -5064,14 +5105,16 @@ static void release_attachment(thread_db* tdbb, Attachment* attachment, ISC_STAT
detachLocksFromAttachment(attachment); detachLocksFromAttachment(attachment);
if (attachment->att_flags & ATT_lck_init_done) { if (attachment->att_flags & ATT_lck_init_done)
{
LCK_fini(tdbb, LCK_OWNER_attachment); LCK_fini(tdbb, LCK_OWNER_attachment);
attachment->att_flags &= ~ATT_lck_init_done; attachment->att_flags &= ~ATT_lck_init_done;
} }
delete attachment->att_compatibility_table; delete attachment->att_compatibility_table;
if (attachment->att_dsql_instance) { if (attachment->att_dsql_instance)
{
MemoryPool* const pool = &attachment->att_dsql_instance->dbb_pool; MemoryPool* const pool = &attachment->att_dsql_instance->dbb_pool;
delete attachment->att_dsql_instance; delete attachment->att_dsql_instance;
dbb->deletePool(pool); dbb->deletePool(pool);
@ -5079,8 +5122,10 @@ static void release_attachment(thread_db* tdbb, Attachment* attachment, ISC_STAT
// remove the attachment block from the dbb linked list // remove the attachment block from the dbb linked list
for (Attachment** ptr = &dbb->dbb_attachments; *ptr; ptr = &(*ptr)->att_next) { for (Attachment** ptr = &dbb->dbb_attachments; *ptr; ptr = &(*ptr)->att_next)
if (*ptr == attachment) { {
if (*ptr == attachment)
{
*ptr = attachment->att_next; *ptr = attachment->att_next;
break; break;
} }
@ -5117,7 +5162,8 @@ static void detachLocksFromAttachment(Attachment* attachment)
* *
**************************************/ **************************************/
Lock* long_lock = attachment->att_long_locks; Lock* long_lock = attachment->att_long_locks;
while (long_lock) { while (long_lock)
{
Lock* next = long_lock->lck_next; Lock* next = long_lock->lck_next;
long_lock->lck_attachment = NULL; long_lock->lck_attachment = NULL;
long_lock->lck_next = NULL; long_lock->lck_next = NULL;
@ -5375,21 +5421,25 @@ static void shutdown_database(Database* dbb, const bool release_pools)
LCK_release(tdbb, dbb->dbb_lock); LCK_release(tdbb, dbb->dbb_lock);
Database** d_ptr; // Intentionally left outside loop (HP/UX compiler) Database** d_ptr; // Intentionally left outside loop (HP/UX compiler)
for (d_ptr = &databases; *d_ptr; d_ptr = &(*d_ptr)->dbb_next) { for (d_ptr = &databases; *d_ptr; d_ptr = &(*d_ptr)->dbb_next)
if (*d_ptr == dbb) { {
if (*d_ptr == dbb)
{
*d_ptr = dbb->dbb_next; *d_ptr = dbb->dbb_next;
break; break;
} }
} }
if (dbb->dbb_flags & DBB_lck_init_done) { if (dbb->dbb_flags & DBB_lck_init_done)
{
dbb->dbb_page_manager.releaseLocks(); dbb->dbb_page_manager.releaseLocks();
LCK_fini(tdbb, LCK_OWNER_database); LCK_fini(tdbb, LCK_OWNER_database);
dbb->dbb_flags &= ~DBB_lck_init_done; dbb->dbb_flags &= ~DBB_lck_init_done;
} }
if (release_pools) { if (release_pools)
{
tdbb->setDatabase(NULL); tdbb->setDatabase(NULL);
Database::destroy(dbb); Database::destroy(dbb);
} }
@ -5509,8 +5559,10 @@ UCHAR* JRD_num_attachments(UCHAR* const buf, USHORT buf_len, JRD_info_tag flag,
// Check that the buffer is big enough for the requested // Check that the buffer is big enough for the requested
// information. If not, unset the flag // information. If not, unset the flag
if (flag == JRD_info_drivemask) { if (flag == JRD_info_drivemask)
if (buf_len < sizeof(ULONG)) { {
if (buf_len < sizeof(ULONG))
{
lbuf = (UCHAR*) gds__alloc((SLONG) (sizeof(ULONG))); lbuf = (UCHAR*) gds__alloc((SLONG) (sizeof(ULONG)));
if (!lbuf) if (!lbuf)
flag = JRD_info_none; flag = JRD_info_none;
@ -5560,9 +5612,11 @@ UCHAR* JRD_num_attachments(UCHAR* const buf, USHORT buf_len, JRD_info_tag flag,
#ifdef WIN_NT #ifdef WIN_NT
// Get drive letters for temp directories // Get drive letters for temp directories
if (flag == JRD_info_drivemask) { if (flag == JRD_info_drivemask)
{
const TempDirectoryList dirList; const TempDirectoryList dirList;
for (size_t i = 0; i < dirList.getCount(); i++) { for (size_t i = 0; i < dirList.getCount(); i++)
{
const PathName& path = dirList[i]; const PathName& path = dirList[i];
ExtractDriveLetter(path.c_str(), &drive_mask); ExtractDriveLetter(path.c_str(), &drive_mask);
} }
@ -5612,7 +5666,8 @@ UCHAR* JRD_num_attachments(UCHAR* const buf, USHORT buf_len, JRD_info_tag flag,
*lbufp++ = (UCHAR) num_dbs; *lbufp++ = (UCHAR) num_dbs;
*lbufp++ = (UCHAR) (num_dbs >> 8); *lbufp++ = (UCHAR) (num_dbs >> 8);
for (size_t n = 0; n < num_dbs; ++n) { for (size_t n = 0; n < num_dbs; ++n)
{
const USHORT dblen = dbFiles[n].length(); const USHORT dblen = dbFiles[n].length();
*lbufp++ = (UCHAR) dblen; *lbufp++ = (UCHAR) dblen;
*lbufp++ = (UCHAR) (dblen >> 8); *lbufp++ = (UCHAR) (dblen >> 8);
@ -6505,7 +6560,8 @@ void JRD_start_transaction(thread_db* tdbb, jrd_tra** transaction, SSHORT count,
va_list ptr; va_list ptr;
va_start(ptr, count); va_start(ptr, count);
for (TEB* teb_iter = tebs.begin(); teb_iter < tebs.end(); teb_iter++) { for (TEB* teb_iter = tebs.begin(); teb_iter < tebs.end(); teb_iter++)
{
teb_iter->teb_database = va_arg(ptr, Attachment**); teb_iter->teb_database = va_arg(ptr, Attachment**);
teb_iter->teb_tpb_length = va_arg(ptr, int); teb_iter->teb_tpb_length = va_arg(ptr, int);
teb_iter->teb_tpb = va_arg(ptr, UCHAR*); teb_iter->teb_tpb = va_arg(ptr, UCHAR*);