~drizzle-trunk/drizzle/development

641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
1
/*****************************************************************************
2
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
3
Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
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
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
16
17
*****************************************************************************/
18
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
19
/**************************************************//**
20
@file include/row0ins.h
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
21
Insert into a table
22
23
Created 4/20/1996 Heikki Tuuri
24
*******************************************************/
25
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
26
#pragma once
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
27
#ifndef row0ins_h
28
#define row0ins_h
29
30
#include "univ.i"
31
#include "data0data.h"
32
#include "que0types.h"
33
#include "dict0types.h"
34
#include "trx0types.h"
35
#include "row0types.h"
36
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
37
/***************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
38
Checks if foreign key constraint fails for an index entry. Sets shared locks
39
which lock either the success or the failure of the constraint. NOTE that
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
40
the caller must have a shared latch on dict_foreign_key_check_lock.
41
@return DB_SUCCESS, DB_LOCK_WAIT, DB_NO_REFERENCED_ROW, or
42
DB_ROW_IS_REFERENCED */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
43
UNIV_INTERN
44
ulint
45
row_ins_check_foreign_constraint(
46
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
47
	ibool		check_ref,/*!< in: TRUE If we want to check that
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
48
				the referenced table is ok, FALSE if we
1819.5.85 by stewart at flamingspork
[patch 085/129] Merge patch for revision 1884 from InnoDB SVN:
49
				want to check the foreign key table */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
50
	dict_foreign_t*	foreign,/*!< in: foreign constraint; NOTE that the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
51
				tables mentioned in it must be in the
52
				dictionary cache if they exist at all */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
53
	dict_table_t*	table,	/*!< in: if check_ref is TRUE, then the foreign
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
54
				table, else the referenced table */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
55
	dtuple_t*	entry,	/*!< in: index entry for index */
56
	que_thr_t*	thr);	/*!< in: query thread */
57
/*********************************************************************//**
58
Creates an insert node struct.
59
@return	own: insert node struct */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
60
UNIV_INTERN
61
ins_node_t*
62
ins_node_create(
63
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
64
	ulint		ins_type,	/*!< in: INS_VALUES, ... */
65
	dict_table_t*	table,		/*!< in: table where to insert */
66
	mem_heap_t*	heap);		/*!< in: mem heap where created */
67
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
68
Sets a new row to insert for an INS_DIRECT node. This function is only used
69
if we have constructed the row separately, which is a rare case; this
70
function is quite slow. */
71
UNIV_INTERN
72
void
73
ins_node_set_new_row(
74
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
75
	ins_node_t*	node,	/*!< in: insert node */
76
	dtuple_t*	row);	/*!< in: new row (or first row) for the node */
77
/***************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
78
Inserts an index entry to index. Tries first optimistic, then pessimistic
79
descent down the tree. If the entry matches enough to a delete marked record,
80
performs the insert by updating or delete unmarking the delete marked
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
81
record.
82
@return	DB_SUCCESS, DB_LOCK_WAIT, DB_DUPLICATE_KEY, or some other error code */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
83
UNIV_INTERN
84
ulint
85
row_ins_index_entry(
86
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
87
	dict_index_t*	index,	/*!< in: index */
1819.9.197 by Marko Mäkelä, Stewart Smith
Merge Revision revid:marko.makela@oracle.com-20101103091611-a3x9p0yivkvu5u9i from MySQL InnoDB
88
	dtuple_t*	entry,	/*!< in/out: index entry to insert */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
89
	ulint		n_ext,	/*!< in: number of externally stored columns */
1819.9.201 by Marko Mäkelä
Merge Revision revid:marko.makela@oracle.com-20101104131215-pfxnpidlrzd4krg0 from MySQL InnoDB
90
	ibool		foreign,/*!< in: TRUE=check foreign key constraints
91
				(foreign=FALSE only during CREATE INDEX) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
92
	que_thr_t*	thr);	/*!< in: query thread */
93
/***********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
94
Inserts a row to a table. This is a high-level function used in
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
95
SQL execution graphs.
96
@return	query thread to run next or NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
97
UNIV_INTERN
98
que_thr_t*
99
row_ins_step(
100
/*=========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
101
	que_thr_t*	thr);	/*!< in: query thread */
102
/***********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
103
Creates an entry template for each index of a table. */
104
UNIV_INTERN
105
void
106
ins_node_create_entry_list(
107
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
108
	ins_node_t*	node);	/*!< in: row insert node */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
109
110
/* Insert node structure */
111
112
struct ins_node_struct{
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
113
	que_common_t	common;	/*!< node type: QUE_NODE_INSERT */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
114
	ulint		ins_type;/* INS_VALUES, INS_SEARCHED, or INS_DIRECT */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
115
	dtuple_t*	row;	/*!< row to insert */
116
	dict_table_t*	table;	/*!< table where to insert */
117
	sel_node_t*	select;	/*!< select in searched insert */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
118
	que_node_t*	values_list;/* list of expressions to evaluate and
119
				insert in an INS_VALUES insert */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
120
	ulint		state;	/*!< node execution state */
121
	dict_index_t*	index;	/*!< NULL, or the next index where the index
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
122
				entry should be inserted */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
123
	dtuple_t*	entry;	/*!< NULL, or entry to insert in the index;
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
124
				after a successful insert of the entry,
125
				this should be reset to NULL */
126
	UT_LIST_BASE_NODE_T(dtuple_t)
127
			entry_list;/* list of entries, one for each index */
128
	byte*		row_id_buf;/* buffer for the row id sys field in row */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
129
	trx_id_t	trx_id;	/*!< trx id or the last trx which executed the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
130
				node */
131
	byte*		trx_id_buf;/* buffer for the trx id sys field in row */
132
	mem_heap_t*	entry_sys_heap;
133
				/* memory heap used as auxiliary storage;
134
				entry_list and sys fields are stored here;
135
				if this is NULL, entry list should be created
136
				and buffers for sys fields in row allocated */
137
	ulint		magic_n;
138
};
139
140
#define	INS_NODE_MAGIC_N	15849075
141
142
/* Insert node types */
143
#define INS_SEARCHED	0	/* INSERT INTO ... SELECT ... */
144
#define INS_VALUES	1	/* INSERT INTO ... VALUES ... */
145
#define INS_DIRECT	2	/* this is for internal use in dict0crea:
146
				insert the row directly */
147
148
/* Node execution states */
149
#define	INS_NODE_SET_IX_LOCK	1	/* we should set an IX lock on table */
150
#define INS_NODE_ALLOC_ROW_ID	2	/* row id should be allocated */
151
#define	INS_NODE_INSERT_ENTRIES 3	/* index entries should be built and
152
					inserted */
153
154
#ifndef UNIV_NONINL
155
#include "row0ins.ic"
156
#endif
157
158
#endif