~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/drizzle_com.h

  • Committer: Monty Taylor
  • Date: 2008-08-01 23:59:59 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080801235959-n8ypy9r5aohown77
Gettext error compiles and passes test!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 MySQL
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
9
10
 *
10
11
 *  This program is distributed in the hope that it will be useful,
11
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
22
** Common definition between mysql server & client
22
23
*/
23
24
 
24
 
#ifndef DRIZZLED_COMMON_H
25
 
#define DRIZZLED_COMMON_H
26
 
 
27
 
#include <unistd.h>
28
 
#include <stdint.h>
29
 
#include <drizzled/korr.h>
30
 
 
31
 
/*
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:
41
 
   SELECT - Select_Lex_Node::options
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.
47
 
*/
48
 
 
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
65
 
 
66
 
/* The following is used to detect a conflict with DISTINCT */
67
 
#define SELECT_ALL              (UINT64_C(1) << 24)    // SELECT, user, parser
68
 
 
69
 
/** The following can be set when importing tables in a 'wrong order'
70
 
   to suppress foreign key checks */
71
 
#define OPTION_NO_FOREIGN_KEY_CHECKS    (UINT64_C(1) << 26) // THD, user, binlog
72
 
/** The following speeds up inserts to InnoDB tables by suppressing unique
73
 
   key checks in some cases */
74
 
#define OPTION_RELAXED_UNIQUE_CHECKS    (UINT64_C(1) << 27) // THD, user, binlog
75
 
#define SELECT_NO_UNLOCK                (UINT64_C(1) << 28) // SELECT, intern
76
 
/** Flag set if setup_tables already done */
77
 
#define OPTION_SETUP_TABLES_DONE        (UINT64_C(1) << 30) // intern
78
 
/** If not set then the thread will ignore all warnings with level notes. */
79
 
#define OPTION_SQL_NOTES                (UINT64_C(1) << 31) // THD, user
80
 
 
81
 
/**
82
 
  Maximum length of time zone name that we support
83
 
  (Time zone name is char(64) in db). mysqlbinlog needs it.
84
 
*/
85
 
#define MAX_TIME_ZONE_NAME_LENGTH       (NAME_LEN + 1)
 
25
#ifndef _libdrizzle_drizzle_com_h
 
26
#define _libdrizzle_drizzle_com_h
86
27
 
87
28
#define HOSTNAME_LENGTH 60
88
29
#define SYSTEM_CHARSET_MBMAXLEN 4
 
30
#define NAME_CHAR_LEN   64              /* Field/table name length */
89
31
#define USERNAME_CHAR_LENGTH 16
90
 
#define NAME_CHAR_LEN   64              /* Field/table name length */
91
32
#define NAME_LEN                (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
92
 
#define MAXIMUM_IDENTIFIER_LENGTH NAME_LEN
93
33
#define USERNAME_LENGTH         (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
94
34
 
95
35
#define SERVER_VERSION_LENGTH 60
96
36
#define SQLSTATE_LENGTH 5
97
37
 
98
38
/*
 
39
  Maximum length of comments
 
40
*/
 
41
#define TABLE_COMMENT_MAXLEN 2048
 
42
#define COLUMN_COMMENT_MAXLEN 1024
 
43
#define INDEX_COMMENT_MAXLEN 1024
 
44
 
 
45
 
 
46
/*
99
47
  USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
100
48
  username and hostname parts of the user identifier with trailing zero in
101
49
  MySQL standard format:
103
51
*/
104
52
#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
105
53
 
 
54
#define LOCAL_HOST      "localhost"
 
55
#define LOCAL_HOST_NAMEDPIPE "."
 
56
 
106
57
/*
107
58
  You should add new commands to the end of this list, otherwise old
108
59
  servers won't be able to handle them as 'unsupported'.
109
60
*/
110
61
 
 
62
enum enum_server_command
 
63
{
 
64
  COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
 
65
  COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS,
 
66
  COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_PING,
 
67
  COM_TIME, COM_CHANGE_USER, COM_BINLOG_DUMP,
 
68
  COM_CONNECT_OUT, COM_REGISTER_SLAVE,
 
69
  COM_SET_OPTION, COM_DAEMON,
 
70
  /* don't forget to update const char *command_name[] in sql_parse.cc */
 
71
 
 
72
  /* Must be last */
 
73
  COM_END
 
74
};
 
