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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:521:   //! Sets the new cachedepth for automatic caching of prepared statements.   //!   //! @returns   //! The previous cachedepth.   //!   //! @note   //! This function is PostgreSQL-specific, and thus it is not available   //! through the generic SQL-interface.   int setcachedepth(void|int newdepth)   { int olddepth=cachedepth; -  if(!zero_type(newdepth) && newdepth>=0) +  if(!undefinedp(newdepth) && newdepth>=0)    cachedepth=newdepth;    return olddepth;   }      //! @param newtimeout   //! Sets the new timeout for long running queries.   //!   //! @returns   //! The previous timeout.   //!   //! @note   //! This function is PostgreSQL-specific, and thus it is not available   //! through the generic SQL-interface.   int settimeout(void|int newtimeout)   { int oldtimeout=timeout; -  if(!zero_type(newtimeout) && newtimeout>0) +  if(!undefinedp(newtimeout) && newtimeout>0)    timeout=newtimeout;    return oldtimeout;   }      //! @param newportalbuffersize   //! Sets the new portalbuffersize for buffering partially concurrent queries.   //!   //! @returns   //! The previous portalbuffersize.   //!   //! @note   //! This function is PostgreSQL-specific, and thus it is not available   //! through the generic SQL-interface.   int setportalbuffersize(void|int newportalbuffersize)   { int oldportalbuffersize=portalbuffersize; -  if(!zero_type(newportalbuffersize) && newportalbuffersize>0) +  if(!undefinedp(newportalbuffersize) && newportalbuffersize>0)    portalbuffersize=newportalbuffersize;    return oldportalbuffersize;   }      //! @param newfetchlimit   //! Sets the new fetchlimit to interleave queries.   //!   //! @returns   //! The previous fetchlimit.   //!   //! @note   //! This function is PostgreSQL-specific, and thus it is not available   //! through the generic SQL-interface.   int setfetchlimit(void|int newfetchlimit)   { int oldfetchlimit=_fetchlimit; -  if(!zero_type(newfetchlimit) && newfetchlimit>=0) +  if(!undefinedp(newfetchlimit) && newfetchlimit>=0)    _fetchlimit=newfetchlimit;    return oldfetchlimit;   }      final private string glob2reg(string glob)   { if(!glob||!sizeof(glob))    return "%";    return replace(glob,({"*","?","\\","%","_"}),({"%","_","\\\\","\\%","\\_"}));   }   
pike.git/lib/modules/Sql.pmod/pgsql.pike:1076:    break;    case protocolerror:    array(string) msg=lastmessage;    lastmessage=({});phasedreconnect();msg+=lastmessage;    string s=sizeof(msg)?a2nls(msg):"";    ERROR("%sProtocol error with database %s\n",s,host_info());    break;    case noerror:    break;    } -  if(zero_type(waitforstate)) +  if(undefinedp(waitforstate))    break;    }    PD("Found state %O\n",_mstate);    return _mstate;   }      #ifndef UNBUFFEREDIO   private int read_cb(mixed foo, string d)   { _c.unread(d);    do _decodemsg();
pike.git/lib/modules/Sql.pmod/pgsql.pike:1143:    }    _closesent=0;    _mstate=unauthenticated;    qstate=queryidle;    portalsinflight=unnamedportalinuse=0;    array(string) plugbuf=({"",_c.plugint32(PG_PROTOCOL(3,0))});    if(user)    plugbuf+=({"user\0",user,"\0"});    if(database)    plugbuf+=({"database\0",database,"\0"}); -  options->reconnect=zero_type(options->reconnect) || options->reconnect; +  options->reconnect=undefinedp(options->reconnect) || options->reconnect;    foreach((options+_runtimeparameter)    -(<"use_ssl","force_ssl","cache_autoprepared_statements","reconnect",    "text_query","is_superuser","server_encoding","server_version",    "integer_datetimes","session_authorization">);    string name;mixed value)    plugbuf+=({name,"\0",(string)value,"\0"});    plugbuf+=({"\0"});    int len=4;    foreach(plugbuf;;string s)    len+=sizeof(s);
pike.git/lib/modules/Sql.pmod/pgsql.pike:1783:    throw("Unnamed portal in use, needed for simple query");    }    else if(forcecache==1    || forcecache!=0 && (sizeof(q)>=MINPREPARELENGTH || cachealways[q]))    { array(string) plugbuf=({});    if(tp=prepareds[q])    { if(tp->preparedname)    prepstmtused++, preparedname=tp->preparedname;    else if((tstart=tp->trun)    && tp->tparse*FACTORPLAN>=tstart -  && (zero_type(options->cache_autoprepared_statements) +  && (undefinedp(options->cache_autoprepared_statements)    || options->cache_autoprepared_statements))    preparedname=PREPSTMTPREFIX+(string)pstmtcount++;    }    else    { if(totalhits>=cachedepth)    { foreach(prepareds;string ind;tp)    { int oldhits=tp->hits;    totalhits-=oldhits-(tp->hits=oldhits>>1);    if(oldhits<=1)    { plugbuf+=closestatement(tp);
pike.git/lib/modules/Sql.pmod/pgsql.pike:1876:    }    array dtoid=_c.portal->_datatypeoid;    if(sizeof(dtoid)!=sizeof(paramValues))    USERERROR(    sprintf("Invalid number of bindings, expected %d, got %d\n",    sizeof(dtoid),sizeof(paramValues)));    foreach(dtoid;;int textbin)    plugbuf+=({_c.plugint16(oidformat(textbin))});    plugbuf+=({_c.plugint16(sizeof(paramValues))});    foreach(paramValues;int i;mixed value) -  { if(zero_type(value)) +  { if(undefinedp(value))    plugbuf+=({_c.plugint32(-1)}); // NULL    else if(stringp(value) && !sizeof(value))    { int k=0;    switch(dtoid[i])    { default:    k=-1; // cast empty strings to NULL for non-string types    case BYTEAOID:    case TEXTOID:    case XMLOID:    case BPCHAROID: