00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _mysql_com_h
00009 #define _mysql_com_h
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013
00014 #define NAME_LEN 64
00015 #define LOCAL_HOST "localhost"
00016
00017 #define MYSQL_PORT 3306
00018 #define MYSQL_UNIX_ADDR "/tmp/mysql.sock"
00019
00020 enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
00021 COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH,
00022 COM_SHUTDOWN,COM_STATISTICS,
00023 COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
00024 COM_DEBUG,COM_PING};
00025
00026 #define NOT_NULL_FLAG 1
00027 #define PRI_KEY_FLAG 2
00028 #define UNIQUE_KEY_FLAG 4
00029 #define MULTIPLE_KEY_FLAG 8
00030 #define BLOB_FLAG 16
00031 #define UNSIGNED_FLAG 32
00032 #define ZEROFILL_FLAG 64
00033 #define BINARY_FLAG 128
00034
00035 #define ENUM_FLAG 256
00036 #define AUTO_INCREMENT_FLAG 512
00037 #define TIMESTAMP_FLAG 1024
00038 #define PART_KEY_FLAG 16384
00039 #define GROUP_FLAG 32768
00040
00041 #define REFRESH_GRANT 1
00042 #define REFRESH_LOG 2
00043 #define REFRESH_TABLES 4
00044 #define REFRESH_HOSTS 8
00045 #define REFRESH_FAST 32768
00046
00047 #define CLIENT_LONG_PASSWORD 1
00048 #define CLIENT_FOUND_ROWS 2
00049 #define CLIENT_LONG_FLAG 4
00050 #define CLIENT_CONNECT_WITH_DB 8
00051 #define CLIENT_NO_SCHEMA 16
00052 #define CLIENT_COMPRESS 32
00053 #define CLIENT_ODBC 64
00054
00055 #define MYSQL_ERRMSG_SIZE 200
00056 #define NET_READ_TIMEOUT 30
00057 #define NET_WRITE_TIMEOUT 60
00058 #define NET_WAIT_TIMEOUT 8*60*60
00059
00060 typedef struct st_net {
00061 Socket fd;
00062 int fcntl;
00063 unsigned char *buff,*buff_end,*write_pos;
00064 char last_error[MYSQL_ERRMSG_SIZE];
00065 unsigned int last_errno,max_packet,timeout,pkt_nr;
00066 my_bool error,return_errno,compress;
00067 } NET;
00068
00069 #define packet_error ((unsigned int) -1)
00070
00071 enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
00072 FIELD_TYPE_SHORT, FIELD_TYPE_LONG,
00073 FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE,
00074 FIELD_TYPE_NULL, FIELD_TYPE_TIMESTAMP,
00075 FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
00076 FIELD_TYPE_DATE, FIELD_TYPE_TIME,
00077 FIELD_TYPE_DATETIME, FIELD_TYPE_YEAR,
00078 FIELD_TYPE_NEWDATE,
00079 FIELD_TYPE_ENUM=247,
00080 FIELD_TYPE_SET=248,
00081 FIELD_TYPE_TINY_BLOB=249,
00082 FIELD_TYPE_MEDIUM_BLOB=250,
00083 FIELD_TYPE_LONG_BLOB=251,
00084 FIELD_TYPE_BLOB=252,
00085 FIELD_TYPE_VAR_STRING=253,
00086 FIELD_TYPE_STRING=254
00087 };
00088
00089 #define FIELD_TYPE_CHAR FIELD_TYPE_TINY
00090 #define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM
00091
00092 extern unsigned long max_allowed_packet;
00093 extern unsigned long net_buffer_length;
00094
00095 #define net_new_transaction(net) ((net)->pkt_nr=0)
00096 int my_net_init(NET *net,Socket fd);
00097 void net_end(NET *net);
00098 void net_clear(NET *net);
00099 int net_flush(NET *net);
00100 int my_net_write(NET *net,char *packet,unsigned long len);
00101 int net_write_command(NET *net,unsigned char command,const char *packet,
00102 unsigned long len);
00103 int net_real_write(NET *net,const char *packet,unsigned long len);
00104 unsigned int my_net_read(NET *net);
00105
00106 struct rand_struct {
00107 unsigned long seed,seed2,max_value;
00108 double max_value_dbl;
00109 };
00110
00111
00112
00113 enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT};
00114
00115 typedef struct st_udf_args
00116 {
00117 unsigned int arg_count;
00118 enum Item_result *arg_type;
00119 char **args;
00120 unsigned long *lengths;
00121 } UDF_ARGS;
00122
00123
00124
00125 typedef struct st_udf_init
00126 {
00127 my_bool maybe_null;
00128 unsigned int decimals;
00129 unsigned int max_length;
00130 char *ptr;
00131 } UDF_INIT;
00132
00133
00134 #define NET_HEADER_SIZE 4
00135 #define COMP_HEADER_SIZE 3
00136
00137
00138
00139 void randominit(struct rand_struct *rand,unsigned long seed1,
00140 unsigned long seed2);
00141 double rnd(struct rand_struct *rand);
00142 void make_scrambled_password(char *to,const char *password);
00143 void get_salt_from_password(unsigned long *res,const char *password);
00144 char *scramble(char *to,const char *message,const char *password,
00145 my_bool old_ver);
00146 my_bool check_scramble(const char *scramble,const char *message,
00147 unsigned long *salt,my_bool old_ver);
00148 char *get_tty_password(char *opt_message);
00149
00150 #define NULL_LENGTH ((unsigned long) ~0)
00151
00152 #ifdef __WIN32__
00153 #define socket_errno WSAGetLastError()
00154 #else
00155 #define socket_errno errno
00156 #endif
00157
00158 #ifdef __cplusplus
00159 }
00160 #endif
00161 #endif