75
 
 
76
 
111
77
/*
112
78
  Length of random string sent by server on handshake; this is also length of
113
79
  obfuscated password, recieved from client
114
80
*/
115
81
#define SCRAMBLE_LENGTH 20
116
82
#define SCRAMBLE_LENGTH_323 8
 
83
/* length of password stored in the db: new passwords are preceeded with '*' */
 
84
#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
 
85
#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
 
86
 
117
87
 
118
88
#define NOT_NULL_FLAG   1               /* Field can't be NULL */
119
89
#define PRI_KEY_FLAG    2               /* Field is part of a primary key */
121
91
#define MULTIPLE_KEY_FLAG 8             /* Field is part of a key */
122
92
#define BLOB_FLAG       16              /* Field is a blob */
123
93
#define UNSIGNED_FLAG   32              /* Field is unsigned */
 
94
#define DECIMAL_FLAG    64              /* Field is zerofill */
124
95
#define BINARY_FLAG     128             /* Field is binary   */
125
96
 
126
97
/* The following are only sent to new clients */
127
98
#define ENUM_FLAG       256             /* field is an enum */
128
99
#define AUTO_INCREMENT_FLAG 512         /* field is a autoincrement field */
129
100
#define TIMESTAMP_FLAG  1024            /* Field is a timestamp */
 
101
#define SET_FLAG        2048            /* field is a set */
130
102
#define NO_DEFAULT_VALUE_FLAG 4096      /* Field doesn't have default value */
131
103
#define ON_UPDATE_NOW_FLAG 8192         /* Field is set to NOW on UPDATE */
 
104
#define NUM_FLAG        32768           /* Field is num (for clients) */
132
105
#define PART_KEY_FLAG   16384           /* Intern; Part of some key */
133
106
#define GROUP_FLAG      32768           /* Intern: Group field */
134
107
#define UNIQUE_FLAG     65536           /* Intern: Used by sql_yacc */
135
108
#define BINCMP_FLAG     131072          /* Intern: Used by sql_yacc */
 
109
#define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
 
110
#define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
 
111
#define FIELD_IN_ADD_INDEX (1<< 20)     /* Intern: Field used in ADD INDEX */
 
112
#define FIELD_IS_RENAMED (1<< 21)       /* Intern: Field is being renamed */
 
113
#define FIELD_STORAGE_FLAGS 22          /* Storage type: bit 22, 23 and 24 */
136
114
#define COLUMN_FORMAT_FLAGS 25          /* Column format: bit 25, 26 and 27 */
137
 
#define COLUMN_FORMAT_MASK 7
 
115
 
 
116
#define REFRESH_GRANT           1       /* Refresh grant tables */
 
117
#define REFRESH_LOG             2       /* Start on new log file */
 
118
#define REFRESH_TABLES          4       /* close all tables */
 
119
#define REFRESH_HOSTS           8       /* Flush host cache */
 
120
#define REFRESH_STATUS          16      /* Flush status variables */
 
121
#define REFRESH_THREADS         32      /* Flush thread cache */
 
122
#define REFRESH_SLAVE           64      /* Reset master info and restart slave
 
123
                                           thread */
 
124
#define REFRESH_MASTER          128     /* Remove all bin logs in the index
 
125
                                           and truncate the index */
 
126
 
 
127
/* The following can't be set with mysql_refresh() */
 
128
#define REFRESH_READ_LOCK       16384   /* Lock tables for read */
 
129
#define REFRESH_FAST            32768   /* Intern flag */
 
130
 
 
131
/* RESET (remove all queries) from query cache */
 
132
#define REFRESH_QUERY_CACHE     65536
 
133
#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
 
134
#define REFRESH_DES_KEY_FILE    0x40000L
 
135
#define REFRESH_USER_RESOURCES  0x80000L
 
136
 
 
137
#define CLIENT_LONG_PASSWORD    1       /* new more secure passwords */
 
138
#define CLIENT_FOUND_ROWS       2       /* Found instead of affected rows */
 
139
#define CLIENT_LONG_FLAG        4       /* Get all column flags */
 
