Eneboo - Documentación para desarrolladores
src/libmysql_macosx/include/mysql.h
Ir a la documentación de este archivo.
00001 /* Copyright (C) 2000-2003 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; either version 2 of the License, or
00006    (at your option) any later version.
00007 
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012 
00013    You should have received a copy of the GNU General Public License
00014    along with this program; if not, write to the Free Software
00015    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00016 
00017 #ifndef _mysql_h
00018 #define _mysql_h
00019 
00020 #ifdef __CYGWIN__     /* CYGWIN implements a UNIX API */
00021 #undef WIN
00022 #undef _WIN
00023 #undef _WIN32
00024 #undef _WIN64
00025 #undef __WIN__
00026 #endif
00027 
00028 #ifdef  __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 #ifndef _global_h                               /* If not standard header */
00033 #include <sys/types.h>
00034 #ifdef __LCC__
00035 #include <winsock.h>                            /* For windows */
00036 #endif
00037 typedef char my_bool;
00038 #if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
00039 #define __WIN__
00040 #endif
00041 #if !defined(__WIN__)
00042 #define STDCALL
00043 #else
00044 #define STDCALL __stdcall
00045 #endif
00046 typedef char * gptr;
00047 
00048 #ifndef my_socket_defined
00049 #ifdef __WIN__
00050 #define my_socket SOCKET
00051 #else
00052 typedef int my_socket;
00053 #endif /* __WIN__ */
00054 #endif /* my_socket_defined */
00055 #endif /* _global_h */
00056 
00057 #include "mysql_com.h"
00058 #include "mysql_time.h"
00059 #include "mysql_version.h"
00060 #include "typelib.h"
00061 
00062 #include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */
00063 
00064 extern unsigned int mysql_port;
00065 extern char *mysql_unix_port;
00066 
00067 #define CLIENT_NET_READ_TIMEOUT         365*24*3600     /* Timeout on read */
00068 #define CLIENT_NET_WRITE_TIMEOUT        365*24*3600     /* Timeout on write */
00069 
00070 #ifdef __NETWARE__
00071 #pragma pack(push, 8)           /* 8 byte alignment */
00072 #endif
00073 
00074 #define IS_PRI_KEY(n)   ((n) & PRI_KEY_FLAG)
00075 #define IS_NOT_NULL(n)  ((n) & NOT_NULL_FLAG)
00076 #define IS_BLOB(n)      ((n) & BLOB_FLAG)
00077 #define IS_NUM(t)       ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR)
00078 #define IS_NUM_FIELD(f)  ((f)->flags & NUM_FLAG)
00079 #define INTERNAL_NUM_FIELD(f) (((f)->type <= FIELD_TYPE_INT24 && ((f)->type != FIELD_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == FIELD_TYPE_YEAR)
00080 
00081 
00082 typedef struct st_mysql_field {
00083   char *name;                 /* Name of column */
00084   char *org_name;             /* Original column name, if an alias */ 
00085   char *table;                /* Table of column if column was a field */
00086   char *org_table;            /* Org table name, if table was an alias */
00087   char *db;                   /* Database for table */
00088   char *catalog;              /* Catalog for table */
00089   char *def;                  /* Default value (set by mysql_list_fields) */
00090   unsigned long length;       /* Width of column (create length) */
00091   unsigned long max_length;   /* Max width for selected set */
00092   unsigned int name_length;
00093   unsigned int org_name_length;
00094   unsigned int table_length;
00095   unsigned int org_table_length;
00096   unsigned int db_length;
00097   unsigned int catalog_length;
00098   unsigned int def_length;
00099   unsigned int flags;         /* Div flags */
00100   unsigned int decimals;      /* Number of decimals in field */
00101   unsigned int charsetnr;     /* Character set */
00102   enum enum_field_types type; /* Type of field. See mysql_com.h for types */
00103 } MYSQL_FIELD;
00104 
00105 typedef char **MYSQL_ROW;               /* return data as array of strings */
00106 typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
00107 
00108 #ifndef _global_h
00109 #if defined(NO_CLIENT_LONG_LONG)
00110 typedef unsigned long my_ulonglong;
00111 #elif defined (__WIN__)
00112 typedef unsigned __int64 my_ulonglong;
00113 #else
00114 typedef unsigned long long my_ulonglong;
00115 #endif
00116 #endif
00117 
00118 #define MYSQL_COUNT_ERROR (~(my_ulonglong) 0)
00119 
00120 typedef struct st_mysql_rows {
00121   struct st_mysql_rows *next;           /* list of rows */
00122   MYSQL_ROW data;
00123   unsigned long length;
00124 } MYSQL_ROWS;
00125 
00126 typedef MYSQL_ROWS *MYSQL_ROW_OFFSET;   /* offset to current row */
00127 
00128 #include "my_alloc.h"
00129 
00130 typedef struct st_mysql_data {
00131   my_ulonglong rows;
00132   unsigned int fields;
00133   MYSQL_ROWS *data;
00134   MEM_ROOT alloc;
00135 #if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
00136   MYSQL_ROWS **prev_ptr;
00137 #endif
00138 } MYSQL_DATA;
00139 
00140 enum mysql_option 
00141 {
00142   MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE,
00143   MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
00144   MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE,
00145   MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT,
00146   MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT,
00147   MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
00148   MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH
00149 };
00150 
00151 struct st_mysql_options {
00152   unsigned int connect_timeout, read_timeout, write_timeout;
00153   unsigned int port, protocol;
00154   unsigned long client_flag;
00155   char *host,*user,*password,*unix_socket,*db;
00156   struct st_dynamic_array *init_commands;
00157   char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
00158   char *ssl_key;                                /* PEM key file */
00159   char *ssl_cert;                               /* PEM cert file */
00160   char *ssl_ca;                                 /* PEM CA file */
00161   char *ssl_capath;                             /* PEM directory of CA-s? */
00162   char *ssl_cipher;                             /* cipher to use */
00163   char *shared_memory_base_name;
00164   unsigned long max_allowed_packet;
00165   my_bool use_ssl;                              /* if to use SSL or not */
00166   my_bool compress,named_pipe;
00167  /*
00168    On connect, find out the replication role of the server, and
00169    establish connections to all the peers
00170  */
00171   my_bool rpl_probe;
00172  /*
00173    Each call to mysql_real_query() will parse it to tell if it is a read
00174    or a write, and direct it to the slave or the master
00175  */
00176   my_bool rpl_parse;
00177  /*
00178    If set, never read from a master, only from slave, when doing
00179    a read that is replication-aware
00180  */
00181   my_bool no_master_reads;
00182 #if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
00183   my_bool separate_thread;
00184 #endif
00185   enum mysql_option methods_to_use;
00186   char *client_ip;
00187   /* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */
00188   my_bool secure_auth;
00189 
00190   /* function pointers for local infile support */
00191   int (*local_infile_init)(void **, const char *, void *);
00192   int (*local_infile_read)(void *, char *, unsigned int);
00193   void (*local_infile_end)(void *);
00194   int (*local_infile_error)(void *, char *, unsigned int);
00195   void *local_infile_userdata;
00196 };
00197 
00198 enum mysql_status 
00199 {
00200   MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT
00201 };
00202 
00203 enum mysql_protocol_type 
00204 {
00205   MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
00206   MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
00207 };
00208 /*
00209   There are three types of queries - the ones that have to go to
00210   the master, the ones that go to a slave, and the adminstrative
00211   type which must happen on the pivot connectioin
00212 */
00213 enum mysql_rpl_type 
00214 {
00215   MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
00216 };
00217 
00218 struct st_mysql_methods;
00219 
00220 typedef struct st_mysql
00221 {
00222   NET           net;                    /* Communication parameters */
00223   gptr          connector_fd;           /* ConnectorFd for SSL */
00224   char          *host,*user,*passwd,*unix_socket,*server_version,*host_info,*info;
00225   char          *db;
00226   struct charset_info_st *charset;
00227   MYSQL_FIELD   *fields;
00228   MEM_ROOT      field_alloc;
00229   my_ulonglong affected_rows;
00230   my_ulonglong insert_id;               /* id if insert on table with NEXTNR */
00231   my_ulonglong extra_info;              /* Used by mysqlshow */
00232   unsigned long thread_id;              /* Id for connection in server */
00233   unsigned long packet_length;
00234   unsigned int  port;
00235   unsigned long client_flag,server_capabilities;
00236   unsigned int  protocol_version;
00237   unsigned int  field_count;
00238   unsigned int  server_status;
00239   unsigned int  server_language;
00240   unsigned int  warning_count;
00241   struct st_mysql_options options;
00242   enum mysql_status status;
00243   my_bool       free_me;                /* If free in mysql_close */
00244   my_bool       reconnect;              /* set to 1 if automatic reconnect */
00245 
00246   /* session-wide random string */
00247   char          scramble[SCRAMBLE_LENGTH+1];
00248 
00249  /*
00250    Set if this is the original connection, not a master or a slave we have
00251    added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave()
00252  */
00253   my_bool rpl_pivot;
00254   /*
00255     Pointers to the master, and the next slave connections, points to
00256     itself if lone connection.
00257   */
00258   struct st_mysql* master, *next_slave;
00259 
00260   struct st_mysql* last_used_slave; /* needed for round-robin slave pick */
00261  /* needed for send/read/store/use result to work correctly with replication */
00262   struct st_mysql* last_used_con;
00263 
00264   LIST  *stmts;                     /* list of all statements */
00265   const struct st_mysql_methods *methods;
00266   void *thd;
00267   /*
00268     Points to boolean flag in MYSQL_RES  or MYSQL_STMT. We set this flag 
00269     from mysql_stmt_close if close had to cancel result set of this object.
00270   */
00271   my_bool *unbuffered_fetch_owner;
00272 } MYSQL;
00273 
00274 typedef struct st_mysql_res {
00275   my_ulonglong row_count;
00276   MYSQL_FIELD   *fields;
00277   MYSQL_DATA    *data;
00278   MYSQL_ROWS    *data_cursor;
00279   unsigned long *lengths;               /* column lengths of current row */
00280   MYSQL         *handle;                /* for unbuffered reads */
00281   MEM_ROOT      field_alloc;
00282   unsigned int  field_count, current_field;
00283   MYSQL_ROW     row;                    /* If unbuffered read */
00284   MYSQL_ROW     current_row;            /* buffer to current row */
00285   my_bool       eof;                    /* Used by mysql_fetch_row */
00286   /* mysql_stmt_close() had to cancel this result */
00287   my_bool       unbuffered_fetch_cancelled;  
00288   const struct st_mysql_methods *methods;
00289 } MYSQL_RES;
00290 
00291 #define MAX_MYSQL_MANAGER_ERR 256  
00292 #define MAX_MYSQL_MANAGER_MSG 256
00293 
00294 #define MANAGER_OK           200
00295 #define MANAGER_INFO         250
00296 #define MANAGER_ACCESS       401
00297 #define MANAGER_CLIENT_ERR   450
00298 #define MANAGER_INTERNAL_ERR 500
00299 
00300 #if !defined(MYSQL_SERVER) && !defined(MYSQL_CLIENT)
00301 #define MYSQL_CLIENT
00302 #endif
00303 
00304 
00305 typedef struct st_mysql_manager
00306 {
00307   NET net;
00308   char *host,*user,*passwd;
00309   unsigned int port;
00310   my_bool free_me;
00311   my_bool eof;
00312   int cmd_status;
00313   int last_errno;
00314   char* net_buf,*net_buf_pos,*net_data_end;
00315   int net_buf_size;
00316   char last_error[MAX_MYSQL_MANAGER_ERR];
00317 } MYSQL_MANAGER;
00318 
00319 typedef struct st_mysql_parameters
00320 {
00321   unsigned long *p_max_allowed_packet;
00322   unsigned long *p_net_buffer_length;
00323 } MYSQL_PARAMETERS;
00324 
00325 #if !defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY)
00326 #define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet)
00327 #define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length)
00328 #endif
00329 
00330 /*
00331   Set up and bring down the server; to ensure that applications will
00332   work when linked against either the standard client library or the
00333   embedded server library, these functions should be called.
00334 */
00335 int STDCALL mysql_server_init(int argc, char **argv, char **groups);
00336 void STDCALL mysql_server_end(void);
00337 /*
00338   mysql_server_init/end need to be called when using libmysqld or
00339   libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
00340   you don't need to call it explicitely; but you need to call
00341   mysql_server_end() to free memory). The names are a bit misleading
00342   (mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general
00343   names which suit well whether you're using libmysqld or libmysqlclient. We
00344   intend to promote these aliases over the mysql_server* ones.
00345 */
00346 #define mysql_library_init mysql_server_init
00347 #define mysql_library_end mysql_server_end
00348 
00349 MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void);
00350 
00351 /*
00352   Set up and bring down a thread; these function should be called
00353   for each thread in an application which opens at least one MySQL
00354   connection.  All uses of the connection(s) should be between these
00355   function calls.
00356 */
00357 my_bool STDCALL mysql_thread_init(void);
00358 void STDCALL mysql_thread_end(void);
00359 
00360 /*
00361   Functions to get information from the MYSQL and MYSQL_RES structures
00362   Should definitely be used if one uses shared libraries.
00363 */
00364 
00365 my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res);
00366 unsigned int STDCALL mysql_num_fields(MYSQL_RES *res);
00367 my_bool STDCALL mysql_eof(MYSQL_RES *res);
00368 MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res,
00369                                               unsigned int fieldnr);
00370 MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res);
00371 MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res);
00372 MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res);
00373 
00374 unsigned int STDCALL mysql_field_count(MYSQL *mysql);
00375 my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql);
00376 my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql);
00377 unsigned int STDCALL mysql_errno(MYSQL *mysql);
00378 const char * STDCALL mysql_error(MYSQL *mysql);
00379 const char *STDCALL mysql_sqlstate(MYSQL *mysql);
00380 unsigned int STDCALL mysql_warning_count(MYSQL *mysql);
00381 const char * STDCALL mysql_info(MYSQL *mysql);
00382 unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
00383 const char * STDCALL mysql_character_set_name(MYSQL *mysql);
00384 int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname);
00385 
00386 MYSQL *         STDCALL mysql_init(MYSQL *mysql);
00387 my_bool         STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
00388                                       const char *cert, const char *ca,
00389                                       const char *capath, const char *cipher);
00390 my_bool         STDCALL mysql_change_user(MYSQL *mysql, const char *user, 
00391                                           const char *passwd, const char *db);
00392 MYSQL *         STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
00393                                            const char *user,
00394                                            const char *passwd,
00395                                            const char *db,
00396                                            unsigned int port,
00397                                            const char *unix_socket,
00398                                            unsigned long clientflag);
00399 int             STDCALL mysql_select_db(MYSQL *mysql, const char *db);
00400 int             STDCALL mysql_query(MYSQL *mysql, const char *q);
00401 int             STDCALL mysql_send_query(MYSQL *mysql, const char *q,
00402                                          unsigned long length);
00403 int             STDCALL mysql_real_query(MYSQL *mysql, const char *q,
00404                                         unsigned long length);
00405 MYSQL_RES *     STDCALL mysql_store_result(MYSQL *mysql);
00406 MYSQL_RES *     STDCALL mysql_use_result(MYSQL *mysql);
00407 
00408 /* perform query on master */
00409 my_bool         STDCALL mysql_master_query(MYSQL *mysql, const char *q,
00410                                            unsigned long length);
00411 my_bool         STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
00412                                                 unsigned long length);
00413 /* perform query on slave */  
00414 my_bool         STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
00415                                           unsigned long length);
00416 my_bool         STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
00417                                                unsigned long length);
00418 
00419 /* local infile support */
00420 
00421 #define LOCAL_INFILE_ERROR_LEN 512
00422 
00423 void
00424 mysql_set_local_infile_handler(MYSQL *mysql,
00425                                int (*local_infile_init)(void **, const char *,
00426                             void *),
00427                                int (*local_infile_read)(void *, char *,
00428                                                         unsigned int),
00429                                void (*local_infile_end)(void *),
00430                                int (*local_infile_error)(void *, char*,
00431                                                          unsigned int),
00432                                void *);
00433 
00434 void
00435 mysql_set_local_infile_default(MYSQL *mysql);
00436 
00437 
00438 /*
00439   enable/disable parsing of all queries to decide if they go on master or
00440   slave
00441 */
00442 void            STDCALL mysql_enable_rpl_parse(MYSQL* mysql);
00443 void            STDCALL mysql_disable_rpl_parse(MYSQL* mysql);
00444 /* get the value of the parse flag */  
00445 int             STDCALL mysql_rpl_parse_enabled(MYSQL* mysql);
00446 
00447 /*  enable/disable reads from master */
00448 void            STDCALL mysql_enable_reads_from_master(MYSQL* mysql);
00449 void            STDCALL mysql_disable_reads_from_master(MYSQL* mysql);
00450 /* get the value of the master read flag */  
00451 my_bool         STDCALL mysql_reads_from_master_enabled(MYSQL* mysql);
00452 
00453 enum mysql_rpl_type     STDCALL mysql_rpl_query_type(const char* q, int len);  
00454 
00455 /* discover the master and its slaves */  
00456 my_bool         STDCALL mysql_rpl_probe(MYSQL* mysql);
00457 
00458 /* set the master, close/free the old one, if it is not a pivot */
00459 int             STDCALL mysql_set_master(MYSQL* mysql, const char* host,
00460                                          unsigned int port,
00461                                          const char* user,
00462                                          const char* passwd);
00463 int             STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
00464                                         unsigned int port,
00465                                         const char* user,
00466                                         const char* passwd);
00467 
00468 int             STDCALL mysql_shutdown(MYSQL *mysql,
00469                                        enum mysql_enum_shutdown_level
00470                                        shutdown_level);
00471 int             STDCALL mysql_dump_debug_info(MYSQL *mysql);
00472 int             STDCALL mysql_refresh(MYSQL *mysql,
00473                                      unsigned int refresh_options);
00474 int             STDCALL mysql_kill(MYSQL *mysql,unsigned long pid);
00475 int             STDCALL mysql_set_server_option(MYSQL *mysql,
00476                                                 enum enum_mysql_set_option
00477                                                 option);
00478 int             STDCALL mysql_ping(MYSQL *mysql);
00479 const char *    STDCALL mysql_stat(MYSQL *mysql);
00480 const char *    STDCALL mysql_get_server_info(MYSQL *mysql);
00481 const char *    STDCALL mysql_get_client_info(void);
00482 unsigned long   STDCALL mysql_get_client_version(void);
00483 const char *    STDCALL mysql_get_host_info(MYSQL *mysql);
00484 unsigned long   STDCALL mysql_get_server_version(MYSQL *mysql);
00485 unsigned int    STDCALL mysql_get_proto_info(MYSQL *mysql);
00486 MYSQL_RES *     STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild);
00487 MYSQL_RES *     STDCALL mysql_list_tables(MYSQL *mysql,const char *wild);
00488 MYSQL_RES *     STDCALL mysql_list_processes(MYSQL *mysql);
00489 int             STDCALL mysql_options(MYSQL *mysql,enum mysql_option option,
00490                                       const char *arg);
00491 void            STDCALL mysql_free_result(MYSQL_RES *result);
00492 void            STDCALL mysql_data_seek(MYSQL_RES *result,
00493                                         my_ulonglong offset);
00494 MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result,
00495                                                 MYSQL_ROW_OFFSET offset);
00496 MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result,
00497                                            MYSQL_FIELD_OFFSET offset);
00498 MYSQL_ROW       STDCALL mysql_fetch_row(MYSQL_RES *result);
00499 unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result);
00500 MYSQL_FIELD *   STDCALL mysql_fetch_field(MYSQL_RES *result);
00501 MYSQL_RES *     STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
00502                                           const char *wild);
00503 unsigned long   STDCALL mysql_escape_string(char *to,const char *from,
00504                                             unsigned long from_length);
00505 unsigned long   STDCALL mysql_hex_string(char *to,const char *from,
00506                                          unsigned long from_length);
00507 unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
00508                                                char *to,const char *from,
00509                                                unsigned long length);
00510 void            STDCALL mysql_debug(const char *debug);
00511 char *          STDCALL mysql_odbc_escape_string(MYSQL *mysql,
00512                                                  char *to,
00513                                                  unsigned long to_length,
00514                                                  const char *from,
00515                                                  unsigned long from_length,
00516                                                  void *param,
00517                                                  char *
00518                                                  (*extend_buffer)
00519                                                  (void *, char *to,
00520                                                   unsigned long *length));
00521 void            STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
00522 unsigned int    STDCALL mysql_thread_safe(void);
00523 my_bool         STDCALL mysql_embedded(void);
00524 MYSQL_MANAGER*  STDCALL mysql_manager_init(MYSQL_MANAGER* con);  
00525 MYSQL_MANAGER*  STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
00526                                               const char* host,
00527                                               const char* user,
00528                                               const char* passwd,
00529                                               unsigned int port);
00530 void            STDCALL mysql_manager_close(MYSQL_MANAGER* con);
00531 int             STDCALL mysql_manager_command(MYSQL_MANAGER* con,
00532                                                 const char* cmd, int cmd_len);
00533 int             STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con,
00534                                                   char* res_buf,
00535                                                  int res_buf_size);
00536 my_bool         STDCALL mysql_read_query_result(MYSQL *mysql);
00537 
00538 
00539 /*
00540   The following definitions are added for the enhanced 
00541   client-server protocol
00542 */
00543 
00544 /* statement state */
00545 enum enum_mysql_stmt_state
00546 {
00547   MYSQL_STMT_INIT_DONE= 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE,
00548   MYSQL_STMT_FETCH_DONE
00549 };
00550 
00551 
00552 /* bind structure */
00553 typedef struct st_mysql_bind
00554 {
00555   unsigned long *length;          /* output length pointer */
00556   my_bool       *is_null;         /* Pointer to null indicator */
00557   void          *buffer;          /* buffer to get/put data */
00558   enum enum_field_types buffer_type;    /* buffer type */
00559   unsigned long buffer_length;    /* buffer length, must be set for str/binary */  
00560 
00561   /* Following are for internal use. Set by mysql_stmt_bind_param */
00562   unsigned char *inter_buffer;    /* for the current data position */
00563   unsigned long offset;           /* offset position for char/binary fetch */
00564   unsigned long internal_length;  /* Used if length is 0 */
00565   unsigned int  param_number;     /* For null count and error messages */
00566   unsigned int  pack_length;      /* Internal length for packed data */
00567   my_bool       is_unsigned;      /* set if integer type is unsigned */
00568   my_bool       long_data_used;   /* If used with mysql_send_long_data */
00569   my_bool       internal_is_null; /* Used if is_null is 0 */
00570   void (*store_param_func)(NET *net, struct st_mysql_bind *param);
00571   void (*fetch_result)(struct st_mysql_bind *, unsigned char **row);
00572   void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *,
00573                       unsigned char **row);
00574 } MYSQL_BIND;
00575 
00576 
00577 /* statement handler */
00578 typedef struct st_mysql_stmt
00579 {
00580   MEM_ROOT       mem_root;             /* root allocations */
00581   LIST           list;                 /* list to keep track of all stmts */
00582   MYSQL          *mysql;               /* connection handle */
00583   MYSQL_BIND     *params;              /* input parameters */
00584   MYSQL_BIND     *bind;                /* output parameters */
00585   MYSQL_FIELD    *fields;              /* result set metadata */
00586   MYSQL_DATA     result;               /* cached result set */
00587   MYSQL_ROWS     *data_cursor;         /* current row in cached result */
00588   /* copy of mysql->affected_rows after statement execution */
00589   my_ulonglong   affected_rows;
00590   my_ulonglong   insert_id;            /* copy of mysql->insert_id */
00591   /*
00592     mysql_stmt_fetch() calls this function to fetch one row (it's different
00593     for buffered, unbuffered and cursor fetch).
00594   */
00595   int            (*read_row_func)(struct st_mysql_stmt *stmt, 
00596                                   unsigned char **row);
00597   unsigned long  stmt_id;              /* Id for prepared statement */
00598   unsigned int   last_errno;           /* error code */
00599   unsigned int   param_count;          /* input parameter count */
00600   unsigned int   field_count;          /* number of columns in result set */
00601   enum enum_mysql_stmt_state state;    /* statement state */
00602   char           last_error[MYSQL_ERRMSG_SIZE]; /* error message */
00603   char           sqlstate[SQLSTATE_LENGTH+1];
00604   /* Types of input parameters should be sent to server */
00605   my_bool        send_types_to_server;
00606   my_bool        bind_param_done;      /* input buffers were supplied */
00607   my_bool        bind_result_done;     /* output buffers were supplied */
00608   /* mysql_stmt_close() had to cancel this result */
00609   my_bool       unbuffered_fetch_cancelled;  
00610   /*
00611     Is set to true if we need to calculate field->max_length for 
00612     metadata fields when doing mysql_stmt_store_result.
00613   */
00614   my_bool       update_max_length;     
00615 } MYSQL_STMT;
00616 
00617 enum enum_stmt_attr_type
00618 {
00619   /*
00620     When doing mysql_stmt_store_result calculate max_length attribute
00621     of statement metadata. This is to be consistent with the old API, 
00622     where this was done automatically.
00623     In the new API we do that only by request because it slows down
00624     mysql_stmt_store_result sufficiently.
00625   */
00626   STMT_ATTR_UPDATE_MAX_LENGTH
00627 };
00628 
00629 
00630 typedef struct st_mysql_methods
00631 {
00632   my_bool (*read_query_result)(MYSQL *mysql);
00633   my_bool (*advanced_command)(MYSQL *mysql,
00634                               enum enum_server_command command,
00635                               const char *header,
00636                               unsigned long header_length,
00637                               const char *arg,
00638                               unsigned long arg_length,
00639                               my_bool skip_check);
00640   MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
00641                            unsigned int fields);
00642   MYSQL_RES * (*use_result)(MYSQL *mysql);
00643   void (*fetch_lengths)(unsigned long *to, 
00644                         MYSQL_ROW column, unsigned int field_count);
00645   void (*flush_use_result)(MYSQL *mysql);
00646 #if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
00647   MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
00648   my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
00649   int (*stmt_execute)(MYSQL_STMT *stmt);
00650   int (*read_binary_rows)(MYSQL_STMT *stmt);
00651   int (*unbuffered_fetch)(MYSQL *mysql, char **row);
00652   void (*free_embedded_thd)(MYSQL *mysql);
00653   const char *(*read_statistics)(MYSQL *mysql);
00654   my_bool (*next_result)(MYSQL *mysql);
00655   int (*read_change_user_result)(MYSQL *mysql, char *buff, const char *passwd);
00656 #endif
00657 } MYSQL_METHODS;
00658 
00659 
00660 MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql);
00661 int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query,
00662                                unsigned long length);
00663 int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt);
00664 int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt);
00665 int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, 
00666                                     unsigned int column,
00667                                     unsigned long offset);
00668 int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
00669 unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt);
00670 my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt,
00671                                     enum enum_stmt_attr_type attr_type,
00672                                     const void *attr);
00673 my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
00674                                     enum enum_stmt_attr_type attr_type,
00675                                     void *attr);
00676 my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
00677 my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
00678 my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt);
00679 my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt);
00680 my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt);
00681 my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, 
00682                                           unsigned int param_number,
00683                                           const char *data, 
00684                                           unsigned long length);
00685 MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt);
00686 MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt);
00687 unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt);
00688 const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt);
00689 const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT * stmt);
00690 MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, 
00691                                              MYSQL_ROW_OFFSET offset);
00692 MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt);
00693 void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset);
00694 my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt);
00695 my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
00696 my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt);
00697 unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt);
00698 
00699 my_bool STDCALL mysql_commit(MYSQL * mysql);
00700 my_bool STDCALL mysql_rollback(MYSQL * mysql);
00701 my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
00702 my_bool STDCALL mysql_more_results(MYSQL *mysql);
00703 int STDCALL mysql_next_result(MYSQL *mysql);
00704 void STDCALL mysql_close(MYSQL *sock);
00705 
00706 
00707 /* status return codes */
00708 #define MYSQL_NO_DATA      100
00709 
00710 #define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
00711 
00712 #ifdef USE_OLD_FUNCTIONS
00713 MYSQL *         STDCALL mysql_connect(MYSQL *mysql, const char *host,
00714                                       const char *user, const char *passwd);
00715 int             STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
00716 int             STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
00717 #define  mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
00718 #endif
00719 #define HAVE_MYSQL_REAL_CONNECT
00720 
00721 /*
00722   The following functions are mainly exported because of mysqlbinlog;
00723   They are not for general usage
00724 */
00725 
00726 #ifdef QMYSQL_DRIVER_NAME
00727 //#include "HISTORY"
00728 #endif
00729 #define simple_command(mysql, command, arg, length, skip_check) \
00730   (*(mysql)->methods->advanced_command)(mysql, command,         \
00731                                         NullS, 0, arg, length, skip_check)
00732 unsigned long net_safe_read(MYSQL* mysql);
00733 
00734 #ifdef __NETWARE__
00735 #pragma pack(pop)               /* restore alignment */
00736 #endif
00737 
00738 #ifdef  __cplusplus
00739 }
00740 #endif
00741 
00742 #endif /* _mysql_h */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'