~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-08-12 06:25:19 UTC
  • mto: (1114.1.1 innodb-plugin-merge)
  • mto: This revision was merged to the branch mainline in revision 1183.
  • Revision ID: mordred@inaugust.com-20090812062519-cij02mrrunvnxblt
Tags: innodb-plugin-1.0.4
InnoDB Plugin 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/******************************************************
 
19
/**************************************************//**
 
20
@file include/row0merge.h
20
21
Index build routines using a merge sort
21
22
 
22
23
Created 13/06/2005 Jan Lindstrom
38
39
#include "row0mysql.h"
39
40
#include "lock0types.h"
40
41
 
41
 
/* This structure holds index field definitions */
42
 
 
 
42
/** Index field definition */
43
43
struct merge_index_field_struct {
44
 
        ulint           prefix_len;     /* Prefix len */
45
 
        const char*     field_name;     /* Field name */
 
44
        ulint           prefix_len;     /*!< column prefix length, or 0
 
45
                                        if indexing the whole column */
 
46
        const char*     field_name;     /*!< field name */
46
47
};
47
48
 
 
49
/** Index field definition */
48
50
typedef struct merge_index_field_struct merge_index_field_t;
49
51
 
50
 
/* This structure holds index definitions */
51
 
 
 
52
/** Definition of an index being created */
52
53
struct merge_index_def_struct {
53
 
        const char*             name;           /* Index name */
54
 
        ulint                   ind_type;       /* 0, DICT_UNIQUE,
 
54
        const char*             name;           /*!< index name */
 
55
        ulint                   ind_type;       /*!< 0, DICT_UNIQUE,
55
56
                                                or DICT_CLUSTERED */
56
 
        ulint                   n_fields;       /* Number of fields in index */
57
 
        merge_index_field_t*    fields;         /* Field definitions */
 
57
        ulint                   n_fields;       /*!< number of fields
 
58
                                                in index */
 
59
        merge_index_field_t*    fields;         /*!< field definitions */
58
60
};
59
61
 
 
62
/** Definition of an index being created */
60
63
typedef struct merge_index_def_struct merge_index_def_t;
61
64
 
62
 
/*************************************************************************
63
 
Sets an exclusive lock on a table, for the duration of creating indexes. */
 
65
/*********************************************************************//**
 
66
Sets an exclusive lock on a table, for the duration of creating indexes.
 
67
@return error code or DB_SUCCESS */
64
68
UNIV_INTERN
65
69
ulint
66
70
row_merge_lock_table(
67
71
/*=================*/
68
 
                                        /* out: error code or DB_SUCCESS */
69
 
        trx_t*          trx,            /* in/out: transaction */
70
 
        dict_table_t*   table,          /* in: table to lock */
71
 
        enum lock_mode  mode);          /* in: LOCK_X or LOCK_S */
72
 
/*************************************************************************
 
72
        trx_t*          trx,            /*!< in/out: transaction */
 
73
        dict_table_t*   table,          /*!< in: table to lock */
 
74
        enum lock_mode  mode);          /*!< in: LOCK_X or LOCK_S */
 
75
/*********************************************************************//**
73
76
Drop an index from the InnoDB system tables.  The data dictionary must
74
77
have been locked exclusively by the caller, because the transaction
75
78
will not be committed. */
77
80
void
78
81
row_merge_drop_index(
79
82
/*=================*/
80
 
        dict_index_t*   index,  /* in: index to be removed */
81
 
        dict_table_t*   table,  /* in: table */
82
 
        trx_t*          trx);   /* in: transaction handle */
83
 
/*************************************************************************
 
83
        dict_index_t*   index,  /*!< in: index to be removed */
 
84
        dict_table_t*   table,  /*!< in: table */
 
85
        trx_t*          trx);   /*!< in: transaction handle */
 
86
/*********************************************************************//**
84
87
Drop those indexes which were created before an error occurred when
85
88
building an index.  The data dictionary must have been locked
86
89
exclusively by the caller, because the transaction will not be
89
92
void
90
93
row_merge_drop_indexes(
91
94
/*===================*/
92
 
        trx_t*          trx,            /* in: transaction */
