~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
/*
2252.2.3 by Brian Aker
Fix for bad include reference in include.am
21
** Common definition between Drizzle server & client
1 by brian
clean slate
22
*/
23
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
24
#pragma once
1 by brian
clean slate
25
390.1.5 by Monty Taylor
Moved more functions into drizzle.c as part of the split of code.
26
#include <unistd.h>
27
#include <stdint.h>
542 by Monty Taylor
Cleaned up the last commit.
28
#include <drizzled/korr.h>
390.1.5 by Monty Taylor
Moved more functions into drizzle.c as part of the split of code.
29
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
30
/*
520.1.28 by Monty Taylor
Reverted too-big formatting change.
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
   XXX:
35
   log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
36
   options list are written into binlog. These options can NOT change their
37
   values, or it will break replication between version.
38
39
   context is encoded as following:
847 by Brian Aker
More typdef class removal.
40
   SELECT - Select_Lex_Node::options
520.1.28 by Monty Taylor
Reverted too-big formatting change.
41
   THD    - THD::options
42
   intern - neither. used only as
43
            func(..., select_node->options | thd->options | OPTION_XXX, ...)
44
45
   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
46
*/
47
779.3.53 by Monty Taylor
Revert the fail.
48
#define SELECT_DISTINCT         (UINT64_C(1) << 0)     // SELECT, user
49
#define SELECT_STRAIGHT_JOIN    (UINT64_C(1) << 1)     // SELECT, user
50
#define SELECT_DESCRIBE         (UINT64_C(1) << 2)     // SELECT, user
51
#define SELECT_SMALL_RESULT     (UINT64_C(1) << 3)     // SELECT, user
52
#define SELECT_BIG_RESULT       (UINT64_C(1) << 4)     // SELECT, user
53
#define OPTION_FOUND_ROWS       (UINT64_C(1) << 5)     // SELECT, user
54
#define SELECT_NO_JOIN_CACHE    (UINT64_C(1) << 7)     // intern
55
#define OPTION_BIG_TABLES       (UINT64_C(1) << 8)     // THD, user
56
#define OPTION_BIG_SELECTS      (UINT64_C(1) << 9)     // THD, user
57
#define TMP_TABLE_ALL_COLUMNS   (UINT64_C(1) << 12)    // SELECT, intern
58
#define OPTION_WARNINGS         (UINT64_C(1) << 13)    // THD, user
59
#define OPTION_AUTO_IS_NULL     (UINT64_C(1) << 14)    // THD, user, binlog
60
#define OPTION_FOUND_COMMENT    (UINT64_C(1) << 15)    // SELECT, intern, parser
61
#define OPTION_BUFFER_RESULT    (UINT64_C(1) << 17)    // SELECT, user
62
#define OPTION_NOT_AUTOCOMMIT   (UINT64_C(1) << 19)    // THD, user
63
#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
64
65
/* The following is used to detect a conflict with DISTINCT */
779.3.53 by Monty Taylor
Revert the fail.
66
#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
67
68
/** The following can be set when importing tables in a 'wrong order'
520.1.28 by Monty Taylor
Reverted too-big formatting change.
69
   to suppress foreign key checks */
779.3.53 by Monty Taylor
Revert the fail.
70
#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
71
/** The following speeds up inserts to InnoDB tables by suppressing unique
520.1.28 by Monty Taylor
Reverted too-big formatting change.
72
   key checks in some cases */
779.3.53 by Monty Taylor
Revert the fail.
73
#define OPTION_RELAXED_UNIQUE_CHECKS    (UINT64_C(1) << 27) // THD, user, binlog
74
#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
75
/** Flag set if setup_tables already done */
779.3.53 by Monty Taylor
Revert the fail.
76
#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
77
/** If not set then the thread will ignore all warnings with level notes. */
779.3.53 by Monty Taylor
Revert the fail.
78
#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
79
1 by brian
clean slate
80
#define HOSTNAME_LENGTH 60
81
#define SYSTEM_CHARSET_MBMAXLEN 4
575.4.7 by Monty Taylor
More header cleanup.
82
#define USERNAME_CHAR_LENGTH 16
1 by brian
clean slate
83
#define NAME_CHAR_LEN	64              /* Field/table name length */
84
#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
85
#define MAXIMUM_IDENTIFIER_LENGTH NAME_LEN
1 by brian
clean slate
86
#define USERNAME_LENGTH         (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
87
88
#define SERVER_VERSION_LENGTH 60
89
#define SQLSTATE_LENGTH 5
90
91
/*
92
  USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
93
  username and hostname parts of the user identifier with trailing zero in
94
  MySQL standard format:
95
  user_name_part@host_name_part\0
96
*/
97
#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
98
99
/*
100
  You should add new commands to the end of this list, otherwise old
101
  servers won't be able to handle them as 'unsupported'.
102
*/
103
104
/*
105
  Length of random string sent by server on handshake; this is also length of
106
  obfuscated password, recieved from client
107
*/
108
#define SCRAMBLE_LENGTH 20
109
#define SCRAMBLE_LENGTH_323 8
110
520.1.28 by Monty Taylor
Reverted too-big formatting change.
111
#define NOT_NULL_FLAG	1		/* Field can't be NULL */
112
#define PRI_KEY_FLAG	2		/* Field is part of a primary key */
113
#define UNIQUE_KEY_FLAG 4		/* Field is part of a unique key */
114
#define MULTIPLE_KEY_FLAG 8		/* Field is part of a key */
115
#define BLOB_FLAG	16		/* Field is a blob */
116
#define UNSIGNED_FLAG	32		/* Field is unsigned */
117
#define BINARY_FLAG	128		/* Field is binary   */
1 by brian
clean slate
118
119
/* The following are only sent to new clients */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
120
#define ENUM_FLAG	256		/* field is an enum */
121
#define AUTO_INCREMENT_FLAG 512		/* field is a autoincrement field */
1976.6.1 by Brian Aker
This is a fix for bug lp:686197
122
#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.
123
#define NO_DEFAULT_VALUE_FLAG 4096	/* Field doesn't have default value */
1 by brian
clean slate
124
#define ON_UPDATE_NOW_FLAG 8192         /* Field is set to NOW on UPDATE */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
125
#define PART_KEY_FLAG	16384		/* Intern; Part of some key */
126
#define GROUP_FLAG	32768		/* Intern: Group field */
127
#define UNIQUE_FLAG	65536		/* Intern: Used by sql_yacc */
128
#define BINCMP_FLAG	131072		/* Intern: Used by sql_yacc */
1 by brian
clean slate
129
#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
130
#define COLUMN_FORMAT_MASK 7
1 by brian
clean slate
131
520.1.28 by Monty Taylor
Reverted too-big formatting change.
132
#define SERVER_STATUS_IN_TRANS     1	/* Transaction has started */
133
#define SERVER_STATUS_AUTOCOMMIT   2	/* Server in auto_commit mode */
1 by brian
clean slate
134
#define SERVER_MORE_RESULTS_EXISTS 8    /* Multi query - next query exists */
135
#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
136
#define SERVER_QUERY_NO_INDEX_USED      32
137
#define SERVER_STATUS_DB_DROPPED        256 /* A database was dropped */
138
520.1.28 by Monty Taylor
Reverted too-big formatting change.
139
#define DRIZZLE_ERRMSG_SIZE	512
1 by brian
clean slate
140
141
#define ONLY_KILL_QUERY         1
142
143
#define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
144
#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.
145
#define MAX_BLOB_WIDTH		(uint32_t)16777216	/* Default width for blob */
1 by brian
clean slate
146
264.2.4 by Andrey Hristov
Remove support for the old, pre-4.1, protocol
147
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
148
149
1 by brian
clean slate
150
151
1816.2.4 by Monty Taylor
Cleaned up a bunch more warnings.
152
#define packet_error UINT32_MAX
1 by brian
clean slate
153
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
154
#if defined(__cplusplus)
155
156
namespace drizzled
157
{
158
159
enum enum_server_command
160
{
161
  COM_SLEEP,
162
  COM_QUIT,
2312.1.2 by Brian Aker
Just a shuffle so that INIT_DB enum makes a bit more sense when you read it.
163
  COM_USE_SCHEMA,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
164
  COM_QUERY,
165
  COM_SHUTDOWN,
166
  COM_CONNECT,
167
  COM_PING,
2191.1.1 by Brian Aker
Add in KILL protocol support.
168
  COM_KILL,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
169
  /* don't forget to update const char *command_name[] in sql_parse.cc */
170
  /* Must be last */
171
  COM_END
172
};
173
174
1921.4.2 by Brian Aker
Adding in concurrent execute support.
175
enum enum_field_types { 
176
                        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...
177
                        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
178
                        DRIZZLE_TYPE_NULL,
179
                        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...
180
                        DRIZZLE_TYPE_LONGLONG,
181
                        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
182
                        DRIZZLE_TYPE_DATE,
183
                        DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
184
                        DRIZZLE_TYPE_DECIMAL,
520.1.25 by Monty Taylor
Removed the split.
185
                        DRIZZLE_TYPE_ENUM,
186
                        DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
187
                        DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
188
                        DRIZZLE_TYPE_BOOLEAN,
2046.2.1 by Brian Aker
First pass on micro timestamp.
189
                        DRIZZLE_TYPE_UUID,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
190
                        DRIZZLE_TYPE_MICROTIME,
191
                        DRIZZLE_TYPE_IPV6
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...
192
};
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
193
const int enum_field_types_size= DRIZZLE_TYPE_IPV6 + 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...
194
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
195
} /* namespace drizzled */
196
197
#endif /* defined(__cplusplus) */
1 by brian
clean slate
198