~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/mysql.h

  • Committer: Brian Aker
  • Date: 2008-07-02 21:16:23 UTC
  • Revision ID: brian@tangent.org-20080702211623-lix7xclpnm217nov
Remaining major pieces of PS removed

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
#include "mysql_com.h"
49
49
#include "mysql_time.h"
50
50
 
51
 
#include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */
 
51
#include "my_list.h" /* for LISTs used in 'MYSQL' */
52
52
 
53
53
extern unsigned int mysql_port;
54
54
extern char *mysql_unix_port;
434
434
my_bool         STDCALL mysql_read_query_result(MYSQL *mysql);
435
435
 
436
436
 
437
 
/*
438
 
  The following definitions are added for the enhanced 
439
 
  client-server protocol
440
 
*/
441
 
 
442
 
/* statement state */
443
 
enum enum_mysql_stmt_state
444
 
{
445
 
  MYSQL_STMT_INIT_DONE= 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE,
446
 
  MYSQL_STMT_FETCH_DONE
447
 
};
448
 
 
449
 
 
450
 
/* statement handler */
451
 
typedef struct st_mysql_stmt
452
 
{
453
 
  MEM_ROOT       mem_root;             /* root allocations */
454
 
  LIST           list;                 /* list to keep track of all stmts */
455
 
  MYSQL          *mysql;               /* connection handle */
456
 
  MYSQL_FIELD    *fields;              /* result set metadata */
457
 
  MYSQL_DATA     result;               /* cached result set */
458
 
  MYSQL_ROWS     *data_cursor;         /* current row in cached result */
459
 
  /*
460
 
    mysql_stmt_fetch() calls this function to fetch one row (it's different
461
 
    for buffered, unbuffered and cursor fetch).
462
 
  */
463
 
  int            (*read_row_func)(struct st_mysql_stmt *stmt, 
464
 
                                  unsigned char **row);
465
 
  /* copy of mysql->affected_rows after statement execution */
466
 
  my_ulonglong   affected_rows;
467
 
  my_ulonglong   insert_id;            /* copy of mysql->insert_id */
468
 
  unsigned long  stmt_id;              /* Id for prepared statement */
469
 
  unsigned long  flags;                /* i.e. type of cursor to open */
470
 
  unsigned long  prefetch_rows;        /* number of rows per one COM_FETCH */
471
 
  /*
472
 
    Copied from mysql->server_status after execute/fetch to know
473
 
    server-side cursor status for this statement.
474
 
  */
475
 
  unsigned int   server_status;
476
 
  unsigned int   last_errno;           /* error code */
477
 
  unsigned int   param_count;          /* input parameter count */
478
 
  unsigned int   field_count;          /* number of columns in result set */
479
 
  enum enum_mysql_stmt_state state;    /* statement state */
480
 
  char           last_error[MYSQL_ERRMSG_SIZE]; /* error message */
481
 
  char           sqlstate[SQLSTATE_LENGTH+1];
482
 
  /* Types of input parameters should be sent to server */
483
 
  my_bool        send_types_to_server;
484
 
  my_bool        bind_param_done;      /* input buffers were supplied */
485
 
  unsigned char  bind_result_done;     /* output buffers were supplied */
486
 
  /* mysql_stmt_close() had to cancel this result */
487
 
  my_bool       unbuffered_fetch_cancelled;  
488
 
  /*
489
 
    Is set to true if we need to calculate field->max_length for 
490
 
    metadata fields when doing mysql_stmt_store_result.
491
 
  */
492
 
  my_bool       update_max_length;     
493
 
  void *extension;
494
 
} MYSQL_STMT;
495
 
 
496
 
enum enum_stmt_attr_type
497
 
{
498
 
  /*
499
 
    When doing mysql_stmt_store_result calculate max_length attribute
500
 
    of statement metadata. This is to be consistent with the old API, 
501
 
    where this was done automatically.
502
 
    In the new API we do that only by request because it slows down
503
 
    mysql_stmt_store_result sufficiently.
504
 
  */
505
 
  STMT_ATTR_UPDATE_MAX_LENGTH,
506
 
  /*
507
 
    unsigned long with combination of cursor flags (read only, for update,
508
 
    etc)
509
 
  */
510
 
  STMT_ATTR_CURSOR_TYPE,
511
 
  /*
512
 
    Amount of rows to retrieve from server per one fetch if using cursors.
513
 
    Accepts unsigned long attribute in the range 1 - ulong_max
514
 
  */
515
 
  STMT_ATTR_PREFETCH_ROWS
516
 
};
517
 
 
518
437
 
519
438
typedef struct st_mysql_methods
520
439
{
525
444
                              unsigned long header_length,
526
445
                              const unsigned char *arg,
527
446
                              unsigned long arg_length,
528
 
                              my_bool skip_check,
529
 
                              MYSQL_STMT *stmt);
 
447
                              my_bool skip_check);
530
448
  MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
531
449
                           unsigned int fields);
532
450
  MYSQL_RES * (*use_result)(MYSQL *mysql);
541
459
} MYSQL_METHODS;
542
460
 
543
461
 
544
 
MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql);
545
 
int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query,
546
 
                               unsigned long length);
547
 
int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt);
548
 
int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt);
549
 
int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
550
 
unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt);
551
 
my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt,
552
 
                                    enum enum_stmt_attr_type attr_type,
553
 
                                    const void *attr);
554
 
my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
555
 
                                    enum enum_stmt_attr_type attr_type,
556
 
                                    void *attr);
557
 
my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt);
558
 
my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt);
559
 
my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt);
560
 
my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, 
561
 
                                          unsigned int param_number,
562
 
                                          const char *data, 
563
 
                                          unsigned long length);
564
 
MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt);
565
 
MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt);
566
 
unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt);
567
 
const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt);
568
 
const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT * stmt);
569
 
MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, 
570
 
                                             MYSQL_ROW_OFFSET offset);
571
 
MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt);
572
 
void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset);
573
 
my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt);
574
 
my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
575
 
my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt);
576
 
unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt);
577
 
 
578
462
my_bool STDCALL mysql_commit(MYSQL * mysql);
579
463
my_bool STDCALL mysql_rollback(MYSQL * mysql);
580
464
my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
604
488
 
605
489
#define simple_command(mysql, command, arg, length, skip_check) \
606
490
  (*(mysql)->methods->advanced_command)(mysql, command, 0,  \
607
 
                                        0, arg, length, skip_check, NULL)
608
 
#define stmt_command(mysql, command, arg, length, stmt) \
609
 
  (*(mysql)->methods->advanced_command)(mysql, command, 0,  \
610
 
                                        0, arg, length, 1, stmt)
 
491
                                        0, arg, length, skip_check)
611
492
 
612
493
#ifdef  __cplusplus
613
494
}