2001-05-23 15:26:42 +02:00
|
|
|
/*
|
|
|
|
* PROGRAM: Alice
|
|
|
|
* MODULE: alice.h
|
|
|
|
* DESCRIPTION: Block definitions
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Inprise Corporation
|
|
|
|
* and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
* Copyright (C) Inprise Corporation.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
|
|
|
*/
|
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
#ifndef ALICE_ALICE_H
|
|
|
|
#define ALICE_ALICE_H
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-04-29 00:00:03 +02:00
|
|
|
#include <stdio.h>
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
#include "../jrd/ibase.h"
|
2008-01-16 06:58:53 +01:00
|
|
|
#include "../jrd/ThreadData.h"
|
2001-12-24 03:51:06 +01:00
|
|
|
#include "../include/fb_blk.h"
|
2003-01-16 18:47:10 +01:00
|
|
|
#include "../common/classes/alloc.h"
|
2004-08-30 20:11:08 +02:00
|
|
|
#include "../common/classes/array.h"
|
2008-01-16 06:58:53 +01:00
|
|
|
#include "../common/UtilSvc.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-09-22 10:49:45 +02:00
|
|
|
enum val_errors {
|
2003-09-18 12:56:32 +02:00
|
|
|
VAL_INVALID_DB_VERSION = 0,
|
|
|
|
VAL_RECORD_ERRORS = 1,
|
|
|
|
VAL_BLOB_PAGE_ERRORS = 2,
|
|
|
|
VAL_DATA_PAGE_ERRORS = 3,
|
|
|
|
VAL_INDEX_PAGE_ERRORS = 4,
|
|
|
|
VAL_POINTER_PAGE_ERRORS = 5,
|
|
|
|
VAL_TIP_PAGE_ERRORS = 6,
|
|
|
|
VAL_PAGE_ERRORS = 7,
|
|
|
|
MAX_VAL_ERRORS = 8
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-02-25 02:50:40 +01:00
|
|
|
enum alice_shut_mode {
|
|
|
|
SHUT_DEFAULT = 0,
|
|
|
|
SHUT_NORMAL = 1,
|
|
|
|
SHUT_MULTI = 2,
|
|
|
|
SHUT_SINGLE = 3,
|
|
|
|
SHUT_FULL = 4
|
|
|
|
};
|
|
|
|
|
2004-05-24 19:22:35 +02:00
|
|
|
struct user_action
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
ULONG ua_switches;
|
2006-12-10 12:17:50 +01:00
|
|
|
const char* ua_user;
|
|
|
|
const char* ua_password;
|
|
|
|
const char* ua_tr_user;
|
2008-01-16 06:58:53 +01:00
|
|
|
bool ua_tr_role;
|
|
|
|
#ifdef TRUSTED_AUTH
|
2007-04-07 10:47:58 +02:00
|
|
|
bool ua_trusted;
|
2008-01-16 06:58:53 +01:00
|
|
|
#endif
|
2003-09-10 19:52:12 +02:00
|
|
|
bool ua_use;
|
|
|
|
bool ua_force;
|
|
|
|
bool ua_read_only;
|
2001-05-23 15:26:42 +02:00
|
|
|
SLONG ua_shutdown_delay;
|
|
|
|
SLONG ua_sweep_interval;
|
|
|
|
SLONG ua_transaction;
|
|
|
|
SLONG ua_page_buffers;
|
|
|
|
USHORT ua_debug;
|
|
|
|
SLONG ua_val_errors[MAX_VAL_ERRORS];
|
|
|
|
TEXT ua_log_file[MAXPATHLEN];
|
|
|
|
USHORT ua_db_SQL_dialect;
|
2004-02-25 02:50:40 +01:00
|
|
|
alice_shut_mode ua_shutdown_mode;
|
2004-05-24 19:22:35 +02:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-03-07 08:58:55 +01:00
|
|
|
// String block: used to store a string of constant length.
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-01-03 11:59:52 +01:00
|
|
|
class alice_str : public pool_alloc_rpt<UCHAR, alice_type_str>
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
|
|
|
public:
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT str_length;
|
|
|
|
UCHAR str_data[2];
|
2001-12-24 03:51:06 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-03-07 08:58:55 +01:00
|
|
|
// Transaction block: used to store info about a multidatabase transaction.
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-05-24 19:22:35 +02:00
|
|
|
struct tdr : public pool_alloc<alice_type_tdr>
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2004-03-07 08:58:55 +01:00
|
|
|
tdr* tdr_next; // next subtransaction
|
|
|
|
SLONG tdr_id; // database-specific transaction id
|
|
|
|
alice_str* tdr_fullpath; // full (possibly) remote pathname
|
|
|
|
const TEXT* tdr_filename; // filename within full pathname
|
|
|
|
alice_str* tdr_host_site; // host for transaction
|
|
|
|
alice_str* tdr_remote_site; // site for remote transaction
|
2004-05-03 01:06:37 +02:00
|
|
|
FB_API_HANDLE tdr_handle; // reconnected transaction handle
|
|
|
|
FB_API_HANDLE tdr_db_handle; // reattached database handle
|
2004-03-07 08:58:55 +01:00
|
|
|
USHORT tdr_db_caps; // capabilities of database
|
|
|
|
USHORT tdr_state; // see flags below
|
2004-05-24 19:22:35 +02:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-05-24 19:22:35 +02:00
|
|
|
typedef tdr* TDR;
|
2004-03-07 08:58:55 +01:00
|
|
|
// Transaction Description Record
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-09-18 12:56:32 +02:00
|
|
|
const int TDR_VERSION = 1;
|
2003-09-22 10:49:45 +02:00
|
|
|
enum tdr_vals {
|
2003-09-18 12:56:32 +02:00
|
|
|
TDR_HOST_SITE = 1,
|
|
|
|
TDR_DATABASE_PATH = 2,
|
|
|
|
TDR_TRANSACTION_ID = 3,
|
|
|
|
TDR_REMOTE_SITE = 4,
|
|
|
|
TDR_PROTOCOL = 5
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-03-07 08:58:55 +01:00
|
|
|
// flags for tdr_db_caps
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-09-18 12:56:32 +02:00
|
|
|
enum tdr_db_caps_vals {
|
|
|
|
CAP_none = 0,
|
|
|
|
CAP_transactions = 1
|
|
|
|
};
|
2004-03-07 08:58:55 +01:00
|
|
|
// db has a RDB$TRANSACTIONS relation
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-03-07 08:58:55 +01:00
|
|
|
// flags for tdr_state
|
2003-09-18 12:56:32 +02:00
|
|
|
enum tdr_state_vals {
|
2004-03-07 08:58:55 +01:00
|
|
|
TRA_none = 0, // transaction description record is missing
|
|
|
|
TRA_limbo = 1, // has been prepared
|
|
|
|
TRA_commit = 2, // has committed
|
|
|
|
TRA_rollback = 3, // has rolled back
|
|
|
|
TRA_unknown = 4 // database couldn't be reattached, state is unknown
|
2003-09-18 12:56:32 +02:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
2008-01-16 06:58:53 +01:00
|
|
|
// Global data
|
2004-07-02 12:02:46 +02:00
|
|
|
|
2004-08-30 20:11:08 +02:00
|
|
|
class AliceGlobals : public ThreadData
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2004-08-16 14:28:43 +02:00
|
|
|
private:
|
2008-01-29 13:28:28 +01:00
|
|
|
MemoryPool* ALICE_default_pool;
|
|
|
|
friend class Firebird::SubsystemContextPoolHolder <AliceGlobals, MemoryPool>;
|
2004-08-16 14:28:43 +02:00
|
|
|
|
2008-01-29 13:28:28 +01:00
|
|
|
void setDefaultPool(MemoryPool* p)
|
2004-08-16 14:28:43 +02:00
|
|
|
{
|
|
|
|
ALICE_default_pool = p;
|
|
|
|
}
|
2004-08-30 20:11:08 +02:00
|
|
|
|
|
|
|
public:
|
2008-01-16 06:58:53 +01:00
|
|
|
AliceGlobals(Firebird::UtilSvc* us)
|
2004-09-01 16:51:33 +02:00
|
|
|
: ThreadData(ThreadData::tddALICE),
|
2004-10-27 12:54:25 +02:00
|
|
|
ALICE_default_pool(0),
|
2006-05-19 17:17:02 +02:00
|
|
|
exit_code(FINI_ERROR), // prevent FINI_OK in case of unknown error thrown
|
2007-06-19 09:35:34 +02:00
|
|
|
// would be set to FINI_OK (==0) in ALICE_exit
|
2008-01-16 06:58:53 +01:00
|
|
|
uSvc(us),
|
2006-08-16 11:08:58 +02:00
|
|
|
output_file(NULL),
|
2005-07-24 17:32:53 +02:00
|
|
|
db_handle(0),
|
2006-08-16 11:08:58 +02:00
|
|
|
tr_handle(0),
|
2008-01-16 06:58:53 +01:00
|
|
|
status(status_vector)
|
2004-08-30 20:11:08 +02:00
|
|
|
{
|
2006-08-16 11:08:58 +02:00
|
|
|
memset(&ALICE_data, 0, sizeof(user_action));
|
2004-08-30 20:11:08 +02:00
|
|
|
}
|
|
|
|
|
2008-01-29 13:28:28 +01:00
|
|
|
MemoryPool* getDefaultPool()
|
2004-08-16 14:28:43 +02:00
|
|
|
{
|
|
|
|
return ALICE_default_pool;
|
|
|
|
}
|
2001-12-24 03:51:06 +01:00
|
|
|
|
2003-08-27 12:20:07 +02:00
|
|
|
user_action ALICE_data;
|
2003-04-16 12:18:51 +02:00
|
|
|
ISC_STATUS_ARRAY status_vector;
|
2001-05-23 15:26:42 +02:00
|
|
|
int exit_code;
|
2008-01-16 06:58:53 +01:00
|
|
|
Firebird::UtilSvc* uSvc;
|
2004-04-29 00:00:03 +02:00
|
|
|
FILE* output_file;
|
2001-05-23 15:26:42 +02:00
|
|
|
isc_db_handle db_handle;
|
|
|
|
isc_tr_handle tr_handle;
|
2003-04-10 08:32:58 +02:00
|
|
|
ISC_STATUS* status;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-07-02 12:02:46 +02:00
|
|
|
static inline AliceGlobals* getSpecific() {
|
2004-09-01 16:51:33 +02:00
|
|
|
ThreadData* tData = ThreadData::getSpecific();
|
|
|
|
fb_assert (tData->getType() == ThreadData::tddALICE)
|
|
|
|
return (AliceGlobals*) tData;
|
2004-07-02 12:02:46 +02:00
|
|
|
}
|
|
|
|
static inline void putSpecific(AliceGlobals* tdgbl) {
|
2004-08-30 20:11:08 +02:00
|
|
|
tdgbl->ThreadData::putSpecific();
|
2004-07-02 12:02:46 +02:00
|
|
|
}
|
|
|
|
static inline void restoreSpecific() {
|
2004-08-30 20:11:08 +02:00
|
|
|
ThreadData::restoreSpecific();
|
2004-07-02 12:02:46 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-01-29 13:28:28 +01:00
|
|
|
typedef Firebird::SubsystemContextPoolHolder <AliceGlobals, MemoryPool>
|
2004-08-30 20:11:08 +02:00
|
|
|
AliceContextPoolHolder;
|
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
#endif // ALICE_ALICE_H
|
2003-09-22 10:49:45 +02:00
|
|
|
|