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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:8:   //! PostgreSQL server running on @b{your@} host to use this module: you can   //! connect to the database over a TCP/IP socket on a different host.   //!   //! This module replaces the functionality of the older @[Sql.postgres]   //! and @[Postgres.postgres] modules.   //!   //! This module supports the following features:   //! @ul   //! @item   //! PostgreSQL network protocol version 3, authentication methods - //! currently supported are: cleartext and MD5 (recommended). + //! currently supported are: cleartext, md5 and scram (recommended).   //! @item   //! Streaming queries which do not buffer the whole resultset in memory.   //! @item   //! Automatic binary transfers to and from the database for most common   //! datatypes (amongst others: integer, text and bytea types).   //! @item   //! Automatic character set conversion and native wide string support.   //! Supports UTF8/Unicode for multibyte characters, and all single-byte   //! character sets supported by the database.   //! @item
pike.git/lib/modules/Sql.pmod/pgsql.pike:307:    waitauthready();    return is_open() && !catch(c->start()->sendcmd(FLUSHSEND)) ? 0 : -1;   }      //! Cancels all currently running queries in this session.   //!   //! @seealso   //! @[reload()], @[resync()]   //!   //! @note - //! This function is PostgreSQL-specific, and thus it is not available - //! through the generic SQL-interface. + //! This function is PostgreSQL-specific.   /*semi*/final void cancelquery() {    PD("CancelRequest\n");    .pgsql_util.conxion lcon = .pgsql_util.conxion(this, 0, 2);    lcon->add_int32(16)->add_int32(PG_PROTOCOL(1234,5678))    ->add_int32(backendpid)->add(cancelsecret)->sendcmd(FLUSHSEND);    destruct(lcon); // Destruct explicitly to avoid delayed close   #ifdef PG_DEBUGMORE    PD("Closetrace %O\n",backtrace());   #endif   }
pike.git/lib/modules/Sql.pmod/pgsql.pike:382:   //! @endmapping   //!   //! The values can be changed during a session using SET commands to the   //! database.   //! For other runtimeparameters check the PostgreSQL documentation.   //!   //! @seealso   //! @url{http://www.postgresql.org/search/?u=%2Fdocs%2Fcurrent%2F&q=client+connection+search_path@}   //!   //! @note - //! This function is PostgreSQL-specific, and thus it is not available - //! through the generic SQL-interface. + //! This function is PostgreSQL-specific.   /*semi*/final mapping(string:string) getruntimeparameters() {    waitauthready();    return _runtimeparameter+([]);   }      //! @returns   //! A set of statistics for the current session:   //! @mapping   //! @member int "warnings_dropped"   //! Number of warnings/notices generated by the database but not
pike.git/lib/modules/Sql.pmod/pgsql.pike:424:   //! @member int "bytes_received"   //! Total number of bytes received from the database so far.   //! @member int "messages_received"   //! Total number of messages received from the database (one SQL-statement   //! requires multiple messages to be exchanged).   //! @member int "portals_in_flight"   //! Currently still open portals, i.e. running statements.   //! @endmapping   //!   //! @note - //! This function is PostgreSQL-specific, and thus it is not available - //! through the generic SQL-interface. + //! This function is PostgreSQL-specific.   /*semi*/final mapping(string:mixed) getstatistics() {    mapping(string:mixed) stats=([    "warnings_dropped":warningsdropcount,    "current_prepared_statements":sizeof(_prepareds),    "current_prepared_statement_hits":totalhits,    "prepared_statement_count":pstmtcount,   #ifdef PG_STATS    "used_prepared_statements":prepstmtused,    "skipped_describe_count":skippeddescribe,    "portals_opened_count":portalsopened,
pike.git/lib/modules/Sql.pmod/pgsql.pike:450:    return stats;   }      //! @param newdepth   //! 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. + //! This function is PostgreSQL-specific.   /*semi*/final int setcachedepth(void|int newdepth) {    int olddepth=cachedepth;    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. + //! This function is PostgreSQL-specific.   /*semi*/final int settimeout(void|int newtimeout) {    int oldtimeout=timeout;    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. + //! This function is PostgreSQL-specific.   /*semi*/final int setportalbuffersize(void|int newportalbuffersize) {    int oldportalbuffersize=portalbuffersize;    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. + //! This function is PostgreSQL-specific.   /*semi*/final int setfetchlimit(void|int newfetchlimit) {    int oldfetchlimit=_fetchlimit;    if(!undefinedp(newfetchlimit) && newfetchlimit>=0)    _fetchlimit=newfetchlimit;    return oldfetchlimit;   }      private string glob2reg(string glob) {    if(!glob||!sizeof(glob))    return "%";
pike.git/lib/modules/Sql.pmod/pgsql.pike:1290:    if (err) {    PD("Terminating processloop due to %s\n", describe_backtrace(err));    }    catch(_connectfail(err));   }      //! Closes the connection to the database, any running queries are   //! terminated instantly.   //!   //! @note - //! This function is PostgreSQL-specific, and thus it is not available - //! through the generic SQL-interface. + //! This function is PostgreSQL-specific.   /*semi*/final void close() {    throwdelayederror(this);    Thread.MutexKey lock;    if (qportals && qportals->size())    catch(cancelquery());    if (unnamedstatement)    termlock = unnamedstatement->lock(1);    if (c) // Prevent trivial backtraces    c->close();    if (unnamedstatement)
pike.git/lib/modules/Sql.pmod/pgsql.pike:1385:   //! close all open cursors, drop all temporary tables and reset all   //! session variables to their default values.   //!   //! @note   //! This function @b{can@} raise exceptions.   //!   //! @seealso   //! @[cancelquery()], @[reload()]   //!   //! @note - //! This function is PostgreSQL-specific, and thus it is not available - //! through the generic SQL-interface. + //! This function is PostgreSQL-specific.   /*semi*/final void resync() {    mixed err;    if(is_open()) {    err = catch {    PD("Statementsinflight: %d Portalsinflight: %d\n",    _statementsinflight, _portalsinflight);    if(!waitforauthready) {    readyforquery_cb=resync_cb;    sendsync();    }
pike.git/lib/modules/Sql.pmod/pgsql.pike:1452:   //! The callback function must return no value.   //!   //! @param selfnotify   //! Normally notify events generated by your own session are ignored.   //! If you want to receive those as well, set @ref{selfnotify@} to one.   //!   //! @param args   //! Extra arguments to pass to @ref{notify_cb@}.   //!   //! @note - //! This function is PostgreSQL-specific, and thus it is not available - //! through the generic SQL-interface. + //! This function is PostgreSQL-specific.   /*semi*/final void set_notify_callback(string condition,    void|function(int,string,string,mixed ...:void) notify_cb,void|int selfnotify,    mixed ... args) {    if(!notify_cb)    m_delete(notifylist,condition);    else {    array old=notifylist[condition];    if(!old)    old=({notify_cb});    if(selfnotify||args)
pike.git/lib/modules/Sql.pmod/pgsql.pike:1507:   //! The given string, but escapes/quotes all contained magic characters   //! for binary (bytea) arguments in textual SQL-queries.   //!   //! @note   //! Quoting must not be done for parameters passed in bindings.   //!   //! @seealso   //! @[big_query()], @[quote()]   //!   //! @note - //! This function is PostgreSQL-specific, and thus it is not available - //! through the generic SQL-interface. + //! This function is PostgreSQL-specific.   /*semi*/final string quotebinary(string s) {    return replace(s, ({ "'", "\\", "\0" }), ({ "''", "\\\\", "\\000" }) );   }      //! This function creates a new database (assuming we   //! have sufficient privileges to do this).   //!   //! @param db   //! Name of the new database.   //!
pike.git/lib/modules/Sql.pmod/pgsql.pike:1739:      //! @returns   //! The current commitstatus of the connection. Returns either one of:   //! @string   //! @value idle   //! @value intransaction   //! @value infailedtransaction   //! @endstring   //!   //! @note - //! This function is PostgreSQL-specific, and thus it is not available - //! through the generic SQL-interface. + //! This function is PostgreSQL-specific.   final string status_commit() {    return trbackendst(backendstatus);   }      private inline void closestatement(    .pgsql_util.bufcon|.pgsql_util.conxsess plugbuffer,string oldprep) {    .pgsql_util.closestatement(plugbuffer,oldprep);   }      private inline string int2hex(int i) {