~drizzle-trunk/drizzle/development

1208.3.3 by brian
Adding missingfile.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
/**
21
  @file Cursor.cc
22
23
  Handler-calling-functions
24
*/
25
1241.9.36 by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h.
26
#include "config.h"
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
27
#include "drizzled/my_hash.h"
1208.3.3 by brian
Adding missingfile.
28
#include "drizzled/error.h"
29
#include "drizzled/gettext.h"
30
#include "drizzled/probes.h"
31
#include "drizzled/sql_parse.h"
32
#include "drizzled/session.h"
33
#include "drizzled/sql_base.h"
34
#include "drizzled/replication_services.h"
35
#include "drizzled/lock.h"
36
#include "drizzled/item/int.h"
37
#include "drizzled/item/empty_string.h"
38
#include "drizzled/field/timestamp.h"
39
#include "drizzled/plugin/client.h"
1241.9.64 by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal.
40
#include "drizzled/internal/my_sys.h"
1208.3.3 by brian
Adding missingfile.
41
42
using namespace std;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
43
44
namespace drizzled
45
{
1208.3.3 by brian
Adding missingfile.
46
47
KEY_CREATE_INFO default_key_create_info= { HA_KEY_ALG_UNDEF, 0, {NULL,0} };
48
49
/* number of entries in storage_engines[] */
50
uint32_t total_ha= 0;
51
/* number of storage engines (from storage_engines[]) that support 2pc */
52
uint32_t total_ha_2pc= 0;
53
54
const char *ha_row_type[] = {
55
  "", "FIXED", "DYNAMIC", "COMPRESSED", "REDUNDANT", "COMPACT", "PAGE", "?","?","?"
56
};
57
58
59
60
/**
61
  Register Cursor error messages for use with my_error().
62
63
  @retval
64
    0           OK
65
  @retval
66
    !=0         Error
67
*/
68
69
int ha_init_errors(void)
70
{
71
#define SETMSG(nr, msg) errmsgs[(nr) - HA_ERR_FIRST]= (msg)
72
  const char    **errmsgs;
73
74
  /* Allocate a pointer array for the error message strings. */
75
  /* Zerofill it to avoid uninitialized gaps. */
76
  if (! (errmsgs= (const char**) malloc(HA_ERR_ERRORS * sizeof(char*))))
77
    return 1;
78
  memset(errmsgs, 0, HA_ERR_ERRORS * sizeof(char *));
79
80
  /* Set the dedicated error messages. */
81
  SETMSG(HA_ERR_KEY_NOT_FOUND,          ER(ER_KEY_NOT_FOUND));
82
  SETMSG(HA_ERR_FOUND_DUPP_KEY,         ER(ER_DUP_KEY));
83
  SETMSG(HA_ERR_RECORD_CHANGED,         "Update wich is recoverable");
84
  SETMSG(HA_ERR_WRONG_INDEX,            "Wrong index given to function");
85
  SETMSG(HA_ERR_CRASHED,                ER(ER_NOT_KEYFILE));
86
  SETMSG(HA_ERR_WRONG_IN_RECORD,        ER(ER_CRASHED_ON_USAGE));
87
  SETMSG(HA_ERR_OUT_OF_MEM,             "Table Cursor out of memory");
88
  SETMSG(HA_ERR_NOT_A_TABLE,            "Incorrect file format '%.64s'");
89
  SETMSG(HA_ERR_WRONG_COMMAND,          "Command not supported");
90
  SETMSG(HA_ERR_OLD_FILE,               ER(ER_OLD_KEYFILE));
91
  SETMSG(HA_ERR_NO_ACTIVE_RECORD,       "No record read in update");
92
  SETMSG(HA_ERR_RECORD_DELETED,         "Intern record deleted");
93
  SETMSG(HA_ERR_RECORD_FILE_FULL,       ER(ER_RECORD_FILE_FULL));
94
  SETMSG(HA_ERR_INDEX_FILE_FULL,        "No more room in index file '%.64s'");
95
  SETMSG(HA_ERR_END_OF_FILE,            "End in next/prev/first/last");
96
  SETMSG(HA_ERR_UNSUPPORTED,            ER(ER_ILLEGAL_HA));
97
  SETMSG(HA_ERR_TO_BIG_ROW,             "Too big row");
98
  SETMSG(HA_WRONG_CREATE_OPTION,        "Wrong create option");
99
  SETMSG(HA_ERR_FOUND_DUPP_UNIQUE,      ER(ER_DUP_UNIQUE));
100
  SETMSG(HA_ERR_UNKNOWN_CHARSET,        "Can't open charset");
101
  SETMSG(HA_ERR_WRONG_MRG_TABLE_DEF,    ER(ER_WRONG_MRG_TABLE));
102
  SETMSG(HA_ERR_CRASHED_ON_REPAIR,      ER(ER_CRASHED_ON_REPAIR));
103
  SETMSG(HA_ERR_CRASHED_ON_USAGE,       ER(ER_CRASHED_ON_USAGE));
104
  SETMSG(HA_ERR_LOCK_WAIT_TIMEOUT,      ER(ER_LOCK_WAIT_TIMEOUT));
105
  SETMSG(HA_ERR_LOCK_TABLE_FULL,        ER(ER_LOCK_TABLE_FULL));
106
  SETMSG(HA_ERR_READ_ONLY_TRANSACTION,  ER(ER_READ_ONLY_TRANSACTION));
107
  SETMSG(HA_ERR_LOCK_DEADLOCK,          ER(ER_LOCK_DEADLOCK));
108
  SETMSG(HA_ERR_CANNOT_ADD_FOREIGN,     ER(ER_CANNOT_ADD_FOREIGN));
109
  SETMSG(HA_ERR_NO_REFERENCED_ROW,      ER(ER_NO_REFERENCED_ROW_2));
110
  SETMSG(HA_ERR_ROW_IS_REFERENCED,      ER(ER_ROW_IS_REFERENCED_2));
111
  SETMSG(HA_ERR_NO_SAVEPOINT,           "No savepoint with that name");
112
  SETMSG(HA_ERR_NON_UNIQUE_BLOCK_SIZE,  "Non unique key block size");
113
  SETMSG(HA_ERR_NO_SUCH_TABLE,          "No such table: '%.64s'");
114
  SETMSG(HA_ERR_TABLE_EXIST,            ER(ER_TABLE_EXISTS_ERROR));
115
  SETMSG(HA_ERR_NO_CONNECTION,          "Could not connect to storage engine");
116
  SETMSG(HA_ERR_TABLE_DEF_CHANGED,      ER(ER_TABLE_DEF_CHANGED));
117
  SETMSG(HA_ERR_FOREIGN_DUPLICATE_KEY,  "FK constraint would lead to duplicate key");
118
  SETMSG(HA_ERR_TABLE_NEEDS_UPGRADE,    ER(ER_TABLE_NEEDS_UPGRADE));
119
  SETMSG(HA_ERR_TABLE_READONLY,         ER(ER_OPEN_AS_READONLY));
120
  SETMSG(HA_ERR_AUTOINC_READ_FAILED,    ER(ER_AUTOINC_READ_FAILED));
121
  SETMSG(HA_ERR_AUTOINC_ERANGE,         ER(ER_WARN_DATA_OUT_OF_RANGE));
122
123
  /* Register the error messages for use with my_error(). */
124
  return my_error_register(errmsgs, HA_ERR_FIRST, HA_ERR_LAST);
125
}
126
127
128
/**
129
  Unregister Cursor error messages.
130
131
  @retval
132
    0           OK
133
  @retval
134
    !=0         Error
135
*/
136
static int ha_finish_errors(void)
137
{
138
  const char    **errmsgs;
139
140
  /* Allocate a pointer array for the error message strings. */
141
  if (! (errmsgs= my_error_unregister(HA_ERR_FIRST, HA_ERR_LAST)))
142
    return 1;
143
  free((unsigned char*) errmsgs);
144
  return 0;
145
}
146
147
int ha_init()
148
{
149
  int error= 0;
150
151
  assert(total_ha < MAX_HA);
152
  return error;
153
}
154
155
int ha_end()
156
{
157
  int error= 0;
158
159
  /*
160
    This should be eventualy based  on the graceful shutdown flag.
161
    So if flag is equal to HA_PANIC_CLOSE, the deallocate
162
    the errors.
163
  */
164
  if (ha_finish_errors())
165
    error= 1;
166
167
  return error;
168
}
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
169
170
} /* namespace drizzled */