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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:47:   //! @endul   //! Check the PostgreSQL documentation for further details.   //!   //! @note   //! Multiple simultaneous queries on the same database connection are a   //! feature that none of the other database drivers for Pike support.   //! So, although it's efficient, its use will make switching database drivers   //! difficult.   //!   //! @seealso - //! @[Sql.Sql], @[Sql.postgres], + //! @[Sql.Connection], @[Sql.postgres],   //! @url{https://www.postgresql.org/docs/current/static/@}      #pike __REAL_VERSION__   #pragma dynamic_dot   #require constant(Thread.Thread)      #include "pgsql.h"      #define ERROR(X ...) predef::error(X)   
pike.git/lib/modules/Sql.pmod/pgsql.pike:162:   //! server doesn't respond, if the database doesn't exist or is not   //! accessible to you.   //!   //! @note   //! It is possible that the exception from a failed connect   //! will not be triggered on this call (because the connect   //! proceeds asynchronously in the background), but on the first   //! attempt to actually use the database instead.   //!   //! @seealso - //! @[Postgres.postgres], @[Sql.Sql], @[select_db()], + //! @[Postgres.postgres], @[Sql.Connection], @[select_db()],   //! @url{https://www.postgresql.org/docs/current/static/runtime-config-client.html@}   protected void create(void|string host, void|string database,    void|string user, void|string pass,    void|mapping(string:mixed) options) {    string spass = pass && pass != "" ? Standards.IDNA.to_ascii(pass) : pass;    if(pass) {    String.secure(pass);    pass = "CENSORED";    }    proxy = .pgsql_util.proxy(host, database,
pike.git/lib/modules/Sql.pmod/pgsql.pike:676:    return DRIVERNAME"/" + (proxy.runtimeparameter.server_version || "unknown");   }      //! @returns   //! An array of the databases available on the server.   //!   //! @param glob   //! If specified, list only those databases matching it.   /*semi*/final array(string) list_dbs (void|string glob) {    array row, ret = .pgsql_util.emptyarray; -  .pgsql_util.sql_result res=big_query("SELECT d.datname " +  .pgsql_util.Result res=big_query("SELECT d.datname "    "FROM pg_database d "    "WHERE d.datname ILIKE :glob "    "ORDER BY d.datname",    ([":glob":glob2reg(glob)]));    while(row = res->fetch_row())    ret += ({row[0]});    return ret;   }      //! @returns   //! An array containing the names of all the tables and views in the   //! path in the currently selected database.   //!   //! @param glob   //! If specified, list only the tables with matching names.   /*semi*/final array(string) list_tables (void|string glob) {    array row, ret = .pgsql_util.emptyarray; -  .pgsql_util.sql_result res = big_query( // due to missing schemasupport +  .pgsql_util.Result res = big_query( // due to missing schemasupport    // This query might not work on PostgreSQL 7.4    "SELECT CASE WHEN 'public'=n.nspname THEN '' ELSE n.nspname||'.' END "    " ||c.relname AS name "    "FROM pg_catalog.pg_class c "    " LEFT JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace "    "WHERE c.relkind IN ('r','v') AND n.nspname<>'pg_catalog' "    " AND n.nspname !~ '^pg_toast' AND pg_catalog.pg_table_is_visible(c.oid) "    " AND c.relname ILIKE :glob "    " ORDER BY 1",    ([":glob":glob2reg(glob)]));
pike.git/lib/modules/Sql.pmod/pgsql.pike:757:   //! @param glob   //! If specified, list only the tables with matching names.   //! Setting it to @expr{*@} will include system columns in the list.   /*semi*/final array(mapping(string:mixed)) list_fields(void|string table,    void|string glob) {    array row, ret = .pgsql_util.emptyarray;    string schema;       sscanf(table||"*", "%s.%s", schema, table);    -  .pgsql_util.sql_result res = big_typed_query( +  .pgsql_util.Result res = big_typed_query(    "SELECT a.attname, a.atttypid, t.typname, a.attlen, "    " c.relhasindex, c.relhaspkey, CAST(c.reltuples AS BIGINT) AS reltuples, "    " (c.relpages "    " +COALESCE( "    " (SELECT SUM(tst.relpages) "    " FROM pg_catalog.pg_class tst "    " WHERE tst.relfilenode=c.reltoastrelid) "    " ,0) "    " )*8192::BIGINT AS datasize, "    " (COALESCE( "
pike.git/lib/modules/Sql.pmod/pgsql.pike:906:   //! @endmapping   //!   //! @note   //! The bindings-parameter passed to this function must remain unaltered   //! until the parameters have been sent to the database. The driver   //! currently does not expose this moment, but to avoid a race condition   //! it is sufficient to keep them unaltered until the first resultrow   //! has been fetched (or EOF is reached, in case of no resultrows).   //!   //! @returns - //! A @[Sql.pgsql_util.sql_result] object (which conforms to the - //! @[Sql.sql_result] standard interface for accessing data). It is + //! A @[Sql.pgsql_util.Result] object (which conforms to the + //! @[Sql.Result] standard interface for accessing data). It is   //! recommended to use @[query()] for simpler queries (because   //! it is easier to handle, but stores all the result in memory), and   //! @[big_query()] for queries you expect to return huge amounts of   //! data (it's harder to handle, but fetches results on demand).   //!   //! @note   //! This function @b{can@} raise exceptions.   //!   //! @note   //! This function supports multiple simultaneous queries (portals) on a single
pike.git/lib/modules/Sql.pmod/pgsql.pike:931:   //! @note   //! This function, by default, 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 unquoted semicolon. This can   //! be viewed as a limited protection against SQL-injection attacks.   //! To make it support multiple queries in one querystring, use the   //! @ref{:_text@} option (not recommended).   //!   //! @seealso - //! @[big_typed_query()], @[Sql.Sql], @[Sql.sql_result], - //! @[query()], @[Sql.pgsql_util.sql_result] - /*semi*/final .pgsql_util.sql_result big_query(string q, + //! @[big_typed_query()], @[Sql.Connection], @[Sql.Result], + //! @[query()], @[Sql.pgsql_util.Result] + /*semi*/final .pgsql_util.Result big_query(string q,    void|mapping(string|int:mixed) bindings,    void|int _alltyped) {    throwdelayederror(this);    string preparedname = "";    mapping(string:mixed) options = proxy.options;    .pgsql_util.conxion c = proxy.c;    int forcecache = -1, forcetext = options.text_query;    int syncparse = zero_type(options.sync_parse)    ? -1 : options.sync_parse;    if (proxy.waitforauthready)
pike.git/lib/modules/Sql.pmod/pgsql.pike:1063:    closestatement(plugbuffer, np.preparedname);    m_delete(np, "preparedname");    }    }    if (sizeof(CHAIN(plugbuffer))) {    PD("%O\n",(string)CHAIN(plugbuffer));    plugbuffer->sendcmd(FLUSHSEND); // close expireds    } else    plugbuffer->sendcmd(KEEP); // close start()    tstart = gethrtime(); -  } else // sql_result autoassigns to portal +  } else // Result autoassigns to portal    tp = 0; -  .pgsql_util.sql_result portal; -  portal = .pgsql_util.sql_result(proxy, c, q, portalbuffersize, _alltyped, +  .pgsql_util.Result portal; +  portal = .pgsql_util.Result(proxy, c, q, portalbuffersize, _alltyped,    from, forcetext, timeout, syncparse, transtype);    portal._tprepared = tp;   #ifdef PG_STATS    portalsopened++;   #endif    proxy.clearmessage = 1;    if (forcetext) { // FIXME What happens if portals are still open?    portal._unnamedportalkey = proxy.unnamedportalmux->lock(1);    portal._portalname = "";    portal->_parseportal(); portal->_bindportal();
pike.git/lib/modules/Sql.pmod/pgsql.pike:1143:    portal._unnamedstatementkey = 0; // Cover for a destruct race    }    throwdelayederror(portal);    return portal;   }      //! This is an alias for @[big_query()], since @[big_query()] already supports   //! streaming of multiple simultaneous queries through the same connection.   //!   //! @seealso - //! @[big_query()], @[big_typed_query()], @[Sql.Sql], @[Sql.sql_result] - /*semi*/final inline .pgsql_util.sql_result streaming_query(string q, + //! @[big_query()], @[big_typed_query()], @[Sql.Connection], @[Sql.Result] + /*semi*/final inline .pgsql_util.Result streaming_query(string q,    void|mapping(string|int:mixed) bindings) {    return big_query(q, bindings);   }      //! This function returns an object that allows streaming and typed   //! results.   //!   //! @seealso - //! @[big_query()], @[Sql.Sql], @[Sql.sql_result] - /*semi*/final inline .pgsql_util.sql_result big_typed_query(string q, + //! @[big_query()], @[Sql.Connection], @[Sql.Result] + /*semi*/final inline .pgsql_util.Result big_typed_query(string q,    void|mapping(string|int:mixed) bindings) {    return big_query(q, bindings, 1);   }