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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:1512:   //! @seealso   //! @[Sql.Sql], @[Sql.sql_result], @[Sql.pgsql_util.pgsql_result]   object big_query(string q,void|mapping(string|int:mixed) bindings,    void|int _alltyped) {    string preparedname="";    string portalname="";    int forcecache=-1;    if(stringp(q) && String.width(q)>8)    q=string_to_utf8(q);    array(string|int) paramValues; +  array(string) from,to;    if(bindings) {    int pi=0,rep=0;    paramValues=allocate(sizeof(bindings)); -  array(string) from=allocate(sizeof(bindings)); -  array(string) to=allocate(sizeof(bindings)); +  from=allocate(sizeof(bindings)); +  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;    }    if(!has_value(q,name))    continue;    }    from[rep]=name;    string rval; -  if(multisetp(value)) { +  if(multisetp(value))    rval=sizeof(value) ? indices(value)[0] : ""; -  } +     else {    if(zero_type(value))    paramValues[pi++]=UNDEFINED; // NULL    else {    if(stringp(value) && String.width(value)>8)    value=string_to_utf8(value);    paramValues[pi++]=value;    }    rval="$"+(string)pi;    }    to[rep++]=rval;    }    if(rep--) -  q=replace(q,from[..rep],to[..rep]); +  q=replace(q,from=from[..rep],to=to[..rep]);    paramValues= pi ? paramValues[..pi-1] : ({});    }    else    paramValues = ({});    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) {    array(string) plugbuf=({});
pike.git/lib/modules/Sql.pmod/pgsql.pike:1757:    tp->tparse=tstart;    }    tp->trunstart=tend;    }    tprepared=tp;    }    }) {    PD("%O\n",err);    resync(1);    backendstatus=UNDEFINED; +  if(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.