~drizzle-trunk/drizzle/development

641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
1
/*****************************************************************************
2
3
Copyright (c) 1994, 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., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
16
17
*****************************************************************************/
18
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
19
/********************************************************************//**
20
@file include/data0data.h
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
21
SQL data field and tuple
22
23
Created 5/30/1994 Heikki Tuuri
24
*************************************************************************/
25
26
#ifndef data0data_h
27
#define data0data_h
28
29
#include "univ.i"
30
31
#include "data0types.h"
32
#include "data0type.h"
33
#include "mem0mem.h"
34
#include "dict0types.h"
35
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
36
/** Storage for overflow data in a big record, that is, a clustered
37
index record which needs external storage of data fields */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
38
typedef struct big_rec_struct		big_rec_t;
39
40
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
41
/*********************************************************************//**
42
Gets pointer to the type struct of SQL data field.
43
@return	pointer to the type struct */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
44
UNIV_INLINE
45
dtype_t*
46
dfield_get_type(
47
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
48
	const dfield_t*	field);	/*!< in: SQL data field */
49
/*********************************************************************//**
50
Gets pointer to the data in a field.
51
@return	pointer to data */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
52
UNIV_INLINE
53
void*
54
dfield_get_data(
55
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
56
	const dfield_t* field);	/*!< in: field */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
57
#else /* UNIV_DEBUG */
58
# define dfield_get_type(field) (&(field)->type)
59
# define dfield_get_data(field) ((field)->data)
60
#endif /* UNIV_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
61
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
62
Sets the type struct of SQL data field. */
63
UNIV_INLINE
64
void
65
dfield_set_type(
66
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
67
	dfield_t*	field,	/*!< in: SQL data field */
68
	dtype_t*	type);	/*!< in: pointer to data type struct */
69
/*********************************************************************//**
70
Gets length of field data.
71
@return	length of data; UNIV_SQL_NULL if SQL null data */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
72
UNIV_INLINE
73
ulint
74
dfield_get_len(
75
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
76
	const dfield_t* field);	/*!< in: field */
77
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
78
Sets length in a field. */
79
UNIV_INLINE
80
void
81
dfield_set_len(
82
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
83
	dfield_t*	field,	/*!< in: field */
84
	ulint		len);	/*!< in: length or UNIV_SQL_NULL */
85
/*********************************************************************//**
86
Determines if a field is SQL NULL
87
@return	nonzero if SQL null data */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
88
UNIV_INLINE
89
ulint
90
dfield_is_null(
91
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
92
	const dfield_t* field);	/*!< in: field */
