~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/row0ins.h

  • Committer: Elan Ruusamäe
  • Date: 2008-12-04 19:38:26 UTC
  • mfrom: (644 drizzle)
  • mto: (641.3.10 devel)
  • mto: This revision was merged to the branch mainline in revision 649.
  • Revision ID: glen@haarber.alkohol.ee-20081204193826-xxyhd45ag121pf3z
- pull from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/******************************************************
2
 
Insert into a table
3
 
 
4
 
(c) 1996 Innobase Oy
5
 
 
6
 
Created 4/20/1996 Heikki Tuuri
7
 
*******************************************************/
8
 
 
9
 
#ifndef row0ins_h
10
 
#define row0ins_h
11
 
 
12
 
#include "univ.i"
13
 
#include "data0data.h"
14
 
#include "que0types.h"
15
 
#include "dict0types.h"
16
 
#include "trx0types.h"
17
 
#include "row0types.h"
18
 
 
19
 
/*******************************************************************
20
 
Checks if foreign key constraint fails for an index entry. Sets shared locks
21
 
which lock either the success or the failure of the constraint. NOTE that
22
 
the caller must have a shared latch on dict_foreign_key_check_lock. */
23
 
UNIV_INTERN
24
 
ulint
25
 
row_ins_check_foreign_constraint(
26
 
/*=============================*/
27
 
                                /* out: DB_SUCCESS, DB_LOCK_WAIT,
28
 
                                DB_NO_REFERENCED_ROW,
29
 
                                or DB_ROW_IS_REFERENCED */
30
 
        ibool           check_ref,/* in: TRUE If we want to check that
31
 
                                the referenced table is ok, FALSE if we
32
 
                                want to to check the foreign key table */
33
 
        dict_foreign_t* foreign,/* in: foreign constraint; NOTE that the
34
 
                                tables mentioned in it must be in the
35
 
                                dictionary cache if they exist at all */
36
 
        dict_table_t*   table,  /* in: if check_ref is TRUE, then the foreign
37
 
                                table, else the referenced table */
38
 
        dtuple_t*       entry,  /* in: index entry for index */
39
 
        que_thr_t*      thr);   /* in: query thread */
40
 
/*************************************************************************
41
 
Creates an insert node struct. */
42
 
UNIV_INTERN
43
 
ins_node_t*
44
 
ins_node_create(
45
 
/*============*/
46
 
                                        /* out, own: insert node struct */
47
 
        ulint           ins_type,       /* in: INS_VALUES, ... */
48
 
        dict_table_t*   table,          /* in: table where to insert */
49
 
        mem_heap_t*     heap);          /* in: mem heap where created */
50
 
/*************************************************************************
51
 
Sets a new row to insert for an INS_DIRECT node. This function is only used
52
 
if we have constructed the row separately, which is a rare case; this
53
 
function is quite slow. */
54
 
UNIV_INTERN
55
 
void
56
 
ins_node_set_new_row(
57
 
/*=================*/
58
 
        ins_node_t*     node,   /* in: insert node */
59
 
        dtuple_t*       row);   /* in: new row (or first row) for the node */
60
 
/*******************************************************************
61
 
Inserts an index entry to index. Tries first optimistic, then pessimistic
62
 
descent down the tree. If the entry matches enough to a delete marked record,
63
 
performs the insert by updating or delete unmarking the delete marked
64
 
record. */
65
 
UNIV_INTERN
66
 
ulint
67
 
row_ins_index_entry(
68
 
/*================*/
69
 
                                /* out: DB_SUCCESS, DB_LOCK_WAIT,
70
 
                                DB_DUPLICATE_KEY, or some other error code */
71
 
        dict_index_t*   index,  /* in: index */
72
 
        dtuple_t*       entry,  /* in: index entry to insert */
73
 
        ulint           n_ext,  /* in: number of externally stored columns */
74
 
        ibool           foreign,/* in: TRUE=check foreign key constraints */
75
 
        que_thr_t*      thr);   /* in: query thread */
76
 
/***************************************************************
77
 
Inserts a row to a table. This is a high-level function used in
78
 
SQL execution graphs. */
79
 
UNIV_INTERN
80
 
que_thr_t*
81
 
row_ins_step(
82
 
/*=========*/
83
 
                                /* out: query thread to run next or NULL */
84
 
        que_thr_t*      thr);   /* in: query thread */
85
 
/***************************************************************
86
 
Creates an entry template for each index of a table. */
87
 
UNIV_INTERN
88
 
void
89
 
ins_node_create_entry_list(
90
 
/*=======================*/
91
 
        ins_node_t*     node);  /* in: row insert node */
92
 
 
93
 
/* Insert node structure */
94
 
 
95
 
struct ins_node_struct{
96
 
        que_common_t    common; /* node type: QUE_NODE_INSERT */
97
 
        ulint           ins_type;/* INS_VALUES, INS_SEARCHED, or INS_DIRECT */
98
 
        dtuple_t*       row;    /* row to insert */
99
 
        dict_table_t*   table;  /* table where to insert */
100
 
        sel_node_t*     select; /* select in searched insert */
101
 
        que_node_t*     values_list;/* list of expressions to evaluate and
102
 
                                insert in an INS_VALUES insert */
103
 
        ulint           state;  /* node execution state */
104
 
        dict_index_t*   index;  /* NULL, or the next index where the index
105
 
                                entry should be inserted */
106
 
        dtuple_t*       entry;  /* NULL, or entry to insert in the index;
107
 
                                after a successful insert of the entry,
108
 
                                this should be reset to NULL */
109
 
        UT_LIST_BASE_NODE_T(dtuple_t)
110
 
                        entry_list;/* list of entries, one for each index */
111
 
        byte*           row_id_buf;/* buffer for the row id sys field in row */
112
 
        dulint          trx_id; /* trx id or the last trx which executed the
113
 
                                node */
114
 
        byte*           trx_id_buf;/* buffer for the trx id sys field in row */
115
 
        mem_heap_t*     entry_sys_heap;
116
 
                                /* memory heap used as auxiliary storage;
117
 
                                entry_list and sys fields are stored here;
118
 
                                if this is NULL, entry list should be created
119
 
                                and buffers for sys fields in row allocated */
120
 
        ulint           magic_n;
121
 
};
122
 
 
123
 
#define INS_NODE_MAGIC_N        15849075
124
 
 
125
 
/* Insert node types */
126
 
#define INS_SEARCHED    0       /* INSERT INTO ... SELECT ... */
127
 
#define INS_VALUES      1       /* INSERT INTO ... VALUES ... */
128
 
#define INS_DIRECT      2       /* this is for internal use in dict0crea:
129
 
                                insert the row directly */
130
 
 
131
 
/* Node execution states */
132
 
#define INS_NODE_SET_IX_LOCK    1       /* we should set an IX lock on table */
133
 
#define INS_NODE_ALLOC_ROW_ID   2       /* row id should be allocated */
134
 
#define INS_NODE_INSERT_ENTRIES 3       /* index entries should be built and
135
 
                                        inserted */
136
 
 
137
 
#ifndef UNIV_NONINL
138
 
#include "row0ins.ic"
139
 
#endif
140
 
 
141
 
#endif