140
#define CLIENT_CONNECT_WITH_DB  8       /* One can specify db on connect */
 
141
#define CLIENT_NO_SCHEMA        16      /* Don't allow database.table.column */
 
142
#define CLIENT_COMPRESS         32      /* Can use compression protocol */
 
143
#define CLIENT_ODBC             64      /* Odbc client */
 
144
#define CLIENT_LOCAL_FILES      128     /* Can use LOAD DATA LOCAL */
 
145
#define CLIENT_IGNORE_SPACE     256     /* Ignore spaces before '(' */
 
146
#define CLIENT_PROTOCOL_41      512     /* New 4.1 protocol */
 
147
#define CLIENT_INTERACTIVE      1024    /* This is an interactive client */
 
148
#define CLIENT_SSL              2048    /* Switch to SSL after handshake */
 
149
#define CLIENT_IGNORE_SIGPIPE   4096    /* IGNORE sigpipes */
 
150
#define CLIENT_TRANSACTIONS     8192    /* Client knows about transactions */
 
151
#define CLIENT_RESERVED         16384   /* Old flag for 4.1 protocol  */
 
152
#define CLIENT_SECURE_CONNECTION 32768  /* New 4.1 authentication */
 
153
#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
 
154
#define CLIENT_MULTI_RESULTS    (1UL << 17) /* Enable/disable multi-results */
 
155
 
 
156
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
 
157
#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
 
158
 
 
159
/* Gather all possible capabilites (flags) supported by the server */
 
160
#define CLIENT_ALL_FLAGS  (CLIENT_LONG_PASSWORD | \
 
161
                           CLIENT_FOUND_ROWS | \
 
162
                           CLIENT_LONG_FLAG | \
 
163
                           CLIENT_CONNECT_WITH_DB | \
 
164
                           CLIENT_NO_SCHEMA | \
 
165
                           CLIENT_COMPRESS | \
 
166
                           CLIENT_ODBC | \
 
167
                           CLIENT_LOCAL_FILES | \
 
168
                           CLIENT_IGNORE_SPACE | \
 
169
                           CLIENT_PROTOCOL_41 | \
 
170
                           CLIENT_INTERACTIVE | \
 
171
                           CLIENT_SSL | \
 
172
                           CLIENT_IGNORE_SIGPIPE | \
 
173
                           CLIENT_TRANSACTIONS | \
 
174
                           CLIENT_RESERVED | \
 
175
                           CLIENT_SECURE_CONNECTION | \
 
176
                           CLIENT_MULTI_STATEMENTS | \
 
177
                           CLIENT_MULTI_RESULTS | \
 
178
                           CLIENT_SSL_VERIFY_SERVER_CERT | \
 
179
                           CLIENT_REMEMBER_OPTIONS)
 
180
 
 
181
/*
 
182
  Switch off the flags that are optional and depending on build flags
 
183
  If any of the optional flags is supported by the build it will be switched
 
184
  on before sending to the client during the connection handshake.
 
185
*/
 
186
#define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \
 
187
                                               & ~CLIENT_COMPRESS) \
 
188
                                               & ~CLIENT_SSL_VERIFY_SERVER_CERT)
138
189
 
139
190
#define SERVER_STATUS_IN_TRANS     1    /* Transaction has started */
140
191
#define SERVER_STATUS_AUTOCOMMIT   2    /* Server in auto_commit mode */
141
192
#define SERVER_MORE_RESULTS_EXISTS 8    /* Multi query - next query exists */
142
193
#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
143
194
#define SERVER_QUERY_NO_INDEX_USED      32
 
195
/*
 
196
  The server was able to fulfill the clients request and opened a
 
197
  read-only non-scrollable cursor for a query. This flag comes
 
198
  in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
 
199
*/
 
200
#define SERVER_STATUS_CURSOR_EXISTS 64
 
201
/*
 
202
  This flag is sent when a read-only cursor is exhausted, in reply to
 
203
  COM_STMT_FETCH command.
 
204
*/
 
205
#define SERVER_STATUS_LAST_ROW_SENT 128
144
206
#define SERVER_STATUS_DB_DROPPED        256 /* A database was dropped */
 
207
#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
 
208
/*
 
209
  Tell clients that this query was logged to the slow query log.
 
210
  Not yet set in the server, but interface is defined for applications
 
211
  to use.  See WorkLog 4098.
 
212
*/
 
213
#define SERVER_QUERY_WAS_SLOW           1024
145
214
 
146
 
#define DRIZZLE_ERRMSG_SIZE     512
 
215
#define MYSQL_ERRMSG_SIZE       512
 
216
#define NET_READ_TIMEOUT        30              /* Timeout on read */
 
217
#define NET_WRITE_TIMEOUT       60              /* Timeout on write */
 
218
#define NET_WAIT_TIMEOUT        8*60*60         /* Wait for new query */
147
219
 
148
220
#define ONLY_KILL_QUERY         1
149
221
 
 
222
struct st_vio;                                  /* Only C */
 
223
typedef struct st_vio Vio;
 
224
 
 
225
#define MAX_TINYINT_WIDTH       3       /* Max width for a TINY w.o. sign */
 
226
#define MAX_SMALLINT_WIDTH      5       /* Max width for a SHORT w.o. sign */
 
227
#define MAX_MEDIUMINT_WIDTH     8       /* Max width for a INT24 w.o. sign */
150
228
#define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
151
229
#define MAX_BIGINT_WIDTH        20      /* Max width for a LONGLONG */
152
 
#define MAX_BLOB_WIDTH          (uint32_t)16777216      /* Default width for blob */
153
 
 
154
 
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
155
 
 
156
 
 
 
230
#define MAX_CHAR_WIDTH          255     /* Max length for a CHAR colum */
 
231
#define MAX_BLOB_WIDTH          16777216        /* Default width for blob */
 
232
 
 
233
typedef struct st_net {
 
234
  Vio *vio;
 
235
  unsigned char *buff,*buff_end,*write_pos,*read_pos;
 
236
  my_socket fd;                                 /* For Perl DBI/dbd */
 
237
  /*
 
238
    The following variable is set if we are doing several queries in one
 
239
    command ( as in LOAD TABLE ... FROM MASTER ),
 
240
    and do not want to confuse the client with OK at the wrong time
 
241
  */
 
242
  unsigned long remain_in_buf,length, buf_length, where_b;
 
243
  unsigned long max_packet,max_packet_size;
 
244
  unsigned int pkt_nr,compress_pkt_nr;
 
245
  unsigned int write_timeout;
 
246
  unsigned int read_timeout;
 
247
  unsigned int retry_count;
 
248
  int fcntl;
 
249
  unsigned int *return_status;
 
250
  unsigned char reading_or_writing;
 
251
  char save_char;
 
252
  my_bool compress;
 
253
  /*
 
254
    Pointer to query object in query cache, do not equal NULL (0) for
 
255
    queries in cache that have not stored its results yet
 
256
  */
 
257
  /*
 
258
    Unused, please remove with the next incompatible ABI change.
 
259
  */
 
260
  unsigned char *unused;
 
261
  unsigned int last_errno;
 
262
  unsigned char error; 
 
263
  /** Client library error message buffer. Actually belongs to struct MYSQL. */
 
264
  char last_error[MYSQL_ERRMSG_SIZE];
 
265
  /** Client library sqlstate buffer. Set along with the error message. */
 
266
  char sqlstate[SQLSTATE_LENGTH+1];
 
267
  void *extension;
 
268
} NET;
157
269
 
158
270
 
159
271
#define packet_error (~(uint32_t) 0)
160
272
 
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
 
 
181
 
enum enum_field_types { DRIZZLE_TYPE_LONG,
182
 
                        DRIZZLE_TYPE_DOUBLE,
183
 
                        DRIZZLE_TYPE_NULL,
184
 
                        DRIZZLE_TYPE_TIMESTAMP,
185
 
                        DRIZZLE_TYPE_LONGLONG,
186
 
                        DRIZZLE_TYPE_DATETIME,
187
 
                        DRIZZLE_TYPE_DATE,
188
 
                        DRIZZLE_TYPE_VARCHAR,
189
 
                        DRIZZLE_TYPE_DECIMAL,
190
 
                        DRIZZLE_TYPE_ENUM,
191
 
                        DRIZZLE_TYPE_BLOB,
192
 
