~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/mysql.h

  • Committer: Brian Aker
  • Date: 2008-07-02 20:17:52 UTC
  • Revision ID: brian@tangent.org-20080702201752-5vb7lk1ut6y1bhsk
First pass on removing binary protocol from client library.

Show diffs side-by-side

added added

removed removed

Lines of Context:
447
447
};
448
448
 
449
449
 
450
 
/*
451
 
  This structure is used to define bind information, and
452
 
  internally by the client library.
453
 
  Public members with their descriptions are listed below
454
 
  (conventionally `On input' refers to the binds given to
455
 
  mysql_stmt_bind_param, `On output' refers to the binds given
456
 
  to mysql_stmt_bind_result):
457
 
 
458
 
  buffer_type    - One of the MYSQL_* types, used to describe
459
 
                   the host language type of buffer.
460
 
                   On output: if column type is different from
461
 
                   buffer_type, column value is automatically converted
462
 
                   to buffer_type before it is stored in the buffer.
463
 
  buffer         - On input: points to the buffer with input data.
464
 
                   On output: points to the buffer capable to store
465
 
                   output data.
466
 
                   The type of memory pointed by buffer must correspond
467
 
                   to buffer_type. See the correspondence table in
468
 
                   the comment to mysql_stmt_bind_param.
469
 
 
470
 
  The two above members are mandatory for any kind of bind.
471
 
 
472
 
  buffer_length  - the length of the buffer. You don't have to set
473
 
                   it for any fixed length buffer: float, double,
474
 
                   int, etc. It must be set however for variable-length
475
 
                   types, such as BLOBs or STRINGs.
476
 
 
477
 
  length         - On input: in case when lengths of input values
478
 
                   are different for each execute, you can set this to
479
 
                   point at a variable containining value length. This
480
 
                   way the value length can be different in each execute.
481
 
                   If length is not NULL, buffer_length is not used.
482
 
                   Note, length can even point at buffer_length if
483
 
                   you keep bind structures around while fetching:
484
 
                   this way you can change buffer_length before
485
 
                   each execution, everything will work ok.
486
 
                   On output: if length is set, mysql_stmt_fetch will
487
 
                   write column length into it.
488
 
 
489
 
  is_null        - On input: points to a boolean variable that should
490
 
                   be set to TRUE for NULL values.
491
 
                   This member is useful only if your data may be
492
 
                   NULL in some but not all cases.
493
 
                   If your data is never NULL, is_null should be set to 0.
494
 
                   If your data is always NULL, set buffer_type
495
 
                   to MYSQL_TYPE_NULL, and is_null will not be used.
496
 
 
497
 
  is_unsigned    - On input: used to signify that values provided for one
498
 
                   of numeric types are unsigned.
499
 
                   On output describes signedness of the output buffer.
500
 
                   If, taking into account is_unsigned flag, column data
501
 
                   is out of range of the output buffer, data for this column
502
 
                   is regarded truncated. Note that this has no correspondence
503
 
                   to the sign of result set column, if you need to find it out
504
 
                   use mysql_stmt_result_metadata.
505
 
  error          - where to write a truncation error if it is present.
506
 
                   possible error value is:
507
 
                   0  no truncation
508
 
                   1  value is out of range or buffer is too small
509
 
 
510
 
  Please note that MYSQL_BIND also has internals members.
511
 
*/
512
 
 
513
 
typedef struct st_mysql_bind
514
 
{
515
 
  unsigned long *length;          /* output length pointer */
516
 
  my_bool       *is_null;         /* Pointer to null indicator */
517
 
  void          *buffer;          /* buffer to get/put data */
518
 
  /* set this if you want to track data truncations happened during fetch */
519
 
  my_bool       *error;
520
 
  unsigned char *row_ptr;         /* for the current data position */
521
 
  void (*store_param_func)(NET *net, struct st_mysql_bind *param);
522
 
  void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *,
523
 
                       unsigned char **row);
524
 
  void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *,
525
 
                      unsigned char **row);
526
 
  /* output buffer length, must be set when fetching str/binary */
527
 
  unsigned long buffer_length;
528
 
  unsigned long offset;           /* offset position for char/binary fetch */
529
 
  unsigned long length_value;     /* Used if length is 0 */
530
 
  unsigned int  param_number;     /* For null count and error messages */
531
 
  unsigned int  pack_length;      /* Internal length for packed data */
532
 
  enum enum_field_types buffer_type;    /* buffer type */
533
 
  my_bool       error_value;      /* used if error is 0 */
534
 
  my_bool       is_unsigned;      /* set if integer type is unsigned */
535
 
  my_bool       long_data_used;   /* If used with mysql_send_long_data */
536
 
  my_bool       is_null_value;    /* Used if is_null is 0 */
537
 
  void *extension;
538
 
} MYSQL_BIND;
539
 
 
540
 
 
541
450
/* statement handler */
542
451
typedef struct st_mysql_stmt
543
452
{
544
453
  MEM_ROOT       mem_root;             /* root allocations */
545
454
  LIST           list;                 /* list to keep track of all stmts */
546
455
  MYSQL          *mysql;               /* connection handle */
547
 
  MYSQL_BIND     *params;              /* input parameters */
548
 
  MYSQL_BIND     *bind;                /* output parameters */
549
456
  MYSQL_FIELD    *fields;              /* result set metadata */
550
457
  MYSQL_DATA     result;               /* cached result set */
551
458
  MYSQL_ROWS     *data_cursor;         /* current row in cached result */
626
533
  void (*fetch_lengths)(unsigned long *to, 
627
534
                        MYSQL_ROW column, unsigned int field_count);
628
535
  void (*flush_use_result)(MYSQL *mysql);
629
 
#if !defined(MYSQL_SERVER)
630
536
  MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
631
 
  my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
632
 
  int (*stmt_execute)(MYSQL_STMT *stmt);
633
 
  int (*read_binary_rows)(MYSQL_STMT *stmt);
634
537
  int (*unbuffered_fetch)(MYSQL *mysql, char **row);
635
 
  void (*free_embedded_thd)(MYSQL *mysql);
636
538
  const char *(*read_statistics)(MYSQL *mysql);
637
539
  my_bool (*next_result)(MYSQL *mysql);
638
540
  int (*read_change_user_result)(MYSQL *mysql, char *buff, const char *passwd);
639
 
  int (*read_rows_from_cursor)(MYSQL_STMT *stmt);
640
 
#endif
641
541
} MYSQL_METHODS;
642
542
 
643
543
 
646
546
                               unsigned long length);
647
547
int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt);
648
548
int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt);
649
 
int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg, 
650
 
                                    unsigned int column,
651
 
                                    unsigned long offset);
652
549
int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
653
550
unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt);
654
551
my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt,
657
554
my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
658
555
                                    enum enum_stmt_attr_type attr_type,
659
556
                                    void *attr);
660
 
my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
661
 
my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
662
557
my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt);
663
558
my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt);
664
559
my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt);