drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
common.h
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, Inc.
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** Common definition between Drizzle server & client
22*/
23
24#pragma once
25
26#include <unistd.h>
27#include <stdint.h>
28#include <drizzled/korr.h>
29
30/*
31 This is included in the server and in the client.
32 Options for select set by the yacc parser (stored in lex->options).
33
34 context is encoded as following:
35 SELECT - Select_Lex_Node::options
36 THD - THD::options
37 intern - neither. used only as
38 func(..., select_node->options | thd->options | OPTION_XXX, ...)
39
40 TODO: separate three contexts above, move them to separate bitfields.
41*/
42
43#define SELECT_DISTINCT (UINT64_C(1) << 0) // SELECT, user
44#define SELECT_STRAIGHT_JOIN (UINT64_C(1) << 1) // SELECT, user
45#define SELECT_DESCRIBE (UINT64_C(1) << 2) // SELECT, user
46#define SELECT_SMALL_RESULT (UINT64_C(1) << 3) // SELECT, user
47#define SELECT_BIG_RESULT (UINT64_C(1) << 4) // SELECT, user
48#define OPTION_FOUND_ROWS (UINT64_C(1) << 5) // SELECT, user
49#define SELECT_NO_JOIN_CACHE (UINT64_C(1) << 7) // intern
50#define OPTION_BIG_TABLES (UINT64_C(1) << 8) // THD, user
51#define OPTION_BIG_SELECTS (UINT64_C(1) << 9) // THD, user
52#define TMP_TABLE_ALL_COLUMNS (UINT64_C(1) << 12) // SELECT, intern
53#define OPTION_WARNINGS (UINT64_C(1) << 13) // THD, user
54#define OPTION_AUTO_IS_NULL (UINT64_C(1) << 14) // THD, user
55#define OPTION_FOUND_COMMENT (UINT64_C(1) << 15) // SELECT, intern, parser
56#define OPTION_BUFFER_RESULT (UINT64_C(1) << 17) // SELECT, user
57#define OPTION_NOT_AUTOCOMMIT (UINT64_C(1) << 19) // THD, user
58#define OPTION_BEGIN (UINT64_C(1) << 20) // THD, intern
59
60/* The following is used to detect a conflict with DISTINCT */
61#define SELECT_ALL (UINT64_C(1) << 24) // SELECT, user, parser
62
65#define OPTION_NO_FOREIGN_KEY_CHECKS (UINT64_C(1) << 26) // THD, user
68#define OPTION_RELAXED_UNIQUE_CHECKS (UINT64_C(1) << 27) // THD, user
69#define SELECT_NO_UNLOCK (UINT64_C(1) << 28) // SELECT, intern
71#define OPTION_SETUP_TABLES_DONE (UINT64_C(1) << 30) // intern
73#define OPTION_SQL_NOTES (UINT64_C(1) << 31) // THD, user
74
75#define HOSTNAME_LENGTH 60
76#define SYSTEM_CHARSET_MBMAXLEN 4
77#define USERNAME_CHAR_LENGTH 16
78#define NAME_CHAR_LEN 64 /* Field/table name length */
79#define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
80#define MAXIMUM_IDENTIFIER_LENGTH NAME_LEN
81#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
82
83#define SERVER_VERSION_LENGTH 60
84#define SQLSTATE_LENGTH 5
85
86/*
87 USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
88 username and hostname parts of the user identifier with trailing zero in
89 MySQL standard format:
90 user_name_part@host_name_part\0
91*/
92#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
93
94/*
95 You should add new commands to the end of this list, otherwise old
96 servers won't be able to handle them as 'unsupported'.
97*/
98
99/*
100 Length of random string sent by server on handshake; this is also length of
101 obfuscated password, recieved from client
102*/
103#define SCRAMBLE_LENGTH 20
104#define SCRAMBLE_LENGTH_323 8
105
106#define NOT_NULL_FLAG 1 /* Field can't be NULL */
107#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
108#define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */
109#define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */
110#define BLOB_FLAG 16 /* Field is a blob */
111#define UNSIGNED_FLAG 32 /* Field is unsigned */
112#define BINARY_FLAG 128 /* Field is binary */
113
114/* The following are only sent to new clients */
115#define ENUM_FLAG 256 /* field is an enum */
116#define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */
117#define FUNCTION_DEFAULT_FLAG 1024 /* Field is a timestamp, uses a function to generate the value. */
118#define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */
119#define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */
120#define PART_KEY_FLAG 16384 /* Intern; Part of some key */
121#define GROUP_FLAG 32768 /* Intern: Group field */
122#define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */
123#define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */
124#define COLUMN_FORMAT_FLAGS 25 /* Column format: bit 25, 26 and 27 */
125#define COLUMN_FORMAT_MASK 7
126
127#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
128#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
129#define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */
130#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
131#define SERVER_QUERY_NO_INDEX_USED 32
132#define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */
133
134#define DRIZZLE_ERRMSG_SIZE 512
135
136#define ONLY_KILL_QUERY 1
137
138#define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */
139#define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */
140#define MAX_BLOB_WIDTH (uint32_t)16777216 /* Default width for blob */
141
142#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
143
144
145
146
147#define packet_error UINT32_MAX
148
149#if defined(__cplusplus)
150
151namespace drizzled
152{
153
154enum enum_server_command
155{
156 COM_SLEEP,
157 COM_QUIT,
158 COM_USE_SCHEMA,
159 COM_QUERY,
160 COM_SHUTDOWN,
161 COM_CONNECT,
162 COM_PING,
163 COM_KILL,
164 /* don't forget to update const char *command_name[] in sql_parse.cc */
165 /* Must be last */
166 COM_END
167};
168
169
170enum enum_field_types {
171 DRIZZLE_TYPE_LONG,
172 DRIZZLE_TYPE_DOUBLE,
173 DRIZZLE_TYPE_NULL,
174 DRIZZLE_TYPE_TIMESTAMP,
175 DRIZZLE_TYPE_LONGLONG,
176 DRIZZLE_TYPE_DATETIME,
177 DRIZZLE_TYPE_DATE,
178 DRIZZLE_TYPE_VARCHAR,
179 DRIZZLE_TYPE_DECIMAL,
180 DRIZZLE_TYPE_ENUM,
181 DRIZZLE_TYPE_BLOB,
182 DRIZZLE_TYPE_TIME,
183 DRIZZLE_TYPE_BOOLEAN,
184 DRIZZLE_TYPE_UUID,
185 DRIZZLE_TYPE_MICROTIME,
186 DRIZZLE_TYPE_IPV6
187};
188const int enum_field_types_size= DRIZZLE_TYPE_IPV6 + 1;
189
190} /* namespace drizzled */
191
192#endif /* defined(__cplusplus) */
193
TODO: Rename this file - func.h is stupid.