                        DRIZZLE_TYPE_MAX=DRIZZLE_TYPE_BLOB
193
 
};
194
 
 
195
 
} /* namespace drizzled */
196
 
 
197
 
#endif /* defined(__cplusplus) */
198
 
 
199
 
#endif /* DRIZZLED_COMMON_H */
 
273
/* Start TINY at 1 because we removed DECIMAL from off the front of the enum */
 
274
enum enum_field_types { DRIZZLE_TYPE_TINY=1,
 
275
                        DRIZZLE_TYPE_SHORT,  DRIZZLE_TYPE_LONG,
 
276
                        DRIZZLE_TYPE_DOUBLE,
 
277
                        DRIZZLE_TYPE_NULL,   DRIZZLE_TYPE_TIMESTAMP,
 
278
                        DRIZZLE_TYPE_LONGLONG,
 
279
                        DRIZZLE_TYPE_DATE,   DRIZZLE_TYPE_TIME,
 
280
                        DRIZZLE_TYPE_DATETIME,
 
281
                        DRIZZLE_TYPE_NEWDATE, DRIZZLE_TYPE_VARCHAR,
 
282
                        DRIZZLE_TYPE_NEWDECIMAL=252,
 
283
                        DRIZZLE_TYPE_ENUM=253,
 
284
                        DRIZZLE_TYPE_SET=254,
 
285
                        DRIZZLE_TYPE_BLOB=255
 
286
};
 
287
 
 
288
 
 
289
/* Shutdown/kill enums and constants */ 
 
290
 
 
291
/* Bits for THD::killable. */
 
292
#define MYSQL_SHUTDOWN_KILLABLE_CONNECT    (unsigned char)(1 << 0)
 
293
#define MYSQL_SHUTDOWN_KILLABLE_TRANS      (unsigned char)(1 << 1)
 
294
#define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
 
295
#define MYSQL_SHUTDOWN_KILLABLE_UPDATE     (unsigned char)(1 << 3)
 
296
 
 
297
enum drizzle_enum_shutdown_level {
 
298
  /*
 
299
    We want levels to be in growing order of hardness (because we use number
 
300
    comparisons). Note that DEFAULT does not respect the growing property, but
 
301
    it's ok.
 
302
  */
 
303
  SHUTDOWN_DEFAULT = 0,
 
304
  /* wait for existing connections to finish */
 
305
  SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT,
 
306
  /* wait for existing trans to finish */
 
307
  SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS,
 
308
  /* wait for existing updates to finish (=> no partial MyISAM update) */
 
309
  SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE,
 
310
  /* flush InnoDB buffers and other storage engines' buffers*/
 
311
  SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
 
312
  /* don't flush InnoDB buffers, flush other storage engines' buffers*/
 
313
  SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
 
314
  /* Now the 2 levels of the KILL command */
 
315
  KILL_QUERY= 254,
 
316
  KILL_CONNECTION= 255
 
317
};
 
318
 
 
319
 
 
320
enum enum_cursor_type
 
321
{
 
322
  CURSOR_TYPE_NO_CURSOR= 0,
 
323
  CURSOR_TYPE_READ_ONLY= 1,
 
324
  CURSOR_TYPE_FOR_UPDATE= 2,
 
325
  CURSOR_TYPE_SCROLLABLE= 4
 
326
};
 
327
 
 
328
 
 
329
/* options for mysql_set_option */
 
330
enum enum_drizzle_set_option
 
331
{
 
332
  MYSQL_OPTION_MULTI_STATEMENTS_ON,
 
333
  MYSQL_OPTION_MULTI_STATEMENTS_OFF
 
334
};
 
335
 
 
336
#define net_new_transaction(net) ((net)->pkt_nr=0)
 
337
 
 
338
#ifdef __cplusplus
 
