~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-03-06 03:33:24 UTC
  • mfrom: (916.1.2 merge)
  • Revision ID: mordred@inaugust.com-20090306033324-dcedf80g9qzywbvu
Merged Brian's merge... re-rotate the tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/row0ins.h
 
1
/******************************************************
21
2
Insert into a table
22
3
 
 
4
(c) 1996 Innobase Oy
 
5
 
23
6
Created 4/20/1996 Heikki Tuuri
24
7
*******************************************************/
25
8
 
33
16
#include "trx0types.h"
34
17
#include "row0types.h"
35
18
 
36
 
/***************************************************************//**
 
19
/*******************************************************************
37
20
Checks if foreign key constraint fails for an index entry. Sets shared locks
38
21
which lock either the success or the failure of the constraint. NOTE that
39
 
the caller must have a shared latch on dict_foreign_key_check_lock.
40
 
@return DB_SUCCESS, DB_LOCK_WAIT, DB_NO_REFERENCED_ROW, or
41
 
DB_ROW_IS_REFERENCED */
 
22
the caller must have a shared latch on dict_foreign_key_check_lock. */
42
23
UNIV_INTERN
43
24
ulint
44
25
row_ins_check_foreign_constraint(
45
26
/*=============================*/
46
 
        ibool           check_ref,/*!< in: TRUE If we want to check that
 
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
47
31
                                the referenced table is ok, FALSE if we
48
 
                                want to check the foreign key table */
49
 
        dict_foreign_t* foreign,/*!< in: foreign constraint; NOTE that the
 
32
                                want to to check the foreign key table */
 
33
        dict_foreign_t* foreign,/* in: foreign constraint; NOTE that the
50
34
                                tables mentioned in it must be in the
51
35
                                dictionary cache if they exist at all */
52
 
        dict_table_t*   table,  /*!< in: if check_ref is TRUE, then the foreign
 
36
        dict_table_t*   table,  /* in: if check_ref is TRUE, then the foreign
53
37
                                table, else the referenced table */
54
 
        dtuple_t*       entry,  /*!< in: index entry for index */
55
 
        que_thr_t*      thr);   /*!< in: query thread */
56
 
/*********************************************************************//**
57
 
Creates an insert node struct.
58
 
@return own: insert node struct */
 
38
        dtuple_t*       entry,  /* in: index entry for index */
 
39
        que_thr_t*      thr);   /* in: query thread */
 
40
/*************************************************************************
 
41
Creates an insert node struct. */
59
42
UNIV_INTERN
60
43
ins_node_t*
61
44
ins_node_create(
62
45
/*============*/
63
 
        ulint           ins_type,       /*!< in: INS_VALUES, ... */
64
 
        dict_table_t*   table,          /*!< in: table where to insert */
65
 
        mem_heap_t*     heap);          /*!< in: mem heap where created */
66
 
/*********************************************************************//**
 
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
/*************************************************************************
67
51
Sets a new row to insert for an INS_DIRECT node. This function is only used
68
52
if we have constructed the row separately, which is a rare case; this
69
53
function is quite slow. */
71
55
void
72
56
ins_node_set_new_row(
73
57
/*=================*/
74
 
        ins_node_t*     node,   /*!< in: insert node */
75
 
        dtuple_t*       row);   /*!< in: new row (or first row) for the node */
76
 
/***************************************************************//**
 
58
        ins_node_t*     node,   /* in: insert node */
 
59
        dtuple_t*       row);   /* in: new row (or first row) for the node */
 
60
/*******************************************************************
77
61
Inserts an index entry to index. Tries first optimistic, then pessimistic
78
62
descent down the tree. If the entry matches enough to a delete marked record,
79
63
performs the insert by updating or delete unmarking the delete marked
80
 
record.
81
 
@return DB_SUCCESS, DB_LOCK_WAIT, DB_DUPLICATE_KEY, or some other error code */
 
64
record. */
82
65
UNIV_INTERN
83
66
ulint
84
67
row_ins_index_entry(
85
68
/*================*/
86
 
        dict_index_t*   index,  /*!< in: index */
87
 
        dtuple_t*       entry,  /*!< in: index entry to insert */
88
 
        ulint           n_ext,  /*!< in: number of externally stored columns */
89
 
        ibool           foreign,/*!< in: TRUE=check foreign key constraints */
90
 
        que_thr_t*      thr);   /*!< in: query thread */
91
 
/***********************************************************//**
 
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
/***************************************************************
92
77
Inserts a row to a table. This is a high-level function used in
93
 
SQL execution graphs.
94
 
@return query thread to run next or NULL */
 
78
SQL execution graphs. */
95
79
UNIV_INTERN
96
80
que_thr_t*
97
81
row_ins_step(
98
82
/*=========*/
99
 
        que_thr_t*      thr);   /*!< in: query thread */
100
 
/***********************************************************//**
 
83
                                /* out: query thread to run next or NULL */
 
84
        que_thr_t*      thr);   /* in: query thread */
 
85
/***************************************************************
101
86
Creates an entry template for each index of a table. */
102
87
UNIV_INTERN
103
88
void
104
89
ins_node_create_entry_list(
105
90
/*=======================*/
106
 
        ins_node_t*     node);  /*!< in: row insert node */
 
91
        ins_node_t*     node);  /* in: row insert node */
107
92
 
108
93
/* Insert node structure */
109
94
 
110
95
struct ins_node_struct{
111
 
        que_common_t    common; /*!< node type: QUE_NODE_INSERT */
 
96
        que_common_t    common; /* node type: QUE_NODE_INSERT */
112
97
        ulint           ins_type;/* INS_VALUES, INS_SEARCHED, or INS_DIRECT */
113
 
        dtuple_t*       row;    /*!< row to insert */
114
 
        dict_table_t*   table;  /*!< table where to insert */
115
 
        sel_node_t*     select; /*!< select in searched insert */
 
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 */
116
101
        que_node_t*     values_list;/* list of expressions to evaluate and
117
102
                                insert in an INS_VALUES insert */
118
 
        ulint           state;  /*!< node execution state */
119
 
        dict_index_t*   index;  /*!< NULL, or the next index where the index
 
103
        ulint           state;  /* node execution state */
 
104
        dict_index_t*   index;  /* NULL, or the next index where the index
120
105
                                entry should be inserted */
121
 
        dtuple_t*       entry;  /*!< NULL, or entry to insert in the index;
 
106
        dtuple_t*       entry;  /* NULL, or entry to insert in the index;
122
107
                                after a successful insert of the entry,
123
108
                                this should be reset to NULL */
124
109
        UT_LIST_BASE_NODE_T(dtuple_t)
125
110
                        entry_list;/* list of entries, one for each index */
126
111
        byte*           row_id_buf;/* buffer for the row id sys field in row */
127
 
        trx_id_t        trx_id; /*!< trx id or the last trx which executed the
 
112
        dulint          trx_id; /* trx id or the last trx which executed the
128
113
                                node */
129
114
        byte*           trx_id_buf;/* buffer for the trx id sys field in row */
130
115
        mem_heap_t*     entry_sys_heap;