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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:48:   //!   //! @seealso   //! @[Sql.Sql], @[Sql.postgres]      #pike __REAL_VERSION__      #include "pgsql.h"      #define ERROR(X ...) predef::error(X)    + int _alltext; + int _booltext;   int _nextportal;   int _closesent;   int _fetchlimit=FETCHLIMIT;   private int unnamedportalinuse;   private int portalsinflight;      object _c;   private string SSauthdata,cancelsecret;   private int backendpid;   private int backendstatus;
pike.git/lib/modules/Sql.pmod/pgsql.pike:161:   //!   //! The options argument currently supports at least the following:   //! @string   //! @value "use_ssl"   //! If the database supports and allows SSL connections, the session   //! will be SSL encrypted, if not, the connection will fallback   //! to plain unencrypted   //! @value "force_ssl"   //! If the database supports and allows SSL connections, the session   //! will be SSL encrypted, if not, the connection will abort + //! @value "bool_results_as_text" + //! Make boolean values retrieved from the database backward compatible + //! with the old Postgres driver which returned all values as text. + //! When off, boolean values are represented by 0 and 1, when set, + //! boolean values are represented by "f" and "t". + //! @value "all_results_as_text" + //! Make all values backward compatible with the old Postgres driver + //! which returned all values as text. Implies boolresults_as_text.   //! @value "client_encoding"   //! Character encoding for the client side, it defaults to use   //! database encoding, e.g.: "SQL_ASCII"   //! @value "standard_conforming_strings"   //! When on, backslashes in strings must not be escaped any longer,   //! @[quote] automatically adjusts quoting strategy accordingly   //! @value "escape_string_warning"   //! When on, a warning is issued if a backslash (\) appears in an   //! ordinary string literal and @[standard_conforming_strings] is off,   //! defaults to on
pike.git/lib/modules/Sql.pmod/pgsql.pike:190:   //!   //! @seealso   //! @[Postgres.postgres], @[Sql.Sql], @[postgres->select_db]   protected void create(void|string _host, void|string _database,    void|string _user, void|string _pass, void|mapping(string:mixed) _options) {    pass = _pass; _pass = "CENSORED";    if(pass)    String.secure(pass);    user = _user; database = _database; host = _host || PGSQL_DEFAULT_HOST;    options = _options || ([]); +  _alltext = !!options->all_results_as_text; +  _booltext = _alltext || !!options->bool_results_as_text;    if(search(host,":")>=0 && sscanf(_host,"%s:%d",host,port)!=2)    ERROR("Error in parsing the hostname argument\n");    if(!port)    port = PGSQL_DEFAULT_PORT;    _querymutex=Thread.Mutex();    _stealmutex=Thread.Mutex();    reconnect();   }      //! @decl string error()
pike.git/lib/modules/Sql.pmod/pgsql.pike:722:    if(_c.portal) {    if(tprepared)    storetiming();   #ifdef USEPGsql    _c.decodedatarow(msglen);msglen=0;   #else    array a, datarowdesc;    _c.portal->_bytesreceived+=msglen;    datarowdesc=_c.portal->_datarowdesc;    int cols=_c.getint16(); +  int atext = _alltext; // cache locally for speed ? +  int btext = _booltext; // cache locally for speed ?    a=allocate(cols,UNDEFINED);    msglen-=2+4*cols;    foreach(a;int i;) {    int collen=_c.getint32();    if(collen>0) {    msglen-=collen;    mixed value;    switch(datarowdesc[i]->type) {    default:value=_c.getstring(collen);    break; -  case CHAROID: +  case CHAROID:value=_c.getbyte(); +  break;    case BOOLOID:value=_c.getbyte(); -  +  if(btext) +  value=value?"t":"f";    break;    case INT8OID:value=_c.getint64();    break;    case FLOAT4OID:value=(float)_c.getstring(collen);    break;    case INT2OID:value=_c.getint16();    break;    case OIDOID:    case INT4OID:value=_c.getint32();    } -  +  if(atext&&!stringp(value)) +  value=(string)value;    a[i]=value;    }    else if(!collen)    a[i]="";    }    a=({a});    _c.portal->_datarows+=a;    _c.portal->_inflight-=sizeof(a);   #endif    }
pike.git/lib/modules/Sql.pmod/pgsql.pike:944:    ERROR("Couldn't connect to database on %s:%d\n",host,port);    _closesent=0;    _mstate=unauthenticated;    qstate=queryidle;    runtimeparameter=([]);    array(string) plugbuf=({"",_c.plugint32(PG_PROTOCOL(3,0))});    if(user)    plugbuf+=({"user\0",user,"\0"});    if(database)    plugbuf+=({"database\0",database,"\0"}); -  foreach(options-(<"use_ssl","force_ssl">);string name;mixed value) +  foreach(options-(<"use_ssl","force_ssl","bool_results_as_text", +  "all_results_as_text">); +  string name;mixed value)    plugbuf+=({name,"\0",(string)value,"\0"});    plugbuf+=({"\0"});    int len=4;    foreach(plugbuf;;string s)    len+=sizeof(s);    plugbuf[0]=_c.plugint32(len);    _c.write(plugbuf);    PD("%O\n",plugbuf);    _decodemsg(readyforquery);    PD("%O\n",runtimeparameter);