Changeset 1993 for trunk/tools/database/mysql
- Timestamp:
- Dec 6, 1999, 7:11:50 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/mysql/mysql.h
r1936 r1993 6 6 #ifndef _mysql_h 7 7 #define _mysql_h 8 #ifdef 8 #ifdef __cplusplus 9 9 extern "C" { 10 10 #endif 11 11 12 #ifndef _global_h 12 #ifndef _global_h /* If not standard header */ 13 13 #include <sys/types.h> 14 14 typedef char my_bool; 15 15 #if !defined(WIN32) 16 #define STDCALL 16 #if defined(__IBMC__) || defined(__IBMCPP__) 17 #define STDCALL _System 18 #else 19 #define STDCALL 20 #endif 17 21 #else 18 22 #define STDCALL __stdcall … … 22 26 #ifndef ST_USED_MEM_DEFINED 23 27 #define ST_USED_MEM_DEFINED 24 typedef struct st_used_mem { 25 struct st_used_mem *next; 26 unsigned int left;/* memory left in block */27 unsigned int size;/* size of block */28 typedef struct st_used_mem { /* struct for once_alloc */ 29 struct st_used_mem *next; /* Next block in use */ 30 unsigned int left; /* memory left in block */ 31 unsigned int size; /* size of block */ 28 32 } USED_MEM; 29 33 typedef struct st_mem_root { 30 34 USED_MEM *free; 31 35 USED_MEM *used; 32 unsigned int 33 unsigned int 36 unsigned int min_malloc; 37 unsigned int block_size; 34 38 void (*error_handler)(void); 35 39 } MEM_ROOT; … … 50 54 extern char *mysql_unix_port; 51 55 52 #define IS_PRI_KEY(n) 53 #define IS_NOT_NULL(n) 54 #define IS_BLOB(n) 55 #define IS_NUM(t) 56 #define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG) 57 #define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG) 58 #define IS_BLOB(n) ((n) & BLOB_FLAG) 59 #define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR) 56 60 57 61 typedef struct st_mysql_field { 58 char *name; 59 char *table; 60 char *def; 61 enum enum_field_types type; 62 unsigned int length; 63 unsigned int max_length; 64 unsigned int flags; 65 unsigned int decimals; 62 char *name; /* Name of column */ 63 char *table; /* Table of column if column was a field */ 64 char *def; /* Default value (set by mysql_list_fields) */ 65 enum enum_field_types type; /* Type of field. Se mysql_com.h for types */ 66 unsigned int length; /* Width of column */ 67 unsigned int max_length; /* Max width of selected set */ 68 unsigned int flags; /* Div flags */ 69 unsigned int decimals; /* Number of decimals in field */ 66 70 } MYSQL_FIELD; 67 71 68 typedef char **MYSQL_ROW; 72 typedef char **MYSQL_ROW; /* return data as array of strings */ 69 73 typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */ 70 74 … … 80 84 81 85 typedef struct st_mysql_rows { 82 struct st_mysql_rows *next; 86 struct st_mysql_rows *next; /* list of rows */ 83 87 MYSQL_ROW data; 84 88 } MYSQL_ROWS; 85 89 86 typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; 90 typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */ 87 91 88 92 typedef struct st_mysql_data { 93 #if defined(__IBMC__) || defined(__IBMCPP__) 94 unsigned long rows; 95 unsigned long rows_; 96 #else 89 97 my_ulonglong rows; 98 #endif 90 99 unsigned int fields; 91 100 MYSQL_ROWS *data; … … 102 111 103 112 enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, 104 105 113 MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND, 114 MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP }; 106 115 107 116 enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT, 108 117 MYSQL_STATUS_USE_RESULT}; 109 118 110 119 typedef struct st_mysql { 111 NET net; /* Communication parameters */ 112 char *host,*user,*passwd,*unix_socket,*server_version,*host_info, 113 *info,*db; 114 unsigned int port,client_flag,server_capabilities; 115 unsigned int protocol_version; 116 unsigned int field_count; 117 unsigned long thread_id; /* Id for connection in server */ 120 NET net; /* Communication parameters */ 121 char *host,*user,*passwd,*unix_socket,*server_version,*host_info, 122 *info,*db; 123 unsigned int port,client_flag,server_capabilities; 124 unsigned int protocol_version; 125 unsigned int field_count; 126 unsigned long thread_id; /* Id for connection in server */ 127 #if defined(__IBMC__) || defined(__IBMCPP__) 128 unsigned long affected_rows; 129 unsigned long _affected_rows; 130 unsigned long insert_id; /* id if insert on table with NEXTNR */ 131 unsigned long _insert_id; /* id if insert on table with NEXTNR */ 132 unsigned long extra_info; /* Used by mysqlshow */ 133 unsigned long _extra_info; /* Used by mysqlshow */ 134 #else 118 135 my_ulonglong affected_rows; 119 my_ulonglong insert_id; /* id if insert on table with NEXTNR */ 120 my_ulonglong extra_info; /* Used by mysqlshow */ 136 my_ulonglong insert_id; /* id if insert on table with NEXTNR */ 137 my_ulonglong extra_info; /* Used by mysqlshow */ 138 #endif 139 121 140 unsigned long packet_length; 122 141 enum mysql_status status; 123 MYSQL_FIELD 124 MEM_ROOT 125 my_bool free_me;/* If free in mysql_close */126 my_bool reconnect;/* set to 1 if automatic reconnect */142 MYSQL_FIELD *fields; 143 MEM_ROOT field_alloc; 144 my_bool free_me; /* If free in mysql_close */ 145 my_bool reconnect; /* set to 1 if automatic reconnect */ 127 146 struct st_mysql_options options; 128 147 } MYSQL; … … 130 149 131 150 typedef struct st_mysql_res { 151 #if defined(__IBMC__) || defined(__IBMCPP__) 152 unsigned long row_count; 153 unsigned long _row_count; 154 #else 132 155 my_ulonglong row_count; 133 unsigned int field_count, current_field; 134 MYSQL_FIELD *fields; 135 MYSQL_DATA *data; 136 MYSQL_ROWS *data_cursor; 137 MEM_ROOT field_alloc; 138 MYSQL_ROW row; /* If unbuffered read */ 139 MYSQL_ROW current_row; /* buffer to current row */ 140 unsigned long *lengths; /* column lengths of current row */ 141 MYSQL *handle; /* for unbuffered reads */ 142 my_bool eof; /* Used my mysql_fetch_row */ 156 #endif 157 unsigned int field_count, current_field; 158 MYSQL_FIELD *fields; 159 MYSQL_DATA *data; 160 MYSQL_ROWS *data_cursor; 161 MEM_ROOT field_alloc; 162 MYSQL_ROW row; /* If unbuffered read */ 163 MYSQL_ROW current_row; /* buffer to current row */ 164 unsigned long *lengths; /* column lengths of current row */ 165 MYSQL *handle; /* for unbuffered reads */ 166 my_bool eof; /* Used my mysql_fetch_row */ 143 167 } MYSQL_RES; 144 168 … … 161 185 #define mysql_thread_id(mysql) (mysql)->thread_id 162 186 163 MYSQL * 164 MYSQL * 165 187 MYSQL * STDCALL mysql_init(MYSQL *mysql); 188 MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host, 189 const char *user, const char *passwd); 166 190 #if MYSQL_VERSION_ID >= 32200 167 MYSQL * 168 169 170 171 172 173 174 #else 175 MYSQL * 176 177 178 179 180 181 #endif 182 void 183 int 184 int 185 int 186 187 int 188 int 189 int 190 int 191 int 192 193 int 194 int 195 char * 196 char * 197 char * 198 char * 199 unsigned int 200 MYSQL_RES * 201 MYSQL_RES * 202 MYSQL_RES * 203 204 MYSQL_RES * 205 MYSQL_RES * 206 MYSQL_RES * 207 int 208 209 void 210 void 191 MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, 192 const char *user, 193 const char *passwd, 194 const char *db, 195 unsigned int port, 196 const char *unix_socket, 197 unsigned int clientflag); 198 #else 199 MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, 200 const char *user, 201 const char *passwd, 202 unsigned int port, 203 const char *unix_socket, 204 unsigned int clientflag); 205 #endif 206 void STDCALL mysql_close(MYSQL *sock); 207 int STDCALL mysql_select_db(MYSQL *mysql, const char *db); 208 int STDCALL mysql_query(MYSQL *mysql, const char *q); 209 int STDCALL mysql_real_query(MYSQL *mysql, const char *q, 210 unsigned int length); 211 int STDCALL mysql_create_db(MYSQL *mysql, const char *DB); 212 int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); 213 int STDCALL mysql_shutdown(MYSQL *mysql); 214 int STDCALL mysql_dump_debug_info(MYSQL *mysql); 215 int STDCALL mysql_refresh(MYSQL *mysql, 216 unsigned int refresh_options); 217 int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid); 218 int STDCALL mysql_ping(MYSQL *mysql); 219 char * STDCALL mysql_stat(MYSQL *mysql); 220 char * STDCALL mysql_get_server_info(MYSQL *mysql); 221 char * STDCALL mysql_get_client_info(void); 222 char * STDCALL mysql_get_host_info(MYSQL *mysql); 223 unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql); 224 MYSQL_RES * STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild); 225 MYSQL_RES * STDCALL mysql_list_tables(MYSQL *mysql,const char *wild); 226 MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table, 227 const char *wild); 228 MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql); 229 MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql); 230 MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql); 231 int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, 232 const char *arg); 233 void STDCALL mysql_free_result(MYSQL_RES *result); 234 void STDCALL mysql_data_seek(MYSQL_RES *result,unsigned int offset); 211 235 MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET); 212 236 MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result, 213 214 MYSQL_ROW 215 unsigned long * 216 MYSQL_FIELD * 217 unsigned int 218 219 void 237 MYSQL_FIELD_OFFSET offset); 238 MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); 239 unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result); 240 MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result); 241 unsigned int STDCALL mysql_escape_string(char *to,const char *from, 242 unsigned int from_length); 243 void STDCALL mysql_debug(const char *debug); 220 244 221 245 /* new api functions */ … … 223 247 #define HAVE_MYSQL_REAL_CONNECT 224 248 225 #ifdef 249 #ifdef __cplusplus 226 250 } 227 251 #endif
Note:
See TracChangeset
for help on using the changeset viewer.