DBD-PgAsync

 view release on metacpan or  search on metacpan

dbdimp.c  view on Meta::CPAN

    imp_sth->PQfmts            = NULL;
    imp_sth->PQoids            = NULL;
    imp_sth->prepared_by_us    = DBDPG_FALSE; /* Set to 1 when actually done preparing */
    imp_sth->direct            = DBDPG_FALSE;
    imp_sth->is_dml            = DBDPG_FALSE; /* Not preparable DML until proved otherwise */
    imp_sth->has_binary        = DBDPG_FALSE; /* Are any of the params binary? */
    imp_sth->has_default       = DBDPG_FALSE; /* Are any of the params DEFAULT? */
    imp_sth->has_current       = DBDPG_FALSE; /* Are any of the params DEFAULT? */
    imp_sth->use_inout         = DBDPG_FALSE; /* Are any of the placeholders using inout? */
    imp_sth->all_bound         = DBDPG_FALSE; /* Have all placeholders been bound? */
    imp_sth->number_iterations = 0;

    /* We inherit some preferences from the database handle */
    imp_sth->server_prepare   = imp_dbh->server_prepare;
    imp_sth->switch_prepared  = imp_dbh->switch_prepared;
    imp_sth->prepare_now      = imp_dbh->prepare_now;
    imp_sth->dollaronly       = imp_dbh->dollaronly;
    imp_sth->nocolons         = imp_dbh->nocolons;

    /* Parse and set any attributes passed in */
    if (attribs) {

dbdimp.c  view on Meta::CPAN

                    THEADER_slow, 
                    imp_sth->is_dml,
                    imp_sth->direct,
                    imp_sth->server_prepare,
                    imp_sth->numbound,
                    imp_sth->numphs,
                    imp_sth->has_default,
                    imp_sth->has_current);

    /* Increment our count */
    imp_sth->number_iterations++;

    /* We use PQexec if:
       1. The statement is *not* DML (e.g. is DDL, which cannot be prepared)
       2. We have a DEFAULT parameter
       3. We have a CURRENT parameter
       4. pg_direct is true
       5. There are no placeholders
       6. pg_server_prepare is false
    */
    if (NULL != imp_sth->prepare_name)
        pqtype = PQTYPE_PREPARED;
    else if (!imp_sth->is_dml
        || imp_sth->has_default
        || imp_sth->has_current
        || imp_sth->direct
        || !imp_sth->numphs
        || !imp_sth->server_prepare
        )
        pqtype = PQTYPE_EXEC;
    else if (0==imp_sth->switch_prepared || imp_sth->number_iterations < imp_sth->switch_prepared)
        pqtype = PQTYPE_PARAMS;
    else
        pqtype = PQTYPE_PREPARED;

    if (TRACE4_slow) TRC(DBILOGFP, "%sWill use %s\n", 
                         THEADER_slow,
                         pq_x_calls[pqtype][(imp_sth->async_flag & PG_ASYNC) != 0]);

    /* We use the new server_side prepare style if:
       1. The statement is DML (DDL is not preparable)

dbdimp.h  view on Meta::CPAN

        PLACEHOLDER_COLON
    } PGPlaceholderType;
#define PLACEHOLDER_TYPE_COUNT (PLACEHOLDER_COLON + 1)

/* Define sth implementor data structure */
struct imp_sth_st {
    dbih_stc_t com;          /* MUST be first element in structure */

    bool   server_prepare;    /* inherited from dbh */
    int    switch_prepared;   /* inherited from dbh */
    int    number_iterations; /* how many times has the statement been executed? Used by switch_prepared */
    PGPlaceholderType placeholder_type;  /* which style is being used 1=? 2=$1 3=:foo */
    int    numsegs;           /* how many segments this statement has */
    int    numphs;            /* how many placeholders this statement has */
    int    numbound;          /* how many placeholders were explicitly bound by the client, not us */
    int    cur_tuple;         /* current tuple being fetched */
    long   rows;              /* number of affected rows */
    int    async_flag;        /* async? 0=no 1=async 2=cancel 4=wait */
    int    async_status;      /* 0=no async 1=async started -1=async has been cancelled */

    STRLEN totalsize;        /* total string length of the statement (with no placeholders)*/



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