93
/*********************************************************************//**
94
Determines if a field is externally stored
95
@return	nonzero if externally stored */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
96
UNIV_INLINE
97
ulint
98
dfield_is_ext(
99
/*==========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
100
	const dfield_t* field);	/*!< in: field */
101
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
102
Sets the "external storage" flag */
103
UNIV_INLINE
104
void
105
dfield_set_ext(
106
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
107
	dfield_t*	field);	/*!< in/out: field */
108
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
109
Sets pointer to the data and length in a field. */
110
UNIV_INLINE
111
void
112
dfield_set_data(
113
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
114
	dfield_t*	field,	/*!< in: field */
115
	const void*	data,	/*!< in: data */
116
	ulint		len);	/*!< in: length or UNIV_SQL_NULL */
117
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
118
Sets a data field to SQL NULL. */
119
UNIV_INLINE
120
void
121
dfield_set_null(
122
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
123
	dfield_t*	field);	/*!< in/out: field */
124
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
125
Writes an SQL null field full of zeros. */
126
UNIV_INLINE
127
void
128
data_write_sql_null(
129
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
130
	byte*	data,	/*!< in: pointer to a buffer of size len */
131
	ulint	len);	/*!< in: SQL null size in bytes */
132
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
133
Copies the data and len fields. */
134
UNIV_INLINE
135
void
136
dfield_copy_data(
137
/*=============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
138
	dfield_t*	field1,	/*!< out: field to copy to */
139
	const dfield_t*	field2);/*!< in: field to copy from */
140
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
141
Copies a data field to another. */
142
UNIV_INLINE
143
void
144
dfield_copy(
145
/*========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
146
	dfield_t*	field1,	/*!< out: field to copy to */
147
	const dfield_t*	field2);/*!< in: field to copy from */
148
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
149
Copies the data pointed to by a data field. */
150
UNIV_INLINE
151
void
152
dfield_dup(
153
/*=======*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
154
	dfield_t*	field,	/*!< in/out: data field */
155
	mem_heap_t*	heap);	/*!< in: memory heap where allocated */
156
/*********************************************************************//**
157
Tests if data length and content is equal for two dfields.
158
@return	TRUE if equal */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
159
UNIV_INLINE
160
ibool
161
dfield_datas_are_binary_equal(
162
/*==========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
163
	const dfield_t*	field1,	/*!< in: field */
164
	const dfield_t*	field2);/*!< in: field */
165
/*********************************************************************//**
166
Tests if dfield data length and content is equal to the given.
167
@return	TRUE if equal */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
168
UNIV_INTERN
169
ibool
170
dfield_data_is_binary_equal(
171
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
172
	const dfield_t*	field,	/*!< in: field */
173
	ulint		len,	/*!< in: data length or UNIV_SQL_NULL */
174
	const byte*	data);	/*!< in: data */
175
/*********************************************************************//**
176
Gets number of fields in a data tuple.
177
@return	number of fields */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
178
UNIV_INLINE
179
ulint
180
dtuple_get_n_fields(
181
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
182
	const dtuple_t*	tuple);	/*!< in: tuple */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
183
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
184
/*********************************************************************//**
185
Gets nth field of a tuple.
186
@return	nth field */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
187
UNIV_INLINE
188
dfield_t*
189
dtuple_get_nth_field(
190
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
191
	const dtuple_t*	tuple,	/*!< in: tuple */
192
	ulint		n);	/*!< in: index of field */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
193
#else /* UNIV_DEBUG */
194
# define dtuple_get_nth_field(tuple, n) ((tuple)->fields + (n))
195
#endif /* UNIV_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
196
/*********************************************************************//**
197
Gets info bits in a data tuple.
198
@return	info bits */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
199
UNIV_INLINE
200
ulint
201
dtuple_get_info_bits(
202
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
203
	const dtuple_t*	tuple);	/*!< in: tuple */
204
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
205
Sets info bits in a data tuple. */
206
UNIV_INLINE
207
void
208
dtuple_set_info_bits(
209
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
210
	dtuple_t*	tuple,		/*!< in: tuple */
211
	ulint		info_bits);	/*!< in: info bits */
212
/*********************************************************************//**
213
Gets number of fields used in record comparisons.
214
@return	number of fields used in comparisons in rem0cmp.* */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
215
UNIV_INLINE
216
ulint
217
dtuple_get_n_fields_cmp(
218
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
219
	const dtuple_t*	tuple);	/*!< in: tuple */
220
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
221
Gets number of fields used in record comparisons. */
222
UNIV_INLINE
223
void
224
dtuple_set_n_fields_cmp(
225
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
226
	dtuple_t*	tuple,		/*!< in: tuple */
227
	ulint		n_fields_cmp);	/*!< in: number of fields used in
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
228
					comparisons in rem0cmp.* */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
229
/**********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
230
Creates a data tuple to a memory heap. The default value for number
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
231
of fields used in record comparisons for this tuple is n_fields.
232
@return	own: created tuple */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
233
UNIV_INLINE
234
dtuple_t*
235
dtuple_create(
236
/*==========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
237
	mem_heap_t*	heap,	/*!< in: memory heap where the tuple
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
238
				is created */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
239
	ulint		n_fields); /*!< in: number of fields */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
240
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
241
/**********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
242
Wrap data fields in a tuple. The default value for number
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
243
of fields used in record comparisons for this tuple is n_fields.
244
@return	data tuple */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
245
UNIV_INLINE
246
const dtuple_t*
247
dtuple_from_fields(
248
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
249
	dtuple_t*	tuple,		/*!< in: storage for data tuple */
250
	const dfield_t*	fields,		/*!< in: fields */
251
	ulint		n_fields);	/*!< in: number of fields */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
252
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
253
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
254
Sets number of fields used in a tuple. Normally this is set in
255
dtuple_create, but if you want later to set it smaller, you can use this. */
256
UNIV_INTERN
257
void
258
dtuple_set_n_fields(
259
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
260
	dtuple_t*	tuple,		/*!< in: tuple */
261
	ulint		n_fields);	/*!< in: number of fields */
262
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
263
Copies a data tuple to another.  This is a shallow copy; if a deep copy
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
264
is desired, dfield_dup() will have to be invoked on each field.
265
@return	own: copy of tuple */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
266
UNIV_INLINE
267
dtuple_t*
268
dtuple_copy(
269
/*========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
270
	const dtuple_t*	tuple,	/*!< in: tuple to copy from */
271
	mem_heap_t*	heap);	/*!< in: memory heap
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
272
				where the tuple is created */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
273
/**********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
274
The following function returns the sum of data lengths of a tuple. The space
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
275
occupied by the field structs or the tuple struct is not counted.
276
@return	sum of data lens */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
277
UNIV_INLINE
278
ulint
279
dtuple_get_data_size(
280
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
281
	const dtuple_t*	tuple,	/*!< in: typed data tuple */
282
	ulint		comp);	/*!< in: nonzero=ROW_FORMAT=COMPACT  */
283
/*********************************************************************//**
284
Computes the number of externally stored fields in a data tuple.
285
@return	number of fields */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
286
UNIV_INLINE
287
ulint
288
dtuple_get_n_ext(
289
/*=============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
290
	const dtuple_t*	tuple);	/*!< in: tuple */
291
/************************************************************//**
292
Compare two data tuples, respecting the collation of character fields.
293
@return 1, 0 , -1 if tuple1 is greater, equal, less, respectively,
294
than tuple2 */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
295
UNIV_INTERN
296
int
297
dtuple_coll_cmp(
298
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
299
	const dtuple_t*	tuple1,	/*!< in: tuple 1 */
300
	const dtuple_t*	tuple2);/*!< in: tuple 2 */
301
/************************************************************//**
302
Folds a prefix given as the number of fields of a tuple.
303
@return	the folded value */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
304
UNIV_INLINE
305
ulint
306
dtuple_fold(
307
/*========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
308
	const dtuple_t*	tuple,	/*!< in: the tuple */
309
	ulint		n_fields,/*!< in: number of complete fields to fold */
310
	ulint		n_bytes,/*!< in: number of bytes to fold in an
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
311
				incomplete last field */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
312
	dulint		tree_id)/*!< in: index tree id */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
313
	__attribute__((pure));
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
314
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
315
Sets types of fields binary in a tuple. */
316
UNIV_INLINE
317
void
318
dtuple_set_types_binary(
319
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
320
	dtuple_t*	tuple,	/*!< in: data tuple */
321
	ulint		n);	/*!< in: number of fields to set */
322
/**********************************************************************//**
323
Checks if a dtuple contains an SQL null value.
324
@return	TRUE if some field is SQL null */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
325
UNIV_INLINE
326
ibool
327
dtuple_contains_null(
328
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
329
	const dtuple_t*	tuple);	/*!< in: dtuple */
330
/**********************************************************//**
331
Checks that a data field is typed. Asserts an error if not.
332
@return	TRUE if ok */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
333
UNIV_INTERN
334
ibool
335
dfield_check_typed(
336
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
337
	const dfield_t*	field);	/*!< in: data field */
338
/**********************************************************//**
339
Checks that a data tuple is typed. Asserts an error if not.
340
@return	TRUE if ok */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
341
UNIV_INTERN
342
ibool
343
dtuple_check_typed(
344
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
345
	const dtuple_t*	tuple);	/*!< in: tuple */
346
/**********************************************************//**
347
Checks that a data tuple is typed.
348
@return	TRUE if ok */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
349
UNIV_INTERN
350
ibool
351
dtuple_check_typed_no_assert(
352
/*=========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
353
	const dtuple_t*	tuple);	/*!< in: tuple */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
354
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
355
/**********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
356
Validates the consistency of a tuple which must be complete, i.e,
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
357
all fields must have been set.
358
@return	TRUE if ok */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
359
UNIV_INTERN
360
ibool
361
dtuple_validate(
362
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
363
	const dtuple_t*	tuple);	/*!< in: tuple */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
364
#endif /* UNIV_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
365
/*************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
366
Pretty prints a dfield value according to its data type. */
367
UNIV_INTERN
368
void
369
dfield_print(
370
/*=========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
371
	const dfield_t*	dfield);/*!< in: dfield */
372
/*************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
373
Pretty prints a dfield value according to its data type. Also the hex string
374
is printed if a string contains non-printable characters. */
375
UNIV_INTERN
376
void
377
dfield_print_also_hex(
378
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
379
	const dfield_t*	dfield);	 /*!< in: dfield */
380
/**********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
381
The following function prints the contents of a tuple. */
382
UNIV_INTERN
383
void
384
dtuple_print(
385
/*=========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
386
	FILE*		f,	/*!< in: output stream */
387
	const dtuple_t*	tuple);	/*!< in: tuple */
388
/**************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
389
Moves parts of long fields in entry to the big record vector so that
390
the size of tuple drops below the maximum record size allowed in the
391
database. Moves data only from those fields which are not necessary
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
392
to determine uniquely the insertion place of the tuple in the index.
393
@return own: created big record vector, NULL if we are not able to
394
shorten the entry enough, i.e., if there are too many fixed-length or
395
short fields in entry or the index is clustered */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
396
UNIV_INTERN
397
big_rec_t*
398
dtuple_convert_big_rec(
399
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
400
	dict_index_t*	index,	/*!< in: index */
401
	dtuple_t*	entry,	/*!< in/out: index entry */
402
	ulint*		n_ext);	/*!< in/out: number of
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
403
				externally stored columns */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
404
/**************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
405
Puts back to entry the data stored in vector. Note that to ensure the
406
fields in entry can accommodate the data, vector must have been created
407
from entry with dtuple_convert_big_rec. */
408
UNIV_INTERN
409
void
410
dtuple_convert_back_big_rec(
411
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
412
	dict_index_t*	index,	/*!< in: index */
413
	dtuple_t*	entry,	/*!< in: entry whose data was put to vector */
414
	big_rec_t*	vector);/*!< in, own: big rec vector; it is
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
415
				freed in this function */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
416
/**************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
417
Frees the memory in a big rec vector. */
418
UNIV_INLINE
419
void
420
dtuple_big_rec_free(
421
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
422
	big_rec_t*	vector);	/*!< in, own: big rec vector; it is
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
423
				freed in this function */
424
425
/*######################################################################*/
426
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
427
/** Structure for an SQL data field */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
428
struct dfield_struct{
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
429
	void*		data;	/*!< pointer to data */
430
	unsigned	ext:1;	/*!< TRUE=externally stored, FALSE=local */
431
	unsigned	len:32;	/*!< data length; UNIV_SQL_NULL if SQL null */
432
	dtype_t		type;	/*!< type of data */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
433
};
434
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
435
/** Structure for an SQL data tuple of fields (logical record) */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
436
struct dtuple_struct {
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
437
	ulint		info_bits;	/*!< info bits of an index record:
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
438
					the default is 0; this field is used
439
					if an index record is built from
440
					a data tuple */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
441
	ulint		n_fields;	/*!< number of fields in dtuple */
442
	ulint		n_fields_cmp;	/*!< number of fields which should
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
443
					be used in comparison services
444
					of rem0cmp.*; the index search
445
					is performed by comparing only these
446
					fields, others are ignored; the
447
					default value in dtuple creation is
448
					the same value as n_fields */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
449
	dfield_t*	fields;		/*!< fields */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
450
	UT_LIST_NODE_T(dtuple_t) tuple_list;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
451
					/*!< data tuples can be linked into a
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
452
					list using this field */
453
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
454
	ulint		magic_n;	/*!< magic number, used in
455
					debug assertions */
456
/** Value of dtuple_struct::magic_n */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
457
# define		DATA_TUPLE_MAGIC_N	65478679
458
#endif /* UNIV_DEBUG */
459
};
460
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
461
/** A slot for a field in a big rec vector */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
462
typedef struct big_rec_field_struct	big_rec_field_t;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
463
/** A slot for a field in a big rec vector */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
464
struct big_rec_field_struct {
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
465
	ulint		field_no;	/*!< field number in record */
466
	ulint		len;		/*!< stored data length, in bytes */
467
	const void*	data;		/*!< stored data */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
468
};
469
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
470
/** Storage format for overflow data in a big record, that is, a
471
clustered index record which needs external storage of data fields */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
472
struct big_rec_struct {
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
473
	mem_heap_t*	heap;		/*!< memory heap from which
474
					allocated */
475
	ulint		n_fields;	/*!< number of stored fields */
476
	big_rec_field_t*fields;		/*!< stored fields */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
477
};
478
479
#ifndef UNIV_NONINL
480
#include "data0data.ic"
481
#endif
482
483
#endif