00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _mysql_com_h
00022 #define _mysql_com_h
00023
00024 #define NAME_LEN 64
00025 #define HOSTNAME_LENGTH 60
00026 #define USERNAME_LENGTH 16
00027 #define SERVER_VERSION_LENGTH 60
00028 #define SQLSTATE_LENGTH 5
00029
00030 #define LOCAL_HOST "localhost"
00031 #define LOCAL_HOST_NAMEDPIPE "."
00032
00033
00034 #if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
00035 #define MYSQL_NAMEDPIPE "MySQL"
00036 #define MYSQL_SERVICENAME "MySQL"
00037 #endif
00038
00039 enum enum_server_command
00040 {
00041 COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
00042 COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS,
00043 COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING,
00044 COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP,
00045 COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
00046 COM_PREPARE, COM_EXECUTE, COM_LONG_DATA, COM_CLOSE_STMT,
00047 COM_RESET_STMT, COM_SET_OPTION,
00048
00049
00050
00051 COM_END
00052 };
00053
00054
00055
00056
00057
00058
00059 #define SCRAMBLE_LENGTH 20
00060 #define SCRAMBLE_LENGTH_323 8
00061
00062 #define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
00063 #define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
00064
00065
00066 #define NOT_NULL_FLAG 1
00067 #define PRI_KEY_FLAG 2
00068 #define UNIQUE_KEY_FLAG 4
00069 #define MULTIPLE_KEY_FLAG 8
00070 #define BLOB_FLAG 16
00071 #define UNSIGNED_FLAG 32
00072 #define ZEROFILL_FLAG 64
00073 #define BINARY_FLAG 128
00074
00075
00076 #define ENUM_FLAG 256
00077 #define AUTO_INCREMENT_FLAG 512
00078 #define TIMESTAMP_FLAG 1024
00079 #define SET_FLAG 2048
00080 #define NUM_FLAG 32768
00081 #define PART_KEY_FLAG 16384
00082 #define GROUP_FLAG 32768
00083 #define UNIQUE_FLAG 65536
00084 #define BINCMP_FLAG 131072
00085
00086 #define REFRESH_GRANT 1
00087 #define REFRESH_LOG 2
00088 #define REFRESH_TABLES 4
00089 #define REFRESH_HOSTS 8
00090 #define REFRESH_STATUS 16
00091 #define REFRESH_THREADS 32
00092 #define REFRESH_SLAVE 64
00093
00094 #define REFRESH_MASTER 128
00095
00096
00097
00098 #define REFRESH_READ_LOCK 16384
00099 #define REFRESH_FAST 32768
00100
00101
00102 #define REFRESH_QUERY_CACHE 65536
00103 #define REFRESH_QUERY_CACHE_FREE 0x20000L
00104 #define REFRESH_DES_KEY_FILE 0x40000L
00105 #define REFRESH_USER_RESOURCES 0x80000L
00106
00107 #define CLIENT_LONG_PASSWORD 1
00108 #define CLIENT_FOUND_ROWS 2
00109 #define CLIENT_LONG_FLAG 4
00110 #define CLIENT_CONNECT_WITH_DB 8
00111 #define CLIENT_NO_SCHEMA 16
00112 #define CLIENT_COMPRESS 32
00113 #define CLIENT_ODBC 64
00114 #define CLIENT_LOCAL_FILES 128
00115 #define CLIENT_IGNORE_SPACE 256
00116 #define CLIENT_PROTOCOL_41 512
00117 #define CLIENT_INTERACTIVE 1024
00118 #define CLIENT_SSL 2048
00119 #define CLIENT_IGNORE_SIGPIPE 4096
00120 #define CLIENT_TRANSACTIONS 8192
00121 #define CLIENT_RESERVED 16384
00122 #define CLIENT_SECURE_CONNECTION 32768
00123 #define CLIENT_MULTI_STATEMENTS 65536
00124 #define CLIENT_MULTI_RESULTS 131072
00125 #define CLIENT_REMEMBER_OPTIONS (((ulong) 1) << 31)
00126
00127 #define SERVER_STATUS_IN_TRANS 1
00128 #define SERVER_STATUS_AUTOCOMMIT 2
00129 #define SERVER_STATUS_MORE_RESULTS 4
00130 #define SERVER_MORE_RESULTS_EXISTS 8
00131 #define SERVER_QUERY_NO_GOOD_INDEX_USED 16
00132 #define SERVER_QUERY_NO_INDEX_USED 32
00133 #define SERVER_STATUS_DB_DROPPED 256
00134
00135 #define MYSQL_ERRMSG_SIZE 512
00136 #define NET_READ_TIMEOUT 30
00137 #define NET_WRITE_TIMEOUT 60
00138 #define NET_WAIT_TIMEOUT 8*60*60
00139
00140 struct st_vio;
00141 typedef struct st_vio Vio;
00142
00143 #define MAX_TINYINT_WIDTH 3
00144 #define MAX_SMALLINT_WIDTH 5
00145 #define MAX_MEDIUMINT_WIDTH 8
00146 #define MAX_INT_WIDTH 10
00147 #define MAX_BIGINT_WIDTH 20
00148 #define MAX_CHAR_WIDTH 255
00149 #define MAX_BLOB_WIDTH 8192
00150
00151 typedef struct st_net {
00152 #if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)
00153 Vio* vio;
00154 unsigned char *buff,*buff_end,*write_pos,*read_pos;
00155 my_socket fd;
00156 unsigned long max_packet,max_packet_size;
00157 unsigned int pkt_nr,compress_pkt_nr;
00158 unsigned int write_timeout, read_timeout, retry_count;
00159 int fcntl;
00160 my_bool compress;
00161
00162
00163
00164
00165
00166 unsigned long remain_in_buf,length, buf_length, where_b;
00167 unsigned int *return_status;
00168 unsigned char reading_or_writing;
00169 char save_char;
00170 my_bool no_send_ok;
00171
00172
00173
00174
00175 #endif
00176 char last_error[MYSQL_ERRMSG_SIZE], sqlstate[SQLSTATE_LENGTH+1];
00177 unsigned int last_errno;
00178 unsigned char error;
00179 gptr query_cache_query;
00180 my_bool report_error;
00181 my_bool return_errno;
00182 } NET;
00183
00184 #define packet_error (~(unsigned long) 0)
00185
00186 enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
00187 MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
00188 MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
00189 MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
00190 MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
00191 MYSQL_TYPE_DATE, MYSQL_TYPE_TIME,
00192 MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
00193 MYSQL_TYPE_NEWDATE,
00194 MYSQL_TYPE_ENUM=247,
00195 MYSQL_TYPE_SET=248,
00196 MYSQL_TYPE_TINY_BLOB=249,
00197 MYSQL_TYPE_MEDIUM_BLOB=250,
00198 MYSQL_TYPE_LONG_BLOB=251,
00199 MYSQL_TYPE_BLOB=252,
00200 MYSQL_TYPE_VAR_STRING=253,
00201 MYSQL_TYPE_STRING=254,
00202 MYSQL_TYPE_GEOMETRY=255
00203
00204 };
00205
00206
00207 #define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS
00208 #define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
00209 #define FIELD_TYPE_TINY MYSQL_TYPE_TINY
00210 #define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
00211 #define FIELD_TYPE_LONG MYSQL_TYPE_LONG
00212 #define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT
00213 #define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE
00214 #define FIELD_TYPE_NULL MYSQL_TYPE_NULL
00215 #define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP
00216 #define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG
00217 #define FIELD_TYPE_INT24 MYSQL_TYPE_INT24
00218 #define FIELD_TYPE_DATE MYSQL_TYPE_DATE
00219 #define FIELD_TYPE_TIME MYSQL_TYPE_TIME
00220 #define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME
00221 #define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR
00222 #define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
00223 #define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
00224 #define FIELD_TYPE_SET MYSQL_TYPE_SET
00225 #define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
00226 #define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
00227 #define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB
00228 #define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB
00229 #define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING
00230 #define FIELD_TYPE_STRING MYSQL_TYPE_STRING
00231 #define FIELD_TYPE_CHAR MYSQL_TYPE_TINY
00232 #define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM
00233 #define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY
00234
00235
00236
00237
00238
00239 #define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
00240 #define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1)
00241 #define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
00242 #define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
00243
00244 enum mysql_enum_shutdown_level {
00245
00246
00247
00248
00249
00250 SHUTDOWN_DEFAULT = 0,
00251
00252 SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT,
00253
00254 SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS,
00255
00256 SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE,
00257
00258 SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
00259
00260 SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
00261
00262 #if MYSQL_VERSION_ID >= 50000
00263 KILL_QUERY= 254,
00264 #endif
00265 KILL_CONNECTION= 255
00266 };
00267
00268
00269 enum enum_mysql_set_option
00270 {
00271 MYSQL_OPTION_MULTI_STATEMENTS_ON,
00272 MYSQL_OPTION_MULTI_STATEMENTS_OFF
00273 };
00274
00275 #define net_new_transaction(net) ((net)->pkt_nr=0)
00276
00277 #ifdef __cplusplus
00278 extern "C" {
00279 #endif
00280
00281 my_bool my_net_init(NET *net, Vio* vio);
00282 void my_net_local_init(NET *net);
00283 void net_end(NET *net);
00284 void net_clear(NET *net);
00285 my_bool net_realloc(NET *net, unsigned long length);
00286 my_bool net_flush(NET *net);
00287 my_bool my_net_write(NET *net,const char *packet,unsigned long len);
00288 my_bool net_write_command(NET *net,unsigned char command,
00289 const char *header, unsigned long head_len,
00290 const char *packet, unsigned long len);
00291 int net_real_write(NET *net,const char *packet,unsigned long len);
00292 unsigned long my_net_read(NET *net);
00293
00294
00295
00296
00297
00298 struct sockaddr;
00299 int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
00300 unsigned int timeout);
00301
00302 struct rand_struct {
00303 unsigned long seed1,seed2,max_value;
00304 double max_value_dbl;
00305 };
00306
00307 #ifdef __cplusplus
00308 }
00309 #endif
00310
00311
00312
00313 enum Item_result {STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT};
00314
00315 typedef struct st_udf_args
00316 {
00317 unsigned int arg_count;
00318 enum Item_result *arg_type;
00319 char **args;
00320 unsigned long *lengths;
00321 char *maybe_null;
00322 } UDF_ARGS;
00323
00324
00325
00326 typedef struct st_udf_init
00327 {
00328 my_bool maybe_null;
00329 unsigned int decimals;
00330 unsigned long max_length;
00331 char *ptr;
00332 my_bool const_item;
00333 } UDF_INIT;
00334
00335
00336 #define NET_HEADER_SIZE 4
00337 #define COMP_HEADER_SIZE 3
00338
00339
00340
00341 #ifdef __cplusplus
00342 extern "C" {
00343 #endif
00344
00345
00346
00347
00348
00349
00350 void randominit(struct rand_struct *, unsigned long seed1,
00351 unsigned long seed2);
00352 double my_rnd(struct rand_struct *);
00353 void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
00354
00355 void hash_password(unsigned long *to, const char *password, unsigned int password_len);
00356 void make_scrambled_password_323(char *to, const char *password);
00357 void scramble_323(char *to, const char *message, const char *password);
00358 my_bool check_scramble_323(const char *, const char *message,
00359 unsigned long *salt);
00360 void get_salt_from_password_323(unsigned long *res, const char *password);
00361 void make_password_from_salt_323(char *to, const unsigned long *salt);
00362
00363 void make_scrambled_password(char *to, const char *password);
00364 void scramble(char *to, const char *message, const char *password);
00365 my_bool check_scramble(const char *reply, const char *message,
00366 const unsigned char *hash_stage2);
00367 void get_salt_from_password(unsigned char *res, const char *password);
00368 void make_password_from_salt(char *to, const unsigned char *hash_stage2);
00369
00370
00371
00372 char *get_tty_password(char *opt_message);
00373 const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
00374
00375
00376
00377 my_bool my_init(void);
00378 int load_defaults(const char *conf_file, const char **groups,
00379 int *argc, char ***argv);
00380 my_bool my_thread_init(void);
00381 void my_thread_end(void);
00382
00383 #ifdef _global_h
00384 ulong STDCALL net_field_length(uchar **packet);
00385 my_ulonglong net_field_length_ll(uchar **packet);
00386 char *net_store_length(char *pkg, ulonglong length);
00387 #endif
00388
00389 #ifdef __cplusplus
00390 }
00391 #endif
00392
00393 #define NULL_LENGTH ((unsigned long) ~0)
00394 #define MYSQL_STMT_HEADER 4
00395 #define MYSQL_LONG_DATA_HEADER 6
00396
00397 #endif