2001-05-23 15:26:42 +02:00
|
|
|
//____________________________________________________________
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
// PROGRAM: Alice (All Else) Utility
|
|
|
|
// MODULE: exe.cpp
|
|
|
|
// DESCRIPTION: Does the database calls
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
// The contents of this file are subject to the Interbase Public
|
|
|
|
// License Version 1.0 (the "License"); you may not use this file
|
|
|
|
// except in compliance with the License. You may obtain a copy
|
|
|
|
// of the License at http://www.Inprise.com/IPL.html
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
// Software distributed under the License is distributed on an
|
|
|
|
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
|
|
|
// or implied. See the License for the specific language governing
|
|
|
|
// rights and limitations under the License.
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
// The Original Code was created by Inprise Corporation
|
|
|
|
// and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
// Copyright (C) Inprise Corporation.
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
// All Rights Reserved.
|
|
|
|
// Contributor(s): ______________________________________.
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
//
|
|
|
|
//____________________________________________________________
|
|
|
|
//
|
2004-03-19 07:14:53 +01:00
|
|
|
// $Id: exe.cpp,v 1.30 2004-03-19 06:14:29 robocop Exp $
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
|
|
|
// 2001.07.06 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
|
|
|
|
// conditionals, as the engine now fully supports
|
|
|
|
// readonly databases.
|
2001-05-23 15:26:42 +02:00
|
|
|
//
|
2002-10-31 06:06:02 +01:00
|
|
|
// 2002.10.30 Sean Leyne - Removed obsolete "PC_PLATFORM" define
|
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-07-30 01:43:24 +02:00
|
|
|
#include "firebird.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
#include "../jrd/ib_stdio.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2003-11-08 00:09:04 +01:00
|
|
|
#include "../jrd/y_ref.h"
|
|
|
|
#include "../jrd/ibase.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
#include "../jrd/common.h"
|
|
|
|
#include "../alice/alice.h"
|
2003-09-15 15:13:45 +02:00
|
|
|
#include "../alice/alice_proto.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
#include "../alice/aliceswi.h"
|
|
|
|
#include "../alice/all.h"
|
|
|
|
#include "../alice/all_proto.h"
|
|
|
|
#include "../alice/alice_meta.h"
|
|
|
|
#include "../alice/tdr_proto.h"
|
|
|
|
#include "../jrd/gds_proto.h"
|
|
|
|
#include "../jrd/thd_proto.h"
|
|
|
|
|
|
|
|
|
2003-11-01 11:26:43 +01:00
|
|
|
static USHORT build_dpb(UCHAR*, const ULONG);
|
|
|
|
static void extract_db_info(const UCHAR*);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-29 11:53:47 +01:00
|
|
|
static const TEXT val_errors[] =
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
isc_info_page_errors, isc_info_record_errors, isc_info_bpage_errors,
|
|
|
|
isc_info_dpage_errors, isc_info_ipage_errors, isc_info_ppage_errors,
|
2003-11-08 00:09:04 +01:00
|
|
|
isc_info_tpage_errors, isc_info_end
|
2001-05-23 15:26:42 +02:00
|
|
|
};
|
|
|
|
|
2003-10-29 11:53:47 +01:00
|
|
|
static inline void stuff_dpb(UCHAR** d, int blr)
|
2003-09-18 12:56:32 +02:00
|
|
|
{
|
|
|
|
UCHAR *ptr = *d;
|
2003-09-22 10:49:45 +02:00
|
|
|
*ptr++ = (UCHAR)blr;
|
2003-09-18 12:56:32 +02:00
|
|
|
*d = ptr;
|
|
|
|
}
|
2003-09-22 10:49:45 +02:00
|
|
|
|
2003-10-29 11:53:47 +01:00
|
|
|
static inline void stuff_dpb_long(UCHAR** d, int blr)
|
2003-09-18 12:56:32 +02:00
|
|
|
{
|
|
|
|
stuff_dpb(d, blr);
|
2003-09-22 10:49:45 +02:00
|
|
|
stuff_dpb(d, blr >> 8);
|
|
|
|
stuff_dpb(d, blr >> 16);
|
|
|
|
stuff_dpb(d, blr >> 24);
|
2003-09-18 12:56:32 +02:00
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//____________________________________________________________
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-11-01 11:26:43 +01:00
|
|
|
int EXE_action(const TEXT* database, const ULONG switches)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
UCHAR dpb[128];
|
2004-03-19 07:14:53 +01:00
|
|
|
Tgbl* tdgbl = GET_THREAD_DATA;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
ALLA_init();
|
|
|
|
|
2003-09-25 13:49:12 +02:00
|
|
|
for (USHORT i = 0; i < MAX_VAL_ERRORS; i++)
|
2001-05-23 15:26:42 +02:00
|
|
|
tdgbl->ALICE_data.ua_val_errors[i] = 0;
|
|
|
|
|
|
|
|
// generate the database parameter block for the attach,
|
2001-07-10 19:35:13 +02:00
|
|
|
// based on the various switches
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-09-25 13:49:12 +02:00
|
|
|
const USHORT dpb_length = build_dpb(dpb, switches);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-09-25 13:49:12 +02:00
|
|
|
bool error = false;
|
|
|
|
FRBRD* handle = NULL;
|
2003-11-08 00:09:04 +01:00
|
|
|
isc_attach_database(tdgbl->status, 0, database, &handle, dpb_length,
|
2003-09-25 13:49:12 +02:00
|
|
|
reinterpret_cast<SCHAR*>(dpb));
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-02-20 07:43:27 +01:00
|
|
|
tdgbl->service_blk->svc_started();
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-02-25 02:50:40 +01:00
|
|
|
if (tdgbl->status[1] &&
|
|
|
|
// Ignore isc_shutdown error produced when we switch to full shutdown mode. It is expected.
|
|
|
|
(tdgbl->status[1] != isc_shutdown || !(switches & sw_shut) || tdgbl->ALICE_data.ua_shutdown_mode != SHUT_FULL)
|
|
|
|
)
|
|
|
|
{
|
2003-09-10 19:52:12 +02:00
|
|
|
error = true;
|
2004-02-25 02:50:40 +01:00
|
|
|
}
|
|
|
|
|
2001-05-23 15:26:42 +02:00
|
|
|
if (tdgbl->status[2] == isc_arg_warning)
|
|
|
|
ALICE_print_status(tdgbl->status);
|
|
|
|
|
|
|
|
if (handle != NULL) {
|
2003-09-25 13:49:12 +02:00
|
|
|
UCHAR error_string[128];
|
2001-05-23 15:26:42 +02:00
|
|
|
if ((switches & sw_validate) && (tdgbl->status[1] != isc_bug_check)) {
|
2003-11-08 00:09:04 +01:00
|
|
|
isc_database_info(tdgbl->status, &handle, sizeof(val_errors),
|
2003-08-30 04:02:36 +02:00
|
|
|
val_errors, sizeof(error_string),
|
2003-09-25 13:49:12 +02:00
|
|
|
reinterpret_cast<char*>(error_string));
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
extract_db_info(error_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (switches & sw_disable)
|
|
|
|
MET_disable_wal(tdgbl->status, handle);
|
|
|
|
|
2003-11-08 00:09:04 +01:00
|
|
|
isc_detach_database(tdgbl->status, &handle);
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ALLA_fini();
|
|
|
|
|
|
|
|
return ((error) ? FINI_ERROR : FINI_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//____________________________________________________________
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-11-01 11:26:43 +01:00
|
|
|
int EXE_two_phase(const TEXT* database, const ULONG switches)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
UCHAR dpb[128];
|
2004-03-19 07:14:53 +01:00
|
|
|
Tgbl* tdgbl = GET_THREAD_DATA;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
ALLA_init();
|
|
|
|
|
2003-09-25 13:49:12 +02:00
|
|
|
for (USHORT i = 0; i < MAX_VAL_ERRORS; i++)
|
2001-05-23 15:26:42 +02:00
|
|
|
tdgbl->ALICE_data.ua_val_errors[i] = 0;
|
|
|
|
|
|
|
|
// generate the database parameter block for the attach,
|
2001-07-10 19:35:13 +02:00
|
|
|
// based on the various switches
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-09-25 13:49:12 +02:00
|
|
|
const USHORT dpb_length = build_dpb(dpb, switches);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-09-25 13:49:12 +02:00
|
|
|
bool error = false;
|
|
|
|
FRBRD* handle = NULL;
|
2003-11-08 00:09:04 +01:00
|
|
|
isc_attach_database(tdgbl->status, 0, database, &handle,
|
2003-09-25 13:49:12 +02:00
|
|
|
dpb_length, reinterpret_cast<char*>(dpb));
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-02-20 07:43:27 +01:00
|
|
|
tdgbl->service_blk->svc_started();
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
if (tdgbl->status[1])
|
2003-09-10 19:52:12 +02:00
|
|
|
error = true;
|
2001-05-23 15:26:42 +02:00
|
|
|
else if (switches & sw_list)
|
2002-12-16 16:16:32 +01:00
|
|
|
TDR_list_limbo((handle), database, switches);
|
2001-05-23 15:26:42 +02:00
|
|
|
else if (switches & (sw_commit | sw_rollback | sw_two_phase))
|
2003-09-10 19:52:12 +02:00
|
|
|
error = TDR_reconnect_multiple((handle),
|
|
|
|
tdgbl->ALICE_data.ua_transaction, database,
|
|
|
|
switches);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
if (handle)
|
2003-11-08 00:09:04 +01:00
|
|
|
isc_detach_database(tdgbl->status, &handle);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
ALLA_fini();
|
|
|
|
|
|
|
|
return ((error) ? FINI_ERROR : FINI_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
//____________________________________________________________
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
|
|
|
//
|
|
|
|
// generate the database parameter block for the attach,
|
|
|
|
// based on the various switches
|
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-11-01 11:26:43 +01:00
|
|
|
static USHORT build_dpb(UCHAR* dpb, const ULONG switches)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2004-03-19 07:14:53 +01:00
|
|
|
Tgbl* tdgbl = GET_THREAD_DATA;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-09-25 13:49:12 +02:00
|
|
|
UCHAR* dpb2 = dpb;
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_version1;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = isc_dpb_gfix_attach;
|
|
|
|
*dpb2++ = 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
if (switches & sw_sweep) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_sweep;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = 1;
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_records;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_activate) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_activate_shadow;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_validate) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_verify;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = 1;
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2 = isc_dpb_pages;
|
2001-05-23 15:26:42 +02:00
|
|
|
if (switches & sw_full)
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2 |= isc_dpb_records;
|
2001-05-23 15:26:42 +02:00
|
|
|
if (switches & sw_no_update)
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2 |= isc_dpb_no_update;
|
2001-05-23 15:26:42 +02:00
|
|
|
if (switches & sw_mend)
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2 |= isc_dpb_repair;
|
2001-05-23 15:26:42 +02:00
|
|
|
if (switches & sw_ignore)
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2 |= isc_dpb_ignore;
|
2003-09-18 12:56:32 +02:00
|
|
|
dpb2++;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_housekeeping) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_sweep_interval;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = 4;
|
2003-09-25 13:49:12 +02:00
|
|
|
for (int i = 0; i < 4; i++, (tdgbl->ALICE_data.ua_sweep_interval >>= 8))
|
2003-09-18 12:56:32 +02:00
|
|
|
{
|
2003-09-25 13:49:12 +02:00
|
|
|
// TMN: Here we should really have the following assert
|
2003-11-04 00:59:24 +01:00
|
|
|
// fb_assert(tdgbl->ALICE_data.ua_sweep_interval <= MAX_UCHAR);
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = (UCHAR) tdgbl->ALICE_data.ua_sweep_interval;
|
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_begin_log) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_begin_log;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = strlen(tdgbl->ALICE_data.ua_log_file);
|
2003-10-16 10:51:06 +02:00
|
|
|
for (const char* q = tdgbl->ALICE_data.ua_log_file; *q;)
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = *q++;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_buffers) {
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = isc_dpb_set_page_buffers;
|
|
|
|
*dpb2++ = 4;
|
2003-09-25 13:49:12 +02:00
|
|
|
for (int i = 0; i < 4; i++, (tdgbl->ALICE_data.ua_page_buffers >>= 8))
|
2003-09-18 12:56:32 +02:00
|
|
|
{
|
2003-09-25 13:49:12 +02:00
|
|
|
// TMN: Here we should really have the following assert
|
2003-11-04 00:59:24 +01:00
|
|
|
// fb_assert(tdgbl->ALICE_data.ua_page_buffers <= MAX_UCHAR);
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = (UCHAR) tdgbl->ALICE_data.ua_page_buffers;
|
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_quit_log) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_quit_log;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_kill) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_delete_shadow;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_write) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_force_write;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = 1;
|
|
|
|
*dpb2++ = tdgbl->ALICE_data.ua_force ? 1 : 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_use) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_no_reserve;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = 1;
|
|
|
|
*dpb2++ = tdgbl->ALICE_data.ua_use ? 1 : 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
2001-07-10 19:35:13 +02:00
|
|
|
|
2001-05-23 15:26:42 +02:00
|
|
|
else if (switches & sw_mode) {
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = isc_dpb_set_db_readonly;
|
|
|
|
*dpb2++ = 1;
|
|
|
|
*dpb2++ = (tdgbl->ALICE_data.ua_read_only) ? 1 : 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_shut) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_shutdown;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = 1;
|
|
|
|
*dpb2 = 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
if (switches & sw_attach)
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2 |= isc_dpb_shut_attachment;
|
2001-05-23 15:26:42 +02:00
|
|
|
else if (switches & sw_cache)
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2 |= isc_dpb_shut_cache;
|
2001-05-23 15:26:42 +02:00
|
|
|
else if (switches & sw_force)
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2 |= isc_dpb_shut_force;
|
2001-05-23 15:26:42 +02:00
|
|
|
else if (switches & sw_tran)
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2 |= isc_dpb_shut_transaction;
|
2004-02-25 02:50:40 +01:00
|
|
|
switch(tdgbl->ALICE_data.ua_shutdown_mode) {
|
|
|
|
case SHUT_NORMAL:
|
|
|
|
*dpb2 |= isc_dpb_shut_normal;
|
|
|
|
break;
|
|
|
|
case SHUT_SINGLE:
|
|
|
|
*dpb2 |= isc_dpb_shut_single;
|
|
|
|
break;
|
|
|
|
case SHUT_MULTI:
|
|
|
|
*dpb2 |= isc_dpb_shut_multi;
|
|
|
|
break;
|
|
|
|
case SHUT_FULL:
|
|
|
|
*dpb2 |= isc_dpb_shut_full;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-09-18 12:56:32 +02:00
|
|
|
dpb2++;
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_shutdown_delay;
|
2003-09-25 13:49:12 +02:00
|
|
|
*dpb2++ = 2; // Build room for shutdown delay
|
|
|
|
// TMN: Here we should really have the following assert
|
2003-11-04 00:59:24 +01:00
|
|
|
// fb_assert(tdgbl->ALICE_data.ua_page_buffers <= MAX_USHORT);
|
2003-09-25 13:49:12 +02:00
|
|
|
// or maybe even compare with MAX_SSHORT
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = (UCHAR) tdgbl->ALICE_data.ua_shutdown_delay;
|
|
|
|
*dpb2++ = (UCHAR) (tdgbl->ALICE_data.ua_shutdown_delay >> 8);
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_online) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_online;
|
2004-02-25 02:50:40 +01:00
|
|
|
*dpb2++ = 1;
|
|
|
|
*dpb2 = 0;
|
|
|
|
switch(tdgbl->ALICE_data.ua_shutdown_mode) {
|
|
|
|
case SHUT_NORMAL:
|
|
|
|
*dpb2 |= isc_dpb_shut_normal;
|
|
|
|
break;
|
|
|
|
case SHUT_SINGLE:
|
|
|
|
*dpb2 |= isc_dpb_shut_single;
|
|
|
|
break;
|
|
|
|
case SHUT_MULTI:
|
|
|
|
*dpb2 |= isc_dpb_shut_multi;
|
|
|
|
break;
|
|
|
|
case SHUT_FULL:
|
|
|
|
*dpb2 |= isc_dpb_shut_full;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dpb2++;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_disable) {
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = isc_dpb_disable_wal;
|
|
|
|
*dpb2++ = 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & (sw_list | sw_commit | sw_rollback | sw_two_phase)) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_no_garbage_collect;
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else if (switches & sw_set_db_dialect) {
|
2003-09-18 12:56:32 +02:00
|
|
|
stuff_dpb(&dpb2, isc_dpb_set_db_sql_dialect);
|
|
|
|
stuff_dpb(&dpb2, 4);
|
2003-09-22 10:49:45 +02:00
|
|
|
stuff_dpb_long(&dpb2, tdgbl->ALICE_data.ua_db_SQL_dialect);
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tdgbl->ALICE_data.ua_user) {
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_user_name;
|
2003-09-25 13:49:12 +02:00
|
|
|
*dpb2++ = strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_user));
|
2003-10-16 10:51:06 +02:00
|
|
|
for (const UCHAR* q = tdgbl->ALICE_data.ua_user; *q;)
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = *q++;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tdgbl->ALICE_data.ua_password) {
|
2003-03-13 17:54:04 +01:00
|
|
|
if (!tdgbl->sw_service)
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_password;
|
2001-05-23 15:26:42 +02:00
|
|
|
else
|
2003-11-08 00:09:04 +01:00
|
|
|
*dpb2++ = isc_dpb_password_enc;
|
2003-09-25 13:49:12 +02:00
|
|
|
*dpb2++ = strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_password));
|
2003-10-16 10:51:06 +02:00
|
|
|
for (const UCHAR* q = tdgbl->ALICE_data.ua_password; *q;)
|
2003-09-18 12:56:32 +02:00
|
|
|
*dpb2++ = *q++;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
2003-09-25 13:49:12 +02:00
|
|
|
USHORT dpb_length = dpb2 - dpb;
|
2001-05-23 15:26:42 +02:00
|
|
|
if (dpb_length == 1)
|
|
|
|
dpb_length = 0;
|
|
|
|
|
|
|
|
return dpb_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//____________________________________________________________
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
// Extract database info from string
|
2001-07-10 19:35:13 +02:00
|
|
|
//
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-11-01 11:26:43 +01:00
|
|
|
static void extract_db_info(const UCHAR* db_info_buffer)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2004-03-19 07:14:53 +01:00
|
|
|
Tgbl* tdgbl = GET_THREAD_DATA;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-11-01 11:26:43 +01:00
|
|
|
const UCHAR* p = db_info_buffer;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-11-01 11:26:43 +01:00
|
|
|
UCHAR item;
|
2003-11-08 00:09:04 +01:00
|
|
|
while ((item = *p++) != isc_info_end) {
|
2003-11-16 02:44:51 +01:00
|
|
|
const SLONG length = gds__vax_integer(p, 2);
|
2001-05-23 15:26:42 +02:00
|
|
|
p += 2;
|
|
|
|
|
2003-09-25 13:49:12 +02:00
|
|
|
// TMN: Here we should really have the following assert
|
2003-11-04 00:59:24 +01:00
|
|
|
// fb_assert(length <= MAX_SSHORT);
|
2003-11-16 02:44:51 +01:00
|
|
|
// for all cases that use 'length' as input to 'gds__vax_integer'
|
2001-05-23 15:26:42 +02:00
|
|
|
switch (item) {
|
|
|
|
case isc_info_page_errors:
|
|
|
|
tdgbl->ALICE_data.ua_val_errors[VAL_PAGE_ERRORS] =
|
2003-11-16 02:44:51 +01:00
|
|
|
gds__vax_integer(p, (SSHORT) length);
|
2001-05-23 15:26:42 +02:00
|
|
|
p += length;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case isc_info_record_errors:
|
|
|
|
tdgbl->ALICE_data.ua_val_errors[VAL_RECORD_ERRORS] =
|
2003-11-16 02:44:51 +01:00
|
|
|
gds__vax_integer(p, (SSHORT) length);
|
2001-05-23 15:26:42 +02:00
|
|
|
p += length;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case isc_info_bpage_errors:
|
|
|
|
tdgbl->ALICE_data.ua_val_errors[VAL_BLOB_PAGE_ERRORS] =
|
2003-11-16 02:44:51 +01:00
|
|
|
gds__vax_integer(p, (SSHORT) length);
|
2001-05-23 15:26:42 +02:00
|
|
|
p += length;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case isc_info_dpage_errors:
|
|
|
|
tdgbl->ALICE_data.ua_val_errors[VAL_DATA_PAGE_ERRORS] =
|
2003-11-16 02:44:51 +01:00
|
|
|
gds__vax_integer(p, (SSHORT) length);
|
2001-05-23 15:26:42 +02:00
|
|
|
p += length;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case isc_info_ipage_errors:
|
|
|
|
tdgbl->ALICE_data.ua_val_errors[VAL_INDEX_PAGE_ERRORS] =
|
2003-11-16 02:44:51 +01:00
|
|
|
gds__vax_integer(p, (SSHORT) length);
|
2001-05-23 15:26:42 +02:00
|
|
|
p += length;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case isc_info_ppage_errors:
|
|
|
|
tdgbl->ALICE_data.ua_val_errors[VAL_POINTER_PAGE_ERRORS] =
|
2003-11-16 02:44:51 +01:00
|
|
|
gds__vax_integer(p, (SSHORT) length);
|
2001-05-23 15:26:42 +02:00
|
|
|
p += length;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case isc_info_tpage_errors:
|
|
|
|
tdgbl->ALICE_data.ua_val_errors[VAL_TIP_PAGE_ERRORS] =
|
2003-11-16 02:44:51 +01:00
|
|
|
gds__vax_integer(p, (SSHORT) length);
|
2001-05-23 15:26:42 +02:00
|
|
|
p += length;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case isc_info_error:
|
|
|
|
/* has to be a < V4 database. */
|
|
|
|
|
|
|
|
tdgbl->ALICE_data.ua_val_errors[VAL_INVALID_DB_VERSION] = 1;
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|