~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
540 by Monty Taylor
Moved drizzle_com to drizzled/drizzle_common. Started splitting it up.
24
#ifndef DRIZZLED_DRIZZLE_COMMON_H
542 by Monty Taylor
Cleaned up the last commit.
25
#define DRIZZLED_DRIZZLE_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 OPTION_LOG_OFF          (UINT64_C(1) << 10)    // THD, user
59
#define TMP_TABLE_ALL_COLUMNS   (UINT64_C(1) << 12)    // SELECT, intern
60
#define OPTION_WARNINGS         (UINT64_C(1) << 13)    // THD, user
61
#define OPTION_AUTO_IS_NULL     (UINT64_C(1) << 14)    // THD, user, binlog
62
#define OPTION_FOUND_COMMENT    (UINT64_C(1) << 15)    // SELECT, intern, parser
63
#define OPTION_SAFE_UPDATES     (UINT64_C(1) << 16)    // THD, user
64
#define OPTION_BUFFER_RESULT    (UINT64_C(1) << 17)    // SELECT, user
65
#define OPTION_NOT_AUTOCOMMIT   (UINT64_C(1) << 19)    // THD, user
66
#define OPTION_BEGIN            (UINT64_C(1) << 20)    // THD, intern
67
#define OPTION_QUICK            (UINT64_C(1) << 22)    // SELECT (for DELETE)
68
#define OPTION_KEEP_LOG         (UINT64_C(1) << 23)    // THD, user
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
69
70
/* The following is used to detect a conflict with DISTINCT */
779.3.53 by Monty Taylor
Revert the fail.
71
#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
72
73
/** The following can be set when importing tables in a 'wrong order'
520.1.28 by Monty Taylor
Reverted too-big formatting change.
74
   to suppress foreign key checks */
779.3.53 by Monty Taylor
Revert the fail.
75
#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
76
/** The following speeds up inserts to InnoDB tables by suppressing unique
520.1.28 by Monty Taylor
Reverted too-big formatting change.
77
   key checks in some cases */
779.3.53 by Monty Taylor
Revert the fail.
78
#define OPTION_RELAXED_UNIQUE_CHECKS    (UINT64_C(1) << 27) // THD, user, binlog
79
#define SELECT_NO_UNLOCK                (UINT64_C(1) << 28) // SELECT, intern
80
#define OPTION_SCHEMA_TABLE             (UINT64_C(1) << 29) // SELECT, intern
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
81
/** Flag set if setup_tables already done */
779.3.53 by Monty Taylor
Revert the fail.
82
#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
83
/** If not set then the thread will ignore all warnings with level notes. */
779.3.53 by Monty Taylor
Revert the fail.
84
#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
85
/**
520.1.28 by Monty Taylor
Reverted too-big formatting change.
86
  Force the used temporary table to be a MyISAM table (because we will use
87
  fulltext functions when reading from it.
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
88
*/
422 by Monty
Various int64 constant fixes.
89
#define TMP_TABLE_FORCE_MYISAM          (UINT64_C(1) << 32)
90
#define OPTION_PROFILING                (UINT64_C(1) << 33)
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
91
92
/*
93
  Dont report errors for individual rows,
94
  But just report error on commit (or read ofcourse)
95
*/
422 by Monty
Various int64 constant fixes.
96
#define OPTION_ALLOW_BATCH              (UINT64_C(1) << 33) // THD, intern (slave)
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
97
98
/**
520.1.28 by Monty Taylor
Reverted too-big formatting change.
99
  Maximum length of time zone name that we support
100
  (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
101
*/
102
#define MAX_TIME_ZONE_NAME_LENGTH       (NAME_LEN + 1)
103
1 by brian
clean slate
104
#define HOSTNAME_LENGTH 60
105
#define SYSTEM_CHARSET_MBMAXLEN 4
575.4.7 by Monty Taylor
More header cleanup.
106
#define USERNAME_CHAR_LENGTH 16
1 by brian
clean slate
107
#define NAME_CHAR_LEN	64              /* Field/table name length */
108
#define NAME_LEN                (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
109
#define USERNAME_LENGTH         (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
110
111
#define SERVER_VERSION_LENGTH 60
112
#define SQLSTATE_LENGTH 5
113
114
/*
115
  Maximum length of comments
116
*/
117
#define TABLE_COMMENT_MAXLEN 2048
118
#define COLUMN_COMMENT_MAXLEN 1024
119
#define INDEX_COMMENT_MAXLEN 1024
120
121
/*
122
  USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
123
  username and hostname parts of the user identifier with trailing zero in
124
  MySQL standard format:
125
  user_name_part@host_name_part\0
126
*/
127
#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
128
129
#define LOCAL_HOST	"localhost"
130
#define LOCAL_HOST_NAMEDPIPE "."
131
132
/*
133
  You should add new commands to the end of this list, otherwise old
134
  servers won't be able to handle them as 'unsupported'.
135
*/
136
137
enum enum_server_command
138
{
923.1.8 by Brian Aker
Remove final dead COM bits.
139
  COM_SLEEP,
140
  COM_QUIT,
141
  COM_INIT_DB,
142
  COM_QUERY,
143
  COM_SHUTDOWN,
144
  COM_CONNECT,
145
  COM_PING,
1 by brian
clean slate
146
  /* don't forget to update const char *command_name[] in sql_parse.cc */
147
  /* Must be last */
148
  COM_END
149
};
150
151
152
/*
153
  Length of random string sent by server on handshake; this is also length of
154
  obfuscated password, recieved from client
155
*/
156
#define SCRAMBLE_LENGTH 20
157
#define SCRAMBLE_LENGTH_323 8
158
/* length of password stored in the db: new passwords are preceeded with '*' */
159
#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
160
#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
161
162
520.1.28 by Monty Taylor
Reverted too-big formatting change.
163
#define NOT_NULL_FLAG	1		/* Field can't be NULL */
164
#define PRI_KEY_FLAG	2		/* Field is part of a primary key */
165
#define UNIQUE_KEY_FLAG 4		/* Field is part of a unique key */
166
#define MULTIPLE_KEY_FLAG 8		/* Field is part of a key */
167
#define BLOB_FLAG	16		/* Field is a blob */
168
#define UNSIGNED_FLAG	32		/* Field is unsigned */
169
#define BINARY_FLAG	128		/* Field is binary   */
1 by brian
clean slate
170
171
/* The following are only sent to new clients */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
172
#define ENUM_FLAG	256		/* field is an enum */
173
#define AUTO_INCREMENT_FLAG 512		/* field is a autoincrement field */
174
#define TIMESTAMP_FLAG	1024		/* Field is a timestamp */
175
#define SET_FLAG	2048		/* field is a set */
176
#define NO_DEFAULT_VALUE_FLAG 4096	/* Field doesn't have default value */
1 by brian
clean slate
177
#define ON_UPDATE_NOW_FLAG 8192         /* Field is set to NOW on UPDATE */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
178
#define NUM_FLAG	32768		/* Field is num (for clients) */
179
#define PART_KEY_FLAG	16384		/* Intern; Part of some key */
180
#define GROUP_FLAG	32768		/* Intern: Group field */
181
#define UNIQUE_FLAG	65536		/* Intern: Used by sql_yacc */
182
#define BINCMP_FLAG	131072		/* Intern: Used by sql_yacc */
1 by brian
clean slate
183
#define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
184
#define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
185
#define FIELD_IN_ADD_INDEX (1<< 20)	/* Intern: Field used in ADD INDEX */
1 by brian
clean slate
186
#define FIELD_IS_RENAMED (1<< 21)       /* Intern: Field is being renamed */
187
#define FIELD_STORAGE_FLAGS 22          /* Storage type: bit 22, 23 and 24 */
188
#define COLUMN_FORMAT_FLAGS 25          /* Column format: bit 25, 26 and 27 */
189
520.1.28 by Monty Taylor
Reverted too-big formatting change.
190
#define REFRESH_LOG		2	/* Start on new log file */
191
#define REFRESH_TABLES		4	/* close all tables */
192
#define REFRESH_STATUS		16	/* Flush status variables */
1 by brian
clean slate
193
194
/* The following can't be set with mysql_refresh() */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
195
#define REFRESH_READ_LOCK	16384	/* Lock tables for read */
196
#define REFRESH_FAST		32768	/* Intern flag */
1 by brian
clean slate
197
520.1.28 by Monty Taylor
Reverted too-big formatting change.
198
#define SERVER_STATUS_IN_TRANS     1	/* Transaction has started */
199
#define SERVER_STATUS_AUTOCOMMIT   2	/* Server in auto_commit mode */
1 by brian
clean slate
200
#define SERVER_MORE_RESULTS_EXISTS 8    /* Multi query - next query exists */
201
#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
202
#define SERVER_QUERY_NO_INDEX_USED      32
203
/*
204
  The server was able to fulfill the clients request and opened a
205
  read-only non-scrollable cursor for a query. This flag comes
206
  in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
207
*/
208
#define SERVER_STATUS_CURSOR_EXISTS 64
209
/*
210
  This flag is sent when a read-only cursor is exhausted, in reply to
211
  COM_STMT_FETCH command.
212
*/
213
#define SERVER_STATUS_LAST_ROW_SENT 128
214
#define SERVER_STATUS_DB_DROPPED        256 /* A database was dropped */
215
#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
216
/*
217
  Tell clients that this query was logged to the slow query log.
218
  Not yet set in the server, but interface is defined for applications
219
  to use.  See WorkLog 4098.
220
*/
221
#define SERVER_QUERY_WAS_SLOW           1024
222
520.1.28 by Monty Taylor
Reverted too-big formatting change.
223
#define DRIZZLE_ERRMSG_SIZE	512
1 by brian
clean slate
224
225
#define ONLY_KILL_QUERY         1
226
227
#define MAX_TINYINT_WIDTH       3       /* Max width for a TINY w.o. sign */
228
#define MAX_SMALLINT_WIDTH      5       /* Max width for a SHORT w.o. sign */
229
#define MAX_MEDIUMINT_WIDTH     8       /* Max width for a INT24 w.o. sign */
230
#define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
231
#define MAX_BIGINT_WIDTH        20      /* Max width for a LONGLONG */
520.1.28 by Monty Taylor
Reverted too-big formatting change.
232
#define MAX_CHAR_WIDTH		255	/* Max length for a CHAR colum */
937.2.6 by Stewart Smith
make set_if_bigger typesafe for C and C++. Fix up everywhere.
233
#define MAX_BLOB_WIDTH		(uint32_t)16777216	/* Default width for blob */
1 by brian
clean slate
234
264.2.4 by Andrey Hristov
Remove support for the old, pre-4.1, protocol
235
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
236
237
1 by brian
clean slate
238
239
77.1.78 by Monty Taylor
One last bunch of warnings edits.
240
#define packet_error (~(uint32_t) 0)
1 by brian
clean slate
241
242
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
243
/* Shutdown/kill enums and constants */
1 by brian
clean slate
244
245
/* Bits for THD::killable. */
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
246
#define DRIZZLE_SHUTDOWN_KILLABLE_CONNECT    (unsigned char)(1 << 0)
247
#define DRIZZLE_SHUTDOWN_KILLABLE_TRANS      (unsigned char)(1 << 1)
248
#define DRIZZLE_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
249
#define DRIZZLE_SHUTDOWN_KILLABLE_UPDATE     (unsigned char)(1 << 3)
1 by brian
clean slate
250
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...
251
/* Start TINY at 1 because we removed DECIMAL from off the front of the enum */
520.1.24 by Monty Taylor
Fixed the TINY=1 bit.
252
enum enum_field_types { DRIZZLE_TYPE_TINY,
398 by Brian Aker
Remove short.
253
                        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...
254
                        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
255
                        DRIZZLE_TYPE_NULL,
256
                        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...
257
                        DRIZZLE_TYPE_LONGLONG,
258
                        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
259
                        DRIZZLE_TYPE_DATE,
260
                        DRIZZLE_TYPE_VARCHAR,
520.1.25 by Monty Taylor
Removed the split.
261
                        DRIZZLE_TYPE_NEWDECIMAL,
262
                        DRIZZLE_TYPE_ENUM,
263
                        DRIZZLE_TYPE_BLOB,
264
                        DRIZZLE_TYPE_MAX=DRIZZLE_TYPE_BLOB
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...
265
};
266
1 by brian
clean slate
267
520.1.28 by Monty Taylor
Reverted too-big formatting change.
268
  /* The following is for user defined functions */
1 by brian
clean slate
269
270
enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
271
                  DECIMAL_RESULT};
272
273
typedef struct st_udf_args
274
{
520.1.28 by Monty Taylor
Reverted too-big formatting change.
275
  unsigned int arg_count;		/* Number of arguments */
276
  enum Item_result *arg_type;		/* Pointer to item_results */
277
  char **args;				/* Pointer to argument */
278
  unsigned long *lengths;		/* Length of string arguments */
279
  char *maybe_null;			/* Set to 1 for all maybe_null args */
1 by brian
clean slate
280
  char **attributes;                    /* Pointer to attribute name */
281
  unsigned long *attribute_lengths;     /* Length of attribute arguments */
282
  void *extension;
283
} UDF_ARGS;
284
520.1.28 by Monty Taylor
Reverted too-big formatting change.
285
  /* This holds information about the result */
1 by brian
clean slate
286
287
typedef struct st_udf_init
288
{
277 by Brian Aker
Cleanup of my_bool from extra and libdrizzle
289
  bool maybe_null;          /* 1 if function can return NULL */
1 by brian
clean slate
290
  unsigned int decimals;       /* for real functions */
291
  unsigned long max_length;    /* For string functions */
292
  char *ptr;                   /* free pointer for function data */
277 by Brian Aker
Cleanup of my_bool from extra and libdrizzle
293
  bool const_item;          /* 1 if function always returns the same value */
1 by brian
clean slate
294
  void *extension;
295
} UDF_INIT;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
296
/*
297
  TODO: add a notion for determinism of the UDF.
1 by brian
clean slate
298
  See Item_udf_func::update_used_tables ()
299
*/
300
520.1.28 by Monty Taylor
Reverted too-big formatting change.
301
  /* Constants when using compression */
302
#define NET_HEADER_SIZE 4		/* standard header size */
303
#define COMP_HEADER_SIZE 3		/* compression header extra size */
1 by brian
clean slate
304
305
#endif