~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Mark Atwood
  • Date: 2009-01-05 04:37:22 UTC
  • mto: (758.1.1 devel)
  • mto: This revision was merged to the branch mainline in revision 759.
  • Revision ID: me@mark.atwood.name-20090105043722-03l4mzcxi4yjjjih
replace sql_print_error etc with errmsg_print

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.  The data dictionary must
 
58
have been locked exclusively by the caller, because the transaction
 
59
will not be committed. */
 
60
UNIV_INTERN
 
61
void
 
62
row_merge_drop_index(
 
63
/*=================*/
 
64
        dict_index_t*   index,  /* in: index to be removed */
 
65
        dict_table_t*   table,  /* in: table */
 
66
        trx_t*          trx);   /* in: transaction handle */
 
67
/*************************************************************************
 
68
Drop those indexes which were created before an error occurred when
 
69
building an index.  The data dictionary must have been locked
 
70
exclusively by the caller, because the transaction will not be
 
71
committed. */
 
72
UNIV_INTERN
 
73
void
 
74
row_merge_drop_indexes(
 
75
/*===================*/
 
76
        trx_t*          trx,            /* in: transaction */
 
77
        dict_table_t*   table,          /* in: table containing the indexes */
 
78
        dict_index_t**  index,          /* in: indexes to drop */
 
79
        ulint           num_created);   /* in: number of elements in index[] */
 
80
/*************************************************************************
 
81
Drop all partially created indexes during crash recovery. */
 
82
UNIV_INTERN
 
83
void
 
84
row_merge_drop_temp_indexes(void);
 
85
/*=============================*/
 
86
/*************************************************************************
 
87
Rename the tables in the data dictionary.  The data dictionary must
 
88
have been locked exclusively by the caller, because the transaction
 
89
will not be committed. */
 
90
UNIV_INTERN
 
91
ulint
 
92
row_merge_rename_tables(
 
93
/*====================*/
 
94
                                        /* out: error code or DB_SUCCESS */
 
95
        dict_table_t*   old_table,      /* in/out: old table, renamed to
 
96
                                        tmp_name */
 
97
        dict_table_t*   new_table,      /* in/out: new table, renamed to
 
98
                                        old_table->name */
 
99
        const char*     tmp_name,       /* in: new name for old_table */
 
100
        trx_t*          trx);           /* in: transaction handle */
 
101
 
 
102
/*************************************************************************
 
103
Create a temporary table for creating a primary key, using the definition
 
104
of an existing table. */
 
105
UNIV_INTERN
 
106
dict_table_t*
 
107
row_merge_create_temporary_table(
 
108
/*=============================*/
 
109
                                                /* out: table,
 
110
                                                or NULL on error */
 
111
        const char*             table_name,     /* in: new table name */
 
112
        const merge_index_def_t*index_def,      /* in: the index definition
 
113
                                                of the primary key */
 
114
        const dict_table_t*     table,          /* in: old table definition */
 
115
        trx_t*                  trx);           /* in/out: transaction
 
116
                                                (sets error_state) */
 
117
/*************************************************************************
 
118
Rename the temporary indexes in the dictionary to permanent ones.  The
 
119
data dictionary must have been locked exclusively by the caller,
 
120
because the transaction will not be committed. */
 
121
UNIV_INTERN
 
122
ulint
 
123
row_merge_rename_indexes(
 
124
/*=====================*/
 
125
                                        /* out: DB_SUCCESS if all OK */
 
126
        trx_t*          trx,            /* in/out: transaction */
 
127
        dict_table_t*   table);         /* in/out: table with new indexes */
 
128
/*************************************************************************
 
129
Create the index and load in to the dictionary. */
 
130
UNIV_INTERN
 
131
dict_index_t*
 
132
row_merge_create_index(
 
133
/*===================*/
 
134
                                        /* out: index, or NULL on error */
 
135
        trx_t*          trx,            /* in/out: trx (sets error_state) */
 
136
        dict_table_t*   table,          /* in: the index is on this table */
 
137
        const merge_index_def_t*        /* in: the index definition */
 
138
                        index_def);
 
139
#ifdef ROW_MERGE_IS_INDEX_USABLE
 
140
/*************************************************************************
 
141
Check if a transaction can use an index. */
 
142
UNIV_INTERN
 
143
ibool
 
144
row_merge_is_index_usable(
 
145
/*======================*/
 
146
                                        /* out: TRUE if index can be used by
 
147
                                        the transaction else FALSE*/
 
148
        const trx_t*            trx,    /* in: transaction */
 
149
        const dict_index_t*     index); /* in: index to check */
 
150
#endif /* ROW_MERGE_IS_INDEX_USABLE */
 
151
/*************************************************************************
 
152
If there are views that refer to the old table name then we "attach" to
 
153
the new instance of the table else we drop it immediately. */
 
154
UNIV_INTERN
 
155
ulint
 
156
row_merge_drop_table(
 
157
/*=================*/
 
158
                                        /* out: DB_SUCCESS or error code */
 
159
        trx_t*          trx,            /* in: transaction */
 
160
        dict_table_t*   table);         /* in: table instance to drop */
 
161
 
 
162
/*************************************************************************
 
163
Build indexes on a table by reading a clustered index,
 
164
creating a temporary file containing index entries, merge sorting
 
165
these index entries and inserting sorted index entries to indexes. */
 
166
UNIV_INTERN
 
167
ulint
 
168
row_merge_build_indexes(
 
169
/*====================*/
 
170
                                        /* out: DB_SUCCESS or error code */
 
171
        trx_t*          trx,            /* in: transaction */
 
172
        dict_table_t*   old_table,      /* in: table where rows are
 
173
                                        read from */
 
174
        dict_table_t*   new_table,      /* in: table where indexes are
 
175
                                        created; identical to old_table
 
176
                                        unless creating a PRIMARY KEY */
 
177
        dict_index_t**  indexes,        /* in: indexes to be created */
 
178
        ulint           n_indexes,      /* in: size of indexes[] */
 
179
        TABLE*          table);         /* in/out: MySQL table, for
 
180
                                        reporting erroneous key value
 
181
                                        if applicable */
 
182
#endif /* row0merge.h */