~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/******************************************************
2
 
Index build routines using a merge sort
3
 
 
4
 
(c) 2005 Innobase Oy
5
 
 
6
 
Created 13/06/2005 Jan Lindstrom
7
 
*******************************************************/
8
 
 
9
 
#ifndef row0merge_h
10
 
#define row0merge_h
11
 
 
12
 
#include "univ.i"
13
 
#include "data0data.h"
14
 
#include "dict0types.h"
15
 
#include "trx0types.h"
16
 
#include "que0types.h"
17
 
#include "mtr0mtr.h"
18
 
#include "rem0types.h"
19
 
#include "rem0rec.h"
20
 
#include "read0types.h"
21
 
#include "btr0types.h"
22
 
#include "row0mysql.h"
23
 
#include "lock0types.h"
24
 
 
25
 
/* This structure holds index field definitions */
26
 
 
27
 
struct merge_index_field_struct {
28
 
        ulint           prefix_len;     /* Prefix len */
29
 
        const char*     field_name;     /* Field name */
30
 
};
31
 
 
32
 
typedef struct merge_index_field_struct merge_index_field_t;
33
 
 
34
 
/* This structure holds index definitions */
35
 
 
36
 
struct merge_index_def_struct {
37
 
        const char*             name;           /* Index name */
38
 
        ulint                   ind_type;       /* 0, DICT_UNIQUE,
39
 
                                                or DICT_CLUSTERED */
40
 
        ulint                   n_fields;       /* Number of fields in index */
41
 
        merge_index_field_t*    fields;         /* Field definitions */
42
 
};
43
 
 
44
 
typedef struct merge_index_def_struct merge_index_def_t;
45
 
 
46
 
/*************************************************************************
47
 
Sets an exclusive lock on a table, for the duration of creating indexes. */
48
 
UNIV_INTERN
49
 
ulint
50
 
row_merge_lock_table(
51
 
/*=================*/
52
 
                                        /* out: error code or DB_SUCCESS */
53
 
        trx_t*          trx,            /* in/out: transaction */
54
 
        dict_table_t*   table,          /* in: table to lock */
55
 
        enum lock_mode  mode);          /* in: LOCK_X or LOCK_S */
56
 
/*************************************************************************
57
 
Drop an index from the InnoDB system tables. */
58
 
UNIV_INTERN
59
 
void
60
 
row_merge_drop_index(
61
 
/*=================*/
62
 
        dict_index_t*   index,  /* in: index to be removed */
63
 
        dict_table_t*   table,  /* in: table */
64
 
        trx_t*          trx);   /* in: transaction handle */
65
 
/*************************************************************************
66
 
Drop those indexes which were created before an error occurred
67
 
when building an index. */
68
 
UNIV_INTERN
69
 
void
70
 
row_merge_drop_indexes(
71
 
/*===================*/
72
 
        trx_t*          trx,            /* in: transaction */
73
 
        dict_table_t*   table,          /* in: table containing the indexes */
74
 
        dict_index_t**  index,          /* in: indexes to drop */
75
 
        ulint           num_created);   /* in: number of elements in index[] */
76
 
/*************************************************************************
77
 
Drop all partially created indexes during crash recovery. */
78
 
UNIV_INTERN
79
 
void
80
 
row_merge_drop_temp_indexes(void);
81
 
/*=============================*/
82
 
/*************************************************************************
83
 
Rename the tables in the data dictionary. */
84
 
UNIV_INTERN
85
 
ulint
86
 
row_merge_rename_tables(
87
 
/*====================*/
88
 
                                        /* out: error code or DB_SUCCESS */
89
 
        dict_table_t*   old_table,      /* in/out: old table, renamed to
90
 
                                        tmp_name */
91
 
        dict_table_t*   new_table,      /* in/out: new table, renamed to
92
 
                                        old_table->name */
93
 
        const char*     tmp_name,       /* in: new name for old_table */
94
 
        trx_t*          trx);           /* in: transaction handle */
95
 
 
96
 
/*************************************************************************
97
 
Create a temporary table for creating a primary key, using the definition
98
 
of an existing table. */
99
 
UNIV_INTERN
100
 
dict_table_t*
101
 
row_merge_create_temporary_table(
102
 
/*=============================*/
103
 
                                                /* out: table,
104
 
                                                or NULL on error */
105
 
        const char*             table_name,     /* in: new table name */
106
 
        const merge_index_def_t*index_def,      /* in: the index definition
107
 
                                                of the primary key */
108
 
        const dict_table_t*     table,          /* in: old table definition */
109
 
        trx_t*                  trx);           /* in/out: transaction
110
 
                                                (sets error_state) */
111
 
/*************************************************************************
112
 
Rename the temporary indexes in the dictionary to permanent ones. */
113
 
UNIV_INTERN
114
 
ulint
115
 
row_merge_rename_indexes(
116
 
/*=====================*/
117
 
                                        /* out: DB_SUCCESS if all OK */
118
 
        trx_t*          trx,            /* in/out: transaction */
119
 
        dict_table_t*   table);         /* in/out: table with new indexes */
120
 
/*************************************************************************
121
 
Create the index and load in to the dictionary. */
122
 
UNIV_INTERN
123
 
dict_index_t*
124
 
row_merge_create_index(
125
 
/*===================*/
126
 
                                        /* out: index, or NULL on error */
127
 
        trx_t*          trx,            /* in/out: trx (sets error_state) */
128
 
        dict_table_t*   table,          /* in: the index is on this table */
129
 
        const merge_index_def_t*        /* in: the index definition */
130
 
                        index_def);
131
 
#ifdef ROW_MERGE_IS_INDEX_USABLE
132
 
/*************************************************************************
133
 
Check if a transaction can use an index. */
134
 
UNIV_INTERN
135
 
ibool
136
 
row_merge_is_index_usable(
137
 
/*======================*/
138
 
                                        /* out: TRUE if index can be used by
139
 
                                        the transaction else FALSE*/
140
 
        const trx_t*            trx,    /* in: transaction */
141
 
        const dict_index_t*     index); /* in: index to check */
142
 
#endif /* ROW_MERGE_IS_INDEX_USABLE */
143
 
/*************************************************************************
144
 
If there are views that refer to the old table name then we "attach" to
145
 
the new instance of the table else we drop it immediately. */
146
 
UNIV_INTERN
147
 
ulint
148
 
row_merge_drop_table(
149
 
/*=================*/
150
 
                                        /* out: DB_SUCCESS or error code */
151
 
        trx_t*          trx,            /* in: transaction */
152
 
        dict_table_t*   table);         /* in: table instance to drop */
153
 
 
154
 
/*************************************************************************
155
 
Build indexes on a table by reading a clustered index,
156
 
creating a temporary file containing index entries, merge sorting
157
 
these index entries and inserting sorted index entries to indexes. */
158
 
UNIV_INTERN
159
 
ulint
160
 
row_merge_build_indexes(
161
 
/*====================*/
162
 
                                        /* out: DB_SUCCESS or error code */
163
 
        trx_t*          trx,            /* in: transaction */
164
 
        dict_table_t*   old_table,      /* in: table where rows are
165
 
                                        read from */
166
 
        dict_table_t*   new_table,      /* in: table where indexes are
167
 
                                        created; identical to old_table
168
 
                                        unless creating a PRIMARY KEY */
169
 
        dict_index_t**  indexes,        /* in: indexes to be created */
170
 
        ulint           n_indexes,      /* in: size of indexes[] */
171
 
        TABLE*          table);         /* in/out: MySQL table, for
172
 
                                        reporting erroneous key value
173
 
                                        if applicable */
174
 
#endif /* row0merge.h */