Branch: Tag:

2014-11-25

2014-11-25 10:04:43 by Stephen R. van den Berg <srb@cuci.nl>

pgsql: Slight speedup in column processing.

654:    int errtype=NOERROR;    PD("%d<",ci->socket->query_fd());    switch(msgtype) { -  array(mapping) getcols() { +  array getcols() {    int bintext=cr->read_int8();    int cols=cr->read_int16();   #ifdef PG_DEBUG
665:   #else    cr->consume(cols<<1);   #endif // Discard column info, and make it line oriented -  return ({(["type":bintext?BYTEAOID:TEXTOID,"name":"line"])}); +  return ({ ({(["name":"line"])}), ({bintext?BYTEAOID:TEXTOID}) });    };    array(string) reads() {   #ifdef PG_DEBUG
829:    break;    case 't': {    array a; -  int cols=cr->read_int16(); +    #ifdef PG_DEBUG -  +  int cols=cr->read_int16();    PD("%O ParameterDescription %d values\n",portal._query,cols);    msglen-=4+2+4*cols; -  +  a=cr->read_ints(cols,4); + #else +  a=cr->read_ints(cr->read_int16(),4);   #endif -  foreach(a=allocate(cols);int i;) -  a[i]=cr->read_int32(); +    #ifdef PG_DEBUGMORE    PD("%O\n",a);   #endif
845:    break;    }    case 'T': { -  array a; - #ifdef PG_DEBUG +  array a,at;    int cols=cr->read_int16(); -  + #ifdef PG_DEBUG    PD("RowDescription %d columns %O\n",cols,portal._query);    msglen-=4+2; -  foreach(a=allocate(cols);int i;) - #else -  foreach(a=allocate(cr->read_int16());int i;) +    #endif -  +  at=allocate(cols); +  foreach(a=allocate(cols);int i;)    {    string s=cr->read_cstring();    mapping(string:mixed) res=(["name":s]);
864:   #else    cr->consume(6);   #endif -  res.type=cr->read_int32(); +  at[i]=cr->read_int32();   #ifdef PG_DEBUG    {    int len=cr->read_sint(2);
885:    PD("%O\n",a);   #endif    if(portal._forcetext) -  portal->_setrowdesc(a); // Do not consume queued portal +  portal->_setrowdesc(a,at); // Do not consume queued portal    else { -  portal->_processrowdesc(a); +  portal->_processrowdesc(a,at);    portal=0;    }    break;
898:    PD("NoData %O\n",portal._query);   #endif    portal._fetchlimit=0; // disables subsequent Executes -  portal->_processrowdesc(({})); +  portal +  ->_processrowdesc(.pgsql_util.emptyarray,.pgsql_util.emptyarray);    portal=0;    break;    }    case 'H': -  portal->_processrowdesc(getcols()); +  portal->_processrowdesc(@getcols());    PD("CopyOutResponse %O\n",portal._query);    break;    case '2': {
997:   #endif    break;    case 'G': -  portal->_setrowdesc(getcols()); +  portal->_setrowdesc(@getcols());    PD("%O CopyInResponse\n",portal._portalname);    portal._state=COPYINPROGRESS;    break;
1286:    foreach(_prepareds;;mapping tp) {    m_delete(tp,"datatypeoid");    m_delete(tp,"datarowdesc"); +  m_delete(tp,"datarowtypes");    }    Thread.Thread(reset_dbsession); // Urgently and deadlockfree    }
1915: Inside #if defined(PG_STATS)
  #ifdef PG_STATS    skippeddescribe++;   #endif -  portal->_setrowdesc(tp.datarowdesc); +  portal->_setrowdesc(tp.datarowdesc,tp.datarowtypes);    }    if((portal._tprepared=tp) && tp.datatypeoid) {    mixed e=catch(portal->_preparebind(tp.datatypeoid));