339
extern "C" {
 
340
#endif
 
341
 
 
342
bool    my_net_init(NET *net, Vio* vio);
 
343
void    my_net_local_init(NET *net);
 
344
void    net_end(NET *net);
 
345
void    net_clear(NET *net, bool clear_buffer);
 
346
bool    net_realloc(NET *net, size_t length);
 
347
bool    net_flush(NET *net);
 
348
bool    my_net_write(NET *net,const unsigned char *packet, size_t len);
 
349
bool    net_write_command(NET *net,unsigned char command,
 
350
                          const unsigned char *header, size_t head_len,
 
351
                          const unsigned char *packet, size_t len);
 
352
int32_t net_real_write(NET *net,const unsigned char *packet, size_t len);
 
353
uint32_t my_net_read(NET *net);
 
354
 
 
355
#ifdef _global_h
 
356
void my_net_set_write_timeout(NET *net, uint timeout);
 
357
void my_net_set_read_timeout(NET *net, uint timeout);
 
358
#endif
 
359
 
 
360
struct sockaddr;
 
361
int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
 
362
               unsigned int timeout);
 
363
 
 
364
struct rand_struct {
 
365
  unsigned long seed1,seed2,max_value;
 
366
  double max_value_dbl;
 
367
};
 
368
 
 
369
#ifdef __cplusplus
 
370
}
 
371
#endif
 
372
 
 
373
  /* The following is for user defined functions */
 
374
 
 
375
enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
 
376
                  DECIMAL_RESULT};
 
377
 
 
378
typedef struct st_udf_args
 
379
{
 
380
  unsigned int arg_count;               /* Number of arguments */
 
381
  enum Item_result *arg_type;           /* Pointer to item_results */
 
382
  char **args;                          /* Pointer to argument */
 
383
  unsigned long *lengths;               /* Length of string arguments */
 
384
  char *maybe_null;                     /* Set to 1 for all maybe_null args */
 
385
  char **attributes;                    /* Pointer to attribute name */
 
386
  unsigned long *attribute_lengths;     /* Length of attribute arguments */
 
387
  void *extension;
 
388
} UDF_ARGS;
 
389
 
 
390
  /* This holds information about the result */
 
391
 
 
392
typedef struct st_udf_init
 
393
{
 
394
  my_bool maybe_null;          /* 1 if function can return NULL */
 
395
  unsigned int decimals;       /* for real functions */
 
396
  unsigned long max_length;    /* For string functions */
 
397
  char *ptr;                   /* free pointer for function data */
 
398
  my_bool const_item;          /* 1 if function always returns the same value */
 
399
  void *extension;
 
400
} UDF_INIT;
 
401
/* 
 
402
  TODO: add a notion for determinism of the UDF. 
 
403
  See Item_udf_func::update_used_tables ()
 
404
*/
 
405
 
 
406
  /* Constants when using compression */
 
407
#define NET_HEADER_SIZE 4               /* standard header size */
 
408
#define COMP_HEADER_SIZE 3              /* compression header extra size */
 
409
 
 
410
  /* Prototypes to password functions */
 
411
 
 
412
#ifdef __cplusplus
 
413
extern "C" {
 
414
#endif
 
415
 
 
416
/*
 
417
  These functions are used for authentication by client and server and
 
418
  implemented in sql/password.c
 
419
*/
 
420
 
 
421
void randominit(struct rand_struct *, uint32_t seed1, uint32_t seed2);
 
422
double my_rnd(struct rand_struct *);
 
423
void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
 
424
 
 
425
void hash_password(uint32_t *to, const char *password, uint32_t password_len);
 
426
 
 
427
void make_scrambled_password(char *to, const char *password);
 
428
void scramble(char *to, const char *message, const char *password);
 
429
my_bool check_scramble(const char *reply, const char *message,
 
430
                       const unsigned char *hash_stage2);
 
431
void get_salt_from_password(unsigned char *res, const char *password);
 
432
void make_password_from_salt(char *to, const unsigned char *hash_stage2);
 
433
char *octet2hex(char *to, const char *str, unsigned int len);
 
434
 
 
435
/* end of password.c */
 
436
 
 
437
char *get_tty_password(const char *opt_message);
 
438
const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
 
439
 
 
440
 
 
441
#ifdef _global_h
 
442
ulong STDCALL net_field_length(uchar **packet);
 
443
uint64_t net_field_length_ll(uchar **packet);
 
444
uchar *net_store_length(uchar *pkg, uint64_t length);
 
445
#endif
 
446
 
 
447
#ifdef __cplusplus
 
448
}
 
449
#endif
 
450
 
 
451
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
 
452
#define MYSQL_STMT_HEADER       4
 
453
#define MYSQL_LONG_DATA_HEADER  6
 
454
 
 
455
#endif