2001-05-23 15:26:42 +02:00
|
|
|
/*
|
|
|
|
* PROGRAM: JRD Access Method
|
|
|
|
* MODULE: lck.h
|
|
|
|
* DESCRIPTION: Lock hander definitions (NOT lock manager)
|
|
|
|
*
|
|
|
|
* 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): ______________________________________.
|
|
|
|
*/
|
|
|
|
|
2003-10-03 03:53:34 +02:00
|
|
|
#ifndef JRD_LCK_H
|
|
|
|
#define JRD_LCK_H
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-03-18 06:56:06 +01:00
|
|
|
struct blk;
|
2004-03-20 15:57:40 +01:00
|
|
|
|
|
|
|
namespace Jrd {
|
|
|
|
|
2006-05-02 03:01:26 +02:00
|
|
|
class Database;
|
|
|
|
class Attachment;
|
2004-03-18 06:56:06 +01:00
|
|
|
|
2001-05-23 15:26:42 +02:00
|
|
|
/* Lock types */
|
|
|
|
|
|
|
|
enum lck_t {
|
|
|
|
LCK_database = 1, /* Root of lock tree */
|
|
|
|
LCK_relation, /* Individual relation lock */
|
|
|
|
LCK_bdb, /* Individual buffer block */
|
|
|
|
LCK_tra, /* Individual transaction lock */
|
|
|
|
LCK_rel_exist, /* Relation existence lock */
|
|
|
|
LCK_idx_exist, /* Index existence lock */
|
|
|
|
LCK_attachment, /* Attachment lock */
|
|
|
|
LCK_shadow, /* Lock to synchronize addition of shadows */
|
|
|
|
LCK_sweep, /* Sweep lock for single sweeper */
|
|
|
|
LCK_retaining, /* Youngest commit retaining transaction */
|
|
|
|
LCK_expression, /* Expression index caching mechanism */
|
|
|
|
LCK_record_locking, /* Lock on existence of record locking for this database */
|
2006-02-03 23:05:04 +01:00
|
|
|
LCK_prc_exist, /* Procedure existence lock */
|
2003-08-06 18:30:49 +02:00
|
|
|
LCK_update_shadow, /* shadow update sync lock */
|
2003-09-08 22:23:46 +02:00
|
|
|
LCK_backup_alloc, /* Lock for page allocation table in backup spare file */
|
2005-06-26 23:48:47 +02:00
|
|
|
LCK_backup_database, /* Lock to protect writing to database file */
|
2007-04-24 16:05:46 +02:00
|
|
|
LCK_backup_end, /* Lock to protect end_backup consistency */
|
2006-05-22 00:07:35 +02:00
|
|
|
LCK_rel_partners, /* Relation partners lock */
|
2006-07-10 05:12:10 +02:00
|
|
|
LCK_page_space, /* Page space ID lock */
|
2006-07-19 08:19:56 +02:00
|
|
|
LCK_dsql_cache, /* DSQL cache lock */
|
2006-10-07 12:53:01 +02:00
|
|
|
LCK_monitor, /* Lock to dump the monitoring data */
|
2006-10-30 13:39:08 +01:00
|
|
|
LCK_instance, /* Lock to identify a dbb instance */
|
2006-12-04 22:36:29 +01:00
|
|
|
LCK_tt_exist, /* TextType existence lock */
|
2007-01-07 16:15:06 +01:00
|
|
|
LCK_cancel /* Cancellation lock */
|
2001-05-23 15:26:42 +02:00
|
|
|
};
|
|
|
|
|
2008-01-16 10:29:37 +01:00
|
|
|
/* Lock owner types */
|
|
|
|
|
|
|
|
enum lck_owner_t {
|
|
|
|
LCK_OWNER_database = 1, // A database is the owner of the lock
|
|
|
|
LCK_OWNER_attachment // An attachment is the owner of the lock
|
|
|
|
};
|
2001-12-24 03:51:06 +01:00
|
|
|
|
2006-05-02 03:01:26 +02:00
|
|
|
class Lock : public pool_alloc_rpt<UCHAR, type_lck>
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
|
|
|
public:
|
2004-03-18 06:56:06 +01:00
|
|
|
Lock()
|
2003-01-28 16:23:28 +01:00
|
|
|
: lck_test_field(666),
|
2001-12-24 03:51:06 +01:00
|
|
|
lck_parent(0),
|
|
|
|
lck_next(0),
|
|
|
|
lck_prior(0),
|
|
|
|
lck_collision(0),
|
|
|
|
lck_identical(0),
|
|
|
|
lck_dbb(0),
|
|
|
|
lck_object(0),
|
|
|
|
lck_compatible(0),
|
|
|
|
lck_compatible2(0),
|
|
|
|
lck_attachment(0),
|
|
|
|
lck_ast(0),
|
|
|
|
lck_id(0),
|
|
|
|
lck_owner_handle(0),
|
|
|
|
lck_length(0),
|
|
|
|
lck_logical(0),
|
|
|
|
lck_physical(0),
|
2003-01-28 16:23:28 +01:00
|
|
|
lck_data(0)
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
2003-01-28 16:23:28 +01:00
|
|
|
lck_key.lck_long = 0;
|
|
|
|
lck_tail[0] = 0;
|
2001-12-24 03:51:06 +01:00
|
|
|
}
|
|
|
|
|
2003-01-28 16:23:28 +01:00
|
|
|
int lck_test_field;
|
2004-03-18 06:56:06 +01:00
|
|
|
Lock* lck_parent;
|
2004-05-05 07:28:48 +02:00
|
|
|
Lock* lck_next; /* lck_next and lck_prior form a doubly linked list of locks
|
2008-01-16 10:29:37 +01:00
|
|
|
bound to attachment */
|
2004-03-18 06:56:06 +01:00
|
|
|
Lock* lck_prior;
|
|
|
|
Lock* lck_collision; /* collisions in compatibility table */
|
|
|
|
Lock* lck_identical; /* identical locks in compatibility table */
|
2006-05-02 03:01:26 +02:00
|
|
|
Database* lck_dbb; /* database object is contained in */
|
2004-03-18 06:56:06 +01:00
|
|
|
blk* lck_object; /* argument to be passed to ast */
|
|
|
|
blk* lck_compatible; /* Enter into internal_enqueue() and treat as compatible */
|
|
|
|
blk* lck_compatible2; /* Sub-level for internal compatibility */
|
2006-05-02 03:01:26 +02:00
|
|
|
Attachment* lck_attachment; /* Attachment that owns lock, set only using set_lock_attachment */
|
2003-05-16 22:35:19 +02:00
|
|
|
lock_ast_t lck_ast; /* Blocking AST routine */
|
2001-12-24 03:51:06 +01:00
|
|
|
SLONG lck_id; /* Lock id from lock manager */
|
|
|
|
SLONG lck_owner_handle; /* Lock owner handle from the lock manager's point of view */
|
|
|
|
SSHORT lck_length; /* Length of lock string */
|
|
|
|
UCHAR lck_logical; /* Logical lock level */
|
|
|
|
UCHAR lck_physical; /* Physical lock level */
|
|
|
|
SLONG lck_data; /* Data associated with a lock */
|
2001-05-23 15:26:42 +02:00
|
|
|
enum lck_t lck_type;
|
|
|
|
union {
|
2006-05-02 03:01:26 +02:00
|
|
|
UCHAR lck_string[1];
|
2001-05-23 15:26:42 +02:00
|
|
|
SLONG lck_long;
|
|
|
|
} lck_key;
|
2006-05-02 03:01:26 +02:00
|
|
|
UCHAR lck_tail[1]; /* Makes the allocator happy */
|
2001-12-24 03:51:06 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-03-20 15:57:40 +01:00
|
|
|
} //namespace Jrd
|
|
|
|
|
2004-02-20 07:43:27 +01:00
|
|
|
#endif // JRD_LCK_H
|
|
|
|
|