~drizzle-trunk/drizzle/development

520.1.25 by Monty Taylor
Removed the split.
1
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
236.1.23 by Monty Taylor
Cleaned header headers.
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
390.1.3 by Monty Taylor
Copyright header fixes.
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
236.1.23 by Monty Taylor
Cleaned header headers.
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
390.1.3 by Monty Taylor
Copyright header fixes.
8
 *  the Free Software Foundation; version 2 of the License.
236.1.23 by Monty Taylor
Cleaned header headers.
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
 */
1 by brian
clean slate
19
20
/*
21
** Common definition between mysql server & client
22
*/
23
1122.2.10 by Monty Taylor
Fixed all of the include guards.
24
#ifndef DRIZZLED_COMMON_H
25
#define DRIZZLED_COMMON_H
1 by brian
clean slate
26
390.1.5 by Monty Taylor
Moved more functions into drizzle.c as part of the split of code.
27
#include <unistd.h>
28
#include <stdint.h>
542 by Monty Taylor
Cleaned up the last commit.
29
#include <drizzled/korr.h>
390.1.5 by Monty Taylor
Moved more functions into drizzle.c as part of the split of code.
30
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
31
/*
520.1.28 by Monty Taylor
Reverted too-big formatting change.
32
   This is included in the server and in the client.
33
   Options for select set by the yacc parser (stored in lex->options).
34
35
   XXX:
36
   log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
37
   options list are written into binlog. These options can NOT change their
38
   values, or it will break replication between version.
39
40
   context is encoded as following:
847 by Brian Aker
More typdef class removal.
41
   SELECT - Select_Lex_Node::options
520.1.28 by Monty Taylor
Reverted too-big formatting change.
42
   THD    - THD::options
43
   intern - neither. used only as
44
            func(..., select_node->options | thd->options | OPTION_XXX, ...)
45
46
   TODO: separate three contexts above, move them to separate bitfields.
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
47
*/
48
779.3.53 by Monty Taylor
Revert the fail.
49
#define SELECT_DISTINCT         (UINT64_C(1) << 0)     // SELECT, user
50
#define SELECT_STRAIGHT_JOIN    (UINT64_C(1) << 1)     // SELECT, user
51
#define SELECT_DESCRIBE         (UINT64_C(1) << 2)     // SELECT, user
52
#define SELECT_SMALL_RESULT     (UINT64_C(1) << 3)     // SELECT, user
53
#define SELECT_BIG_RESULT       (UINT64_C(1) << 4)     // SELECT, user
54
#define OPTION_FOUND_ROWS       (UINT64_C(1) << 5)     // SELECT, user
55
#define SELECT_NO_JOIN_CACHE    (UINT64_C(1) << 7)     // intern
56
#define OPTION_BIG_TABLES       (UINT64_C(1) << 8)     // THD, user
57
#define OPTION_BIG_SELECTS      (UINT64_C(1) << 9)     // THD, user
58
#define TMP_TABLE_ALL_COLUMNS   (UINT64_C(1) << 12)    // SELECT, intern
59
#define OPTION_WARNINGS         (UINT64_C(1) << 13)    // THD, user
60
#define OPTION_AUTO_IS_NULL     (UINT64_C(1) << 14)    // THD, user, binlog
61
#define OPTION_FOUND_COMMENT    (UINT64_C(1) << 15)    // SELECT, intern, parser
62
#define OPTION_BUFFER_RESULT    (UINT64_C(1) << 17)    // SELECT, user
63
#define OPTION_NOT_AUTOCOMMIT   (UINT64_C(1) << 19)    // THD, user
64
#define OPTION_BEGIN            (UINT64_C(1) << 20)    // THD, intern
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
65
66
/* The following is used to detect a conflict with DISTINCT */
779.3.53 by Monty Taylor
Revert the fail.
67
#define SELECT_ALL              (UINT64_C(1) << 24)    // SELECT, user, parser
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
68
69
/** The following can be set when importing tables in a 'wrong order'
520.1.28 by Monty Taylor
Reverted too-big formatting change.
70
   to suppress foreign key checks */
779.3.53 by Monty Taylor
Revert the fail.
71
#define OPTION_NO_FOREIGN_KEY_CHECKS    (UINT64_C(1) << 26) // THD, user, binlog
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
72
/** The following speeds up inserts to InnoDB tables by suppressing unique
520.1.28 by Monty Taylor
Reverted too-big formatting change.
73
   key checks in some cases */
779.3.53 by Monty Taylor
Revert the fail.
74
#define OPTION_RELAXED_UNIQUE_CHECKS    (UINT64_C(1) << 27) // THD, user, binlog
75
#define SELECT_NO_UNLOCK                (UINT64_C(1) << 28) // SELECT, intern
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
76
/** Flag set if setup_tables already done */
779.3.53 by Monty Taylor
Revert the fail.
77
#define OPTION_SETUP_TABLES_DONE        (UINT64_C(1) << 30) // intern
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
78
/** If not set then the thread will ignore all warnings with level notes. */
779.3.53 by Monty Taylor
Revert the fail.
79
#define OPTION_SQL_NOTES                (UINT64_C(1) << 31) // THD, user
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
80
81
/**
520.1.28 by Monty Taylor
Reverted too-big formatting change.
82
  Maximum length of time zone name that we support
83
  (Time zone name is char(64) in db). mysqlbinlog needs it.
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
84
*/
85
#define MAX_TIME_ZONE_NAME_LENGTH       (NAME_LEN + 1)
86
1 by brian
clean slate
87
#define HOSTNAME_LENGTH 60
88
#define SYSTEM_CHARSET_MBMAXLEN 4
575.4.7 by Monty Taylor
More header cleanup.
89
#define USERNAME_CHAR_LENGTH 16
1 by brian
clean slate
90
#define NAME_CHAR_LEN	64              /* Field/table name length */
91
#define NAME_LEN                (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
1567.1.1 by Brian Aker
This fixes bug 586009, increases the size of the log files so that the UNION
92
#define MAXIMUM_IDENTIFIER_LENGTH NAME_LEN
1 by brian
clean slate
93
#define USERNAME_LENGTH         (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
94
95
#define SERVER_VERSION_LENGTH 60
96
#define SQLSTATE_LENGTH 5
97
98
/*
99
  USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
100
  username and hostname parts of the user identifier with trailing zero in
101
  MySQL standard format:
102
  user_name_part@host_name_part\0
103
*/
104
#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
105
106
/*
107
  You should add new commands to the end of this list, otherwise old
108
  servers won't be able to handle them as 'unsupported'.
109
*/
110
111
/*
112
  Length of random string sent by server on handshake; this is also length of
113
  obfuscated password, recieved from client
114
*/
115
#define SCRAMBLE_LENGTH 20
116
#define SCRAMBLE_LENGTH_323 8
117
520.1.28 by Monty Taylor
Reverted too-big formatting change.
118
#define NOT_NULL_FLAG	1		/* Field can't be NULL */
119
#define PRI_KEY_FLAG	2		/* Field is part of a primary key */
120
#define UNIQUE_KEY_FLAG 4		/* Field is part of a unique key */
121
#define MULTIPLE_KEY_FLAG 8		/* Field is part of a key */
122
#define BLOB_FLAG	16		/* Field is a blob */
123
#define UNSIGNED_FLAG	32		/* Field is unsigned */
124
#define BINARY_FLAG	128		/* Field is binary   */
1 by brian
clean slate
125
126
/* The following are only sent to new clients */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
127
#define ENUM_FLAG	256		/* field is an enum */
128
#define AUTO_INCREMENT_FLAG 512		/* field is a autoincrement field */
1976.6.1 by Brian Aker
This is a fix for bug lp:686197
129
#define FUNCTION_DEFAULT_FLAG	1024		/* Field is a timestamp, uses a function to generate the value. */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
130
#define NO_DEFAULT_VALUE_FLAG 4096	/* Field doesn't have default value */
1 by brian
clean slate
131
#define ON_UPDATE_NOW_FLAG 8192         /* Field is set to NOW on UPDATE */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
132
#define PART_KEY_FLAG	16384		/* Intern; Part of some key */
133
#define GROUP_FLAG	32768		/* Intern: Group field */
134
#define UNIQUE_FLAG	65536		/* Intern: Used by sql_yacc */
135
#define BINCMP_FLAG	131072		/* Intern: Used by sql_yacc */
1 by brian
clean slate
136
#define COLUMN_FORMAT_FLAGS 25          /* Column format: bit 25, 26 and 27 */
1313.1.16 by Stewart Smith
move COLUMN_FORMAT_FLAGS define so it is with the other COLUMN_FLAGS defines in common.h instead
137
#define COLUMN_FORMAT_MASK 7
1 by brian
clean slate
138
520.1.28 by Monty Taylor
Reverted too-big formatting change.
139
#define SERVER_STATUS_IN_TRANS     1	/* Transaction has started */
140
#define SERVER_STATUS_AUTOCOMMIT   2	/* Server in auto_commit mode */
1 by brian
clean slate
141
#define SERVER_MORE_RESULTS_EXISTS 8    /* Multi query - next query exists */
142
#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
143
#define SERVER_QUERY_NO_INDEX_USED      32
144
#define SERVER_STATUS_DB_DROPPED        256 /* A database was dropped */
145
520.1.28 by Monty Taylor
Reverted too-big formatting change.
146
#define DRIZZLE_ERRMSG_SIZE	512
1 by brian
clean slate
147
148
#define ONLY_KILL_QUERY         1
149
150
#define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
151
#define MAX_BIGINT_WIDTH        20      /* Max width for a LONGLONG */
937.2.6 by Stewart Smith
make set_if_bigger typesafe for C and C++. Fix up everywhere.
152
#define MAX_BLOB_WIDTH		(uint32_t)16777216	/* Default width for blob */
1 by brian
clean slate
153
264.2.4 by Andrey Hristov
Remove support for the old, pre-4.1, protocol
154
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
155
156
1 by brian
clean slate
157
158
1816.2.4 by Monty Taylor
Cleaned up a bunch more warnings.
159
#define packet_error UINT32_MAX
1 by brian
clean slate
160
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
161
#if defined(__cplusplus)
162
163
namespace drizzled
164
{
165
166
enum enum_server_command
167
{
168
  COM_SLEEP,
169
  COM_QUIT,
170
  COM_INIT_DB,
171
  COM_QUERY,
172
  COM_SHUTDOWN,
173
  COM_CONNECT,
174
  COM_PING,
175
  /* don't forget to update const char *command_name[] in sql_parse.cc */
176
  /* Must be last */
177
  COM_END
178
};
179
180
1921.4.2 by Brian Aker
Adding in concurrent execute support.
181
enum enum_field_types { 
182
                        DRIZZLE_TYPE_LONG,
390.1.6 by Monty Taylor
Oh dear god the changes. The changes. I'd tell you what they are, but I'd just be making stuff up. Suffice it to day it's mostly all around splitting files in libdrizzle into different files and removing interdepends. And whatever else I happened to see...
183
                        DRIZZLE_TYPE_DOUBLE,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
184
                        DRIZZLE_TYPE_NULL,
185
                        DRIZZLE_TYPE_TIMESTAMP,
390.1.6 by Monty Taylor
Oh dear god the changes. The changes. I'd tell you what they are, but I'd just be making stuff up. Suffice it to day it's mostly all around splitting files in libdrizzle into different files and removing interdepends. And whatever else I happened to see...
186
                        DRIZZLE_TYPE_LONGLONG,
187
                        DRIZZLE_TYPE_DATETIME,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
188
                        DRIZZLE_TYPE_DATE,
189
                        DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
190
                        DRIZZLE_TYPE_DECIMAL,
520.1.25 by Monty Taylor
Removed the split.
191
                        DRIZZLE_TYPE_ENUM,
192
                        DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
193
                        DRIZZLE_TYPE_TIME,
1996.2.1 by Brian Aker
uuid type code.
194
                        DRIZZLE_TYPE_UUID
390.1.6 by Monty Taylor
Oh dear god the changes. The changes. I'd tell you what they are, but I'd just be making stuff up. Suffice it to day it's mostly all around splitting files in libdrizzle into different files and removing interdepends. And whatever else I happened to see...
195
};
1996.2.1 by Brian Aker
uuid type code.
196
const int enum_field_types_size= DRIZZLE_TYPE_UUID + 1;
390.1.6 by Monty Taylor
Oh dear god the changes. The changes. I'd tell you what they are, but I'd just be making stuff up. Suffice it to day it's mostly all around splitting files in libdrizzle into different files and removing interdepends. And whatever else I happened to see...
197
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
198
} /* namespace drizzled */
199
200
#endif /* defined(__cplusplus) */
1 by brian
clean slate
201
1122.2.10 by Monty Taylor
Fixed all of the include guards.
202
#endif /* DRIZZLED_COMMON_H */