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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:171:    reconnect();   }      //! @decl string error()   //!   //! This function returns the textual description of the last   //! server-related error. Returns @expr{0@} if no error has occurred   //! yet. It is not cleared upon reading (can be invoked multiple   //! times, will return the same result until a new error occurs).   //! + //! During the execution of a statement, this function accumulates all + //! non-error messages (notices, warnings, etc.). If a statement does not + //! generate any errors, this function will return all collected messages + //! from the last statement. + //!   //! To clear the error, pass 1 as argument.   //!   //! @seealso   //! big_query   string error(void|int clear) {    string s=lastmessage;    if(clear)    lastmessage=UNDEFINED;    return s;   }      //! @decl string host_info()   //!   //! This function returns a string describing what host are we talking to,   //! and how (TCP/IP or UNIX sockets). -  + //! + //! @seealso + //! server_info   string host_info() {    return sprintf("Via fd:%d over TCP/IP to %s:%d",_c.query_fd(),host,port);   }      final private object getsocket(void|int nossl) {    object lcon = Stdio.File();    if(!lcon.connect(host,port))    return UNDEFINED;       object fcon;
pike.git/lib/modules/Sql.pmod/pgsql.pike:232:    host,port);   #endif    fcon=.pgsql_util.PGconn(lcon,this);    return fcon;   }      //! Cancels the currently running query.   //!   //! This function is PostgreSQL-specific, and thus it is not available   //! through the generic SQL-interface. + //! + //! @seealso + //! reload   void cancelquery() {    if(qstate==inquery) {    qstate=cancelpending;    object lcon;    PD("CancelRequest\n");    if(!(lcon=getsocket(1)))    ERROR("Cancel connect failed\n");    lcon.write(({_c.plugint32(16),_c.plugint32(PG_PROTOCOL(1234,5678)),    _c.plugint32(backendpid),cancelsecret}));    lcon.close();
pike.git/lib/modules/Sql.pmod/pgsql.pike:390:    break;    case 2:PD("KerberosV5\n");    errtype=protocolunsupported;    break;    case 3:PD("ClearTextPassword\n");    sendpass=pass;    break;    case 4:PD("CryptPassword\n");    if(msglen<2)    errtype=protocolerror; -  sendpass=_c.getstring(msglen);msglen=0; -  errtype=protocolunsupported; +  sendpass=_c.getstring(msglen);msglen=0; // salt +  errtype=protocolunsupported; // Pike lacks function that takes salt    break;    case 5:PD("MD5Password\n");    if(msglen<4)    errtype=protocolerror;   #if constant(Crypto.MD5.hash)   #define md5hex(x) String.string2hex(Crypto.MD5.hash(x))    sendpass=md5hex(pass+user);    sendpass="md5"+md5hex(sendpass+_c.getstring(msglen));   #else    _c.getstring(msglen);
pike.git/lib/modules/Sql.pmod/pgsql.pike:743:    _c.write(plugbuf);    PD("%O\n",plugbuf);    _decodemsg(readyforquery);    PD("%O\n",runtimeparameter);   }      //! @decl void reload()   //!   //! Resets the connection to the database. Can be used for   //! a variety of reasons, for example to detect the status of a connection. + //! + //! @seealso + //! cancelquery   void reload(void|int special) {    mixed err;    int didsync;    if(err = catch {    sendclose(1);    PD("Portalsinflight: %d\n",portalsinflight);    if(!portalsinflight) {    if(!earlyclose) {    PD("Sync\n");    _c.sendcmd(({"S",_c.plugint32(4)}),2);
pike.git/lib/modules/Sql.pmod/pgsql.pike:877:   //! @seealso   //! create_db   void drop_db(string db) {    big_query("DROP DATABASE :db",([":db":db]));   }      //! This function returns a string describing the server we are   //! talking to. It has the form @expr{"servername/serverversion"@}   //! (like the HTTP protocol description) and is most useful in   //! conjunction with the generic SQL-server module. + //! + //! @seealso + //! host_info   string server_info () {    return DRIVERNAME"/"+(runtimeparameter->server_version||"unknown");   }      //! Lists all the databases available on the server.   //! If glob is specified, lists only those databases matching it.   array(string) list_dbs (void|string glob) {    array row,ret=({});    object res=big_query("SELECT d.datname "    "FROM pg_database d "
pike.git/lib/modules/Sql.pmod/pgsql.pike:1140:   //! @note   //! This function @b{can@} raise exceptions.   //!   //! @note   //! This function does not support multiple queries in one querystring.   //! I.e. it allows for but does not require a trailing semicolon, but it   //! simply ignores any commands after the first semicolon. This can be   //! viewed as a limited protection against SQL-injection attacks.   //!   //! @seealso - //! @[Sql.Sql], @[Sql.sql_result] + //! @[Sql.Sql], @[Sql.sql_result], @[Sql.pgsql_util.pgsql_result]   object big_query(string q,void|mapping(string|int:mixed) bindings) {    string preparedname="";    string portalname="";    if(stringp(q) && String.width(q)>8)    q=string_to_utf8(q);    array(string|int) paramValues;    if(bindings) {    int pi=0,rep=0;    paramValues=allocate(sizeof(bindings));    array(string) from=allocate(sizeof(bindings));