93
 
        dict_table_t*   table,          /* in: table containing the indexes */
94
 
        dict_index_t**  index,          /* in: indexes to drop */
95
 
        ulint           num_created);   /* in: number of elements in index[] */
96
 
/*************************************************************************
 
95
        trx_t*          trx,            /*!< in: transaction */
 
96
        dict_table_t*   table,          /*!< in: table containing the indexes */
 
97
        dict_index_t**  index,          /*!< in: indexes to drop */
 
98
        ulint           num_created);   /*!< in: number of elements in index[] */
 
99
/*********************************************************************//**
97
100
Drop all partially created indexes during crash recovery. */
98
101
UNIV_INTERN
99
102
void
100
103
row_merge_drop_temp_indexes(void);
101
104
/*=============================*/
102
 
/*************************************************************************
 
105
/*********************************************************************//**
103
106
Rename the tables in the data dictionary.  The data dictionary must
104
107
have been locked exclusively by the caller, because the transaction
105
 
will not be committed. */
 
108
will not be committed.
 
109
@return error code or DB_SUCCESS */
106
110
UNIV_INTERN
107
111
ulint
108
112
row_merge_rename_tables(
109
113
/*====================*/
110
 
                                        /* out: error code or DB_SUCCESS */
111
 
        dict_table_t*   old_table,      /* in/out: old table, renamed to
 
114
        dict_table_t*   old_table,      /*!< in/out: old table, renamed to
112
115
                                        tmp_name */
113
 
        dict_table_t*   new_table,      /* in/out: new table, renamed to
 
116
        dict_table_t*   new_table,      /*!< in/out: new table, renamed to
114
117
                                        old_table->name */
115
 
        const char*     tmp_name,       /* in: new name for old_table */
116
 
        trx_t*          trx);           /* in: transaction handle */
 
118
        const char*     tmp_name,       /*!< in: new name for old_table */
 
119
        trx_t*          trx);           /*!< in: transaction handle */
117
120
 
118
 
/*************************************************************************
 
121
/*********************************************************************//**
119
122
Create a temporary table for creating a primary key, using the definition
120
 
of an existing table. */
 
123
of an existing table.
 
124
@return table, or NULL on error */
121
125
UNIV_INTERN
122
126
dict_table_t*
123
127
row_merge_create_temporary_table(
124
128
/*=============================*/
125
 
                                                /* out: table,
126
 
                                                or NULL on error */
127
 
        const char*             table_name,     /* in: new table name */
128
 
        const merge_index_def_t*index_def,      /* in: the index definition
 
129
        const char*             table_name,     /*!< in: new table name */
 
130
        const merge_index_def_t*index_def,      /*!< in: the index definition
129
131
                                                of the primary key */
130
 
        const dict_table_t*     table,          /* in: old table definition */
131
 
        trx_t*                  trx);           /* in/out: transaction
 
132
        const dict_table_t*     table,          /*!< in: old table definition */
 
133
        trx_t*                  trx);           /*!< in/out: transaction
132
134
                                                (sets error_state) */
133
 
/*************************************************************************
 
135
/*********************************************************************//**
134
136
Rename the temporary indexes in the dictionary to permanent ones.  The
135
137
data dictionary must have been locked exclusively by the caller,
136
 
because the transaction will not be committed. */
 
138
because the transaction will not be committed.
 
139
@return DB_SUCCESS if all OK */
137
140
UNIV_INTERN
138
141
ulint
139
142
row_merge_rename_indexes(
140
143
/*=====================*/
141
 
                                        /* out: DB_SUCCESS if all OK */
142
 
        trx_t*          trx,            /* in/out: transaction */
143
 
        dict_table_t*   table);         /* in/out: table with new indexes */
144
 
/*************************************************************************
145
 
Create the index and load in to the dictionary. */
 
144
        trx_t*          trx,            /*!< in/out: transaction */
 
145
        dict_table_t*   table);         /*!< in/out: table with new indexes */
 
146
/*********************************************************************//**
 
147
Create the index and load in to the dictionary.
 
148
@return index, or NULL on error */
146
149
UNIV_INTERN
147
150
dict_index_t*
148
151
row_merge_create_index(
149
152
/*===================*/
150
 
                                        /* out: index, or NULL on error */
151
 
        trx_t*          trx,            /* in/out: trx (sets error_state) */
152
 
        dict_table_t*   table,          /* in: the index is on this table */
153
 
        const merge_index_def_t*        /* in: the index definition */
154
 
                        index_def);
155
 
#ifdef ROW_MERGE_IS_INDEX_USABLE
156
 
/*************************************************************************
157
 
Check if a transaction can use an index. */
 
153
        trx_t*                  trx,    /*!< in/out: trx (sets error_state) */
 
154
        dict_table_t*           table,  /*!< in: the index is on this table */
 
155
        const merge_index_def_t*index_def);
 
156
                                        /*!< in: the index definition */
 
157
/*********************************************************************//**
 
158
Check if a transaction can use an index.
 
159
@return TRUE if index can be used by the transaction else FALSE */
158
160
UNIV_INTERN
159
161
ibool
160
162
row_merge_is_index_usable(
161
163
/*======================*/
162
 
                                        /* out: TRUE if index can be used by
163
 
                                        the transaction else FALSE*/
164
 
        const trx_t*            trx,    /* in: transaction */
165
 
        const dict_index_t*     index); /* in: index to check */
166
 
#endif /* ROW_MERGE_IS_INDEX_USABLE */
167
 
/*************************************************************************
 
164
        const trx_t*            trx,    /*!< in: transaction */
 
165
        const dict_index_t*     index); /*!< in: index to check */
 
166
/*********************************************************************//**
168
167
If there are views that refer to the old table name then we "attach" to
169
 
the new instance of the table else we drop it immediately. */
 
168
the new instance of the table else we drop it immediately.
 
169
@return DB_SUCCESS or error code */
170
170
UNIV_INTERN
171
171
ulint
172
172
row_merge_drop_table(
173
173
/*=================*/
174
 
                                        /* out: DB_SUCCESS or error code */
175
 
        trx_t*          trx,            /* in: transaction */
176
 
        dict_table_t*   table);         /* in: table instance to drop */
 
174
        trx_t*          trx,            /*!< in: transaction */
 
175
        dict_table_t*   table);         /*!< in: table instance to drop */
177
176
 
178
 
/*************************************************************************
 
177
/*********************************************************************//**
179
178
Build indexes on a table by reading a clustered index,
180
179
creating a temporary file containing index entries, merge sorting
181
 
these index entries and inserting sorted index entries to indexes. */
 
180
these index entries and inserting sorted index entries to indexes.
 
181
@return DB_SUCCESS or error code */
182
182
UNIV_INTERN
183
183
ulint
184
184
row_merge_build_indexes(
185
185
/*====================*/
186
 
                                        /* out: DB_SUCCESS or error code */
187
 
        trx_t*          trx,            /* in: transaction */
188
 
        dict_table_t*   old_table,      /* in: table where rows are
 
186
        trx_t*          trx,            /*!< in: transaction */
 
187
        dict_table_t*   old_table,      /*!< in: table where rows are
189
188
                                        read from */
190
 
        dict_table_t*   new_table,      /* in: table where indexes are
 
189
        dict_table_t*   new_table,      /*!< in: table where indexes are
191
190
                                        created; identical to old_table
192
191
                                        unless creating a PRIMARY KEY */
193
 
        dict_index_t**  indexes,        /* in: indexes to be created */
194
 
        ulint           n_indexes,      /* in: size of indexes[] */
195
 
        TABLE*          table);         /* in/out: MySQL table, for
 
192
        dict_index_t**  indexes,        /*!< in: indexes to be created */
 
193
        ulint           n_indexes,      /*!< in: size of indexes[] */
 
194
        TABLE*          table);         /*!< in/out: MySQL table, for
196
195
                                        reporting erroneous key value
197
196
                                        if applicable */
198
197
#endif /* row0merge.h */