~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
80
/**
520.1.28 by Monty Taylor
Reverted too-big formatting change.
81
  Maximum length of time zone name that we support
82
  (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
83
*/
84
#define MAX_TIME_ZONE_NAME_LENGTH       (NAME_LEN + 1)
85
1 by brian
clean slate
86
#define HOSTNAME_LENGTH 60
87
#define SYSTEM_CHARSET_MBMAXLEN 4
575.4.7 by Monty Taylor
More header cleanup.
88
#define USERNAME_CHAR_LENGTH 16
1 by brian
clean slate
89
#define NAME_CHAR_LEN	64              /* Field/table name length */
90
#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
91
#define MAXIMUM_IDENTIFIER_LENGTH NAME_LEN
1 by brian
clean slate
92
#define USERNAME_LENGTH         (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
93
94
#define SERVER_VERSION_LENGTH 60
95
#define SQLSTATE_LENGTH 5
96
97
/*
98
  USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
99
  username and hostname parts of the user identifier with trailing zero in
100
  MySQL standard format:
101
  user_name_part@host_name_part\0
102
*/
103
#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
104
105
/*
106
  You should add new commands to the end of this list, otherwise old
107
  servers won't be able to handle them as 'unsupported'.
108
*/
109
110
/*
111
  Length of random string sent by server on handshake; this is also length of
112
  obfuscated password, recieved from client
113
*/
114
#define SCRAMBLE_LENGTH 20
115
#define SCRAMBLE_LENGTH_323 8
116
520.1.28 by Monty Taylor
Reverted too-big formatting change.
117
#define NOT_NULL_FLAG	1		/* Field can't be NULL */
118
#define PRI_KEY_FLAG	2		/* Field is part of a primary key */
119
#define UNIQUE_KEY_FLAG 4		/* Field is part of a unique key */
120
#define MULTIPLE_KEY_FLAG 8		/* Field is part of a key */
121
#define BLOB_FLAG	16		/* Field is a blob */
122
#define UNSIGNED_FLAG	32		/* Field is unsigned */
123
#define BINARY_FLAG	128		/* Field is binary   */
1 by brian
clean slate
124
125
/* The following are only sent to new clients */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
126
#define ENUM_FLAG	256		/* field is an enum */
127
#define AUTO_INCREMENT_FLAG 512		/* field is a autoincrement field */
1976.6.1 by Brian Aker
This is a fix for bug lp:686197
128
#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.
129
#define NO_DEFAULT_VALUE_FLAG 4096	/* Field doesn't have default value */
1 by brian
clean slate
130
#define ON_UPDATE_NOW_FLAG 8192         /* Field is set to NOW on UPDATE */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
131
#define PART_KEY_FLAG	16384		/* Intern; Part of some key */
132
#define GROUP_FLAG	32768		/* Intern: Group field */
133
#define UNIQUE_FLAG	65536		/* Intern: Used by sql_yacc */
134
#define BINCMP_FLAG	131072		/* Intern: Used by sql_yacc */
1 by brian
clean slate
135
#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
136
#define COLUMN_FORMAT_MASK 7
1 by brian
clean slate
137
520.1.28 by Monty Taylor
Reverted too-big formatting change.
138
#define SERVER_STATUS_IN_TRANS     1	/* Transaction has started */
139
#define SERVER_STATUS_AUTOCOMMIT   2	/* Server in auto_commit mode */
1 by brian
clean slate
140
#define SERVER_MORE_RESULTS_EXISTS 8    /* Multi query - next query exists */
141
#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
142
#define SERVER_QUERY_NO_INDEX_USED      32
143
#define SERVER_STATUS_DB_DROPPED        256 /* A database was dropped */
144
520.1.28 by Monty Taylor
Reverted too-big formatting change.
145
#define DRIZZLE_ERRMSG_SIZE	512
1 by brian
clean slate
146
147
#define ONLY_KILL_QUERY         1
148
149
#define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
150
#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.
151
#define MAX_BLOB_WIDTH		(uint32_t)16777216	/* Default width for blob */
1 by brian
clean slate
152
264.2.4 by Andrey Hristov
Remove support for the old, pre-4.1, protocol
153
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
154
155
1 by brian
clean slate
156
157
1816.2.4 by Monty Taylor
Cleaned up a bunch more warnings.
158
#define packet_error UINT32_MAX
1 by brian
clean slate
159
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
160
#if defined(__cplusplus)
161
162
namespace drizzled
163
{
164
165
enum enum_server_command
166
{
167
  COM_SLEEP,
168
  COM_QUIT,
169
  COM_INIT_DB,
170
  COM_QUERY,
171
  COM_SHUTDOWN,
172
  COM_CONNECT,
173
  COM_PING,
2191.1.1 by Brian Aker
Add in KILL protocol support.
174
  COM_KILL,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
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,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
194
                        DRIZZLE_TYPE_BOOLEAN,
2046.2.1 by Brian Aker
First pass on micro timestamp.
195
                        DRIZZLE_TYPE_UUID,
196
                        DRIZZLE_TYPE_MICROTIME
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
};
2046.2.1 by Brian Aker
First pass on micro timestamp.
198
const int enum_field_types_size= DRIZZLE_TYPE_MICROTIME + 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...
199
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
200
} /* namespace drizzled */
201
202
#endif /* defined(__cplusplus) */
1 by brian
clean slate
203