pike.git / lib / modules / Sql.pmod / pgsql.pike

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:602:    };    mapping(string:string) getresponse()    { mapping(string:string) msgresponse=([]);    msglen-=4;    foreach(getstrings();;string f)    if(sizeof(f))    msgresponse[f[..0]]=f[1..];    PD("%O\n",msgresponse);    return msgresponse;    }; +  array(string) showbindings() +  { array(string) msgs=({}); +  array from; +  if(from = _c.portal->_params) +  { array to,paramValues; +  [from,to,paramValues] = from; +  if(sizeof(paramValues)) +  { string val; +  int i; +  string fmt=sprintf("%%%ds %%3s %%.61s",max(@map(from,sizeof))); +  foreach(paramValues;i;val) +  msgs+=({sprintf(fmt,from[i],to[i],sprintf("%O",val))}); +  } +  } +  return msgs; +  };    case 'R':PD("Authentication\n");    { string sendpass;    int authtype;    msglen-=4+4;    switch(authtype=_c.getint32())    { case 0:PD("Ok\n");    _mstate=authenticated;    break;    case 2:PD("KerberosV5\n");    errtype=protocolunsupported;
pike.git/lib/modules/Sql.pmod/pgsql.pike:875:    break;    case 'E':PD("ErrorResponse\n");    { mapping(string:string) msgresponse;    msgresponse=getresponse();    warningsdropcount+=warningscollected;    warningscollected=0;    switch(msgresponse->C)    { case "P0001":    lastmessage=({sprintf("%s: %s",msgresponse->S,msgresponse->M)});    USERERROR(a2nls(lastmessage -  +({pinpointerror(_c.portal->query,msgresponse->P)}))); -  break; +  +({pinpointerror(_c.portal->_query,msgresponse->P)}) +  +showbindings()));    case "08P01":case "42P05":    errtype=protocolerror;    case "XX000":case "42883":case "42P01":    invalidatecache=1;    default:    lastmessage=({sprintf("%s %s:%s %s\n (%s:%s:%s)",    msgresponse->S,msgresponse->C,msgresponse->P||"",msgresponse->M,    msgresponse->F||"",msgresponse->R||"",msgresponse->L||"")});    if(msgresponse->D)    lastmessage+=({msgresponse->D});    if(msgresponse->H)    lastmessage+=({msgresponse->H});    lastmessage+=({ -  pinpointerror(_c.portal&&_c.portal->query,msgresponse->P)+ +  pinpointerror(_c.portal&&_c.portal->_query,msgresponse->P)+    pinpointerror(msgresponse->q,msgresponse->p)});    if(msgresponse->W)    lastmessage+=({msgresponse->W}); -  +  lastmessage+=showbindings();    switch(msgresponse->S)    { case "PANIC":werror(a2nls(lastmessage));    }    USERERROR(a2nls(lastmessage));    }    break;    }    case 'N':PD("NoticeResponse\n");    { mapping(string:string) msgresponse;    msgresponse=getresponse();
pike.git/lib/modules/Sql.pmod/pgsql.pike:1600:    string cenc=_runtimeparameter[CLIENT_ENCODING];    switch(cenc)    { case UTF8CHARSET:    q=string_to_utf8(q);    break;    default:    if(String.width(q)>8)    ERROR("Don't know how to convert %O to %s encoding\n",q,cenc);    }    array(string|int) paramValues; -  array(string) from,to; +  array from;    if(bindings)    { int pi=0,rep=0;    paramValues=allocate(sizeof(bindings));    from=allocate(sizeof(bindings)); -  to=allocate(sizeof(bindings)); +  array(string) to=allocate(sizeof(bindings));    foreach(bindings; mixed name; mixed value)    { if(stringp(name)) // Throws if mapping key is empty string    { if(name[0]!=':')    name=":"+name;    if(name[1]=='_') // Special option parameter    { switch(name)    { case ":_cache":forcecache=(int)value;    break;    }    continue;
pike.git/lib/modules/Sql.pmod/pgsql.pike:1633:    rval=indices(value)*","; // and bypass the encoding logic    else    { paramValues[pi++]=value;    rval=sprintf("$%d",pi);    }    to[rep++]=rval;    }    if(rep--)    q=replace(q,from=from[..rep],to=to[..rep]);    paramValues= pi ? paramValues[..pi-1] : ({}); +  from=({from,to,paramValues});    }    else    paramValues = ({});    if(String.width(q)>8)    ERROR("Wide string literals in %O not supported\n",q);    if(has_value(q,"\0"))    ERROR("Querystring %O contains invalid literal nul-characters\n",q);    mapping(string:mixed) tp;    int tstart;    if(forcecache==1 || forcecache!=0 && sizeof(q)>=MINPREPARELENGTH)
pike.git/lib/modules/Sql.pmod/pgsql.pike:1684:    }    }    if(sizeof(plugbuf))    { _c.sendcmd(plugbuf,1); // close expireds    PD("%O\n",plugbuf);    }    tstart=gethrtime();    } // pgsql_result autoassigns to portal    else    tp=UNDEFINED; -  .pgsql_util.pgsql_result(this,q,_fetchlimit,portalbuffersize,_alltyped); +  .pgsql_util.pgsql_result(this,q,_fetchlimit,portalbuffersize,_alltyped,from);    if(unnamedportalinuse)    portalname=PORTALPREFIX+(string)pportalcount++;    else    unnamedportalinuse++;    _c.portal->_portalname=portalname;    qstate=inquery;    portalsinflight++; portalsopened++;    clearmessage=1;    mixed err;    if(err = catch
pike.git/lib/modules/Sql.pmod/pgsql.pike:1884:    tp->tparse=tstart;    }    tp->trunstart=tend;    }    tprepared=tp;    }    })    { PD("%O\n",err);    resync(1);    backendstatus=UNDEFINED; -  if(to && sizeof(to)) -  { string val; -  int i; -  lastmessage+=({"Parameter bindings:"}); -  foreach(to;i;val) -  lastmessage+=({sprintf("%16s %3s %.61s", -  from[i],val,sprintf("%O",paramValues[i]))}); -  } +     throw(err);    }    { object tportal=_c.portal; // Make copy, because it might dislodge    tportal->fetch_row(1); // upon initial fetch_row()    return tportal;    }   }      //! This is an alias for @[big_query()], since @[big_query()] already supports   //! streaming of multiple simultaneous queries through the same connection.