DBD-drizzle

 view release on metacpan or  search on metacpan

dbdimp.h  view on Meta::CPAN

/*
 *  DBD::drizzle - DBI driver for the Drizzle database
 *
 *  Copyright (c) 2008       Patrick Galbraith
 *  Copyright 2009 Clint Byrum
 *
 *  Based on DBD::Oracle; DBD::Oracle is
 *
 *  Copyright (c) 1994,1995  Tim Bunce
 *
 *  You may distribute this under the terms of either the GNU General Public
 *  License or the Artistic License, as specified in the Perl README file.
 *
 */

/*
 *  Header files we use
 */
#include <DBIXS.h>  /* installed by the DBI module                        */
#include <libdrizzle/drizzle_client.h>

/*
  Drizzle team yanked these out of drizzle.h. I'll put them
  here for now
*/
#define IS_PRI_KEY(n) ((n) & DRIZZLE_COLUMN_FLAGS_PRI_KEY)
#define IS_NOT_NULL(n)  ((n) & DRIZZLE_COLUMN_FLAGS_NOT_NULL)
#define IS_BLOB(n)  ((n) & DRIZZLE_COLUMN_FLAGS_BLOB)
#define IS_AUTO_INCREMENT(n)  ((n) & DRIZZLE_COLUMN_FLAGS_AUTO_INCREMENT)
#define IS_KEY  ((n) & DRIZZLE_COLUMN_FLAGS_KEY)


/*
 *  The following are return codes passed in $h->err in case of
 *  errors by DBD::drizzle.
 */
enum errMsgs {
    JW_ERR_CONNECT = 1,
    JW_ERR_SELECT_DB,
    JW_ERR_STORE_RESULT,
    JW_ERR_NOT_ACTIVE,
    JW_ERR_QUERY,
    JW_ERR_FETCH_ROW,
    JW_ERR_LIST_DB,
    JW_ERR_CREATE_DB,
    JW_ERR_DROP_DB,
    JW_ERR_LIST_TABLES,
    JW_ERR_LIST_FIELDS,
    JW_ERR_LIST_FIELDS_INT,
    JW_ERR_LIST_SEL_FIELDS,
    JW_ERR_NO_RESULT,
    JW_ERR_NOT_IMPLEMENTED,
    JW_ERR_ILLEGAL_PARAM_NUM,
    JW_ERR_MEM,
    JW_ERR_LIST_INDEX,
    JW_ERR_SEQUENCE,
    AS_ERR_EMBEDDED,
    TX_ERR_AUTOCOMMIT,
    TX_ERR_COMMIT,
    TX_ERR_ROLLBACK
};


/*
 *  Internal constants, used for fetching array attributes
 */
enum av_attribs {
    AV_ATTRIB_NAME = 0,
    AV_ATTRIB_TABLE,
    AV_ATTRIB_TYPE,
    AV_ATTRIB_SQL_TYPE,
    AV_ATTRIB_IS_PRI_KEY,
    AV_ATTRIB_IS_NOT_NULL,
    AV_ATTRIB_NULLABLE,
    AV_ATTRIB_LENGTH,
    AV_ATTRIB_IS_NUM,
    AV_ATTRIB_TYPE_NAME,
    AV_ATTRIB_PRECISION,
    AV_ATTRIB_SCALE,
    AV_ATTRIB_MAX_LENGTH,
    AV_ATTRIB_IS_KEY,
    AV_ATTRIB_IS_BLOB,
    AV_ATTRIB_IS_AUTO_INCREMENT,
    AV_ATTRIB_LAST         /*  Dummy attribute, never used, for allocation  */
};                         /*  purposes only                                */


struct imp_drh_st {
    dbih_drc_t com;         /* MUST be first element in structure   */
};


/*
 *  Likewise, this is our part of the database handle, as returned
 *  by DBI->connect. We receive the handle as an "SV*", say "dbh",
 *  and receive a pointer to the structure below by declaring
 *
 *    D_imp_dbh(dbh);
 *
 *  This declares a variable called "imp_dbh" of type
 *  "struct imp_dbh_st *".
 */
struct imp_dbh_st {
    dbih_dbc_t com;         /*  MUST be first element in structure   */

    drizzle_st _drizzle;
    drizzle_st * drizzle; 

    uint32_t con_count;
    drizzle_con_st *con; /* TODO: replace with list for drizzle_con_ready */
    bool auto_reconnect;
    struct {
	    unsigned int auto_reconnects_ok;
	    unsigned int auto_reconnects_failed;
    } stats;
    unsigned short int  bind_type_guessing;
    int unbuffered_result;



( run in 0.601 second using v1.01-cache-2.11-cpan-71847e10f99 )