pike.git/
lib/
modules/
Sql.pmod/
pgsql.pike
Branch:
Tag:
Non-build tags
All tags
No tags
2014-11-24
2014-11-24 09:55:50 by Stephen R. van den Berg <srb@cuci.nl>
e7c5c8e1817f47a85218269d37c81917f3f90ffd (
62
lines) (+
32
/-
30
)
[
Show
|
Annotate
]
Branch:
8.1
pgsql: /*semi*/final for efficiency.
242:
//! //! @seealso //! @[big_query()]
-
string error(void|int clear) {
+
/*semi*/final
string error(void|int clear) {
throwdelayederror(this); string s=lastmessage*"\n"; if(clear)
256:
//! //! @seealso //! @[server_info()]
-
string host_info() {
+
/*semi*/final
string host_info() {
return sprintf("fd:%d TCP/IP %s:%d PID %d", c?c->socket->query_fd():-1,_host,_port,backendpid); }
273:
//! //! @seealso //! @[ping()]
-
int is_open() {
+
/*semi*/final
int is_open() {
catch { return c->socket->is_open(); };
297:
//! //! @seealso //! @[is_open()]
-
int ping() {
+
/*semi*/final
int ping() {
return is_open() && !catch(c->start()->sendcmd(FLUSHSEND)) ? !!reconnected : -1; }
314:
//! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
void cancelquery() {
+
/*semi*/final
void cancelquery() {
PD("CancelRequest\n"); .pgsql_util.conxion lcon=getsocket(1); lcon->add_int32(16)->add_int32(PG_PROTOCOL(1234,5678))
341:
//! @seealso //! @[get_charset()], @[create()], //! @url{http://www.postgresql.org/search/?u=%2Fdocs%2Fcurrent%2F&q=character+sets@}
-
void set_charset(string charset) {
+
/*semi*/final
void set_charset(string charset) {
if(charset) big_query(sprintf("SET CLIENT_ENCODING TO '%s'",quote(charset))); }
352:
//! @seealso //! @[set_charset()], @[getruntimeparameters()], //! @url{http://www.postgresql.org/search/?u=%2Fdocs%2Fcurrent%2F&q=character+sets@}
-
string get_charset() {
+
/*semi*/final
string get_charset() {
waitauthready(); return _runtimeparameter[CLIENT_ENCODING]; }
396:
//! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
mapping(string:string) getruntimeparameters() {
+
/*semi*/final
mapping(string:string) getruntimeparameters() {
waitauthready(); return _runtimeparameter+([]); }
440:
//! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
mapping(string:mixed) getstatistics() {
+
/*semi*/final
mapping(string:mixed) getstatistics() {
mapping(string:mixed) stats=([ "warnings_dropped":warningsdropcount, "current_prepared_statements":sizeof(_prepareds),
468:
//! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
int setcachedepth(void|int newdepth) {
+
/*semi*/final
int setcachedepth(void|int newdepth) {
int olddepth=cachedepth; if(!undefinedp(newdepth) && newdepth>=0) cachedepth=newdepth;
484:
//! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
int settimeout(void|int newtimeout) {
+
/*semi*/final
int settimeout(void|int newtimeout) {
int oldtimeout=timeout; if(!undefinedp(newtimeout) && newtimeout>0) { timeout=newtimeout;
503:
//! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
int setportalbuffersize(void|int newportalbuffersize) {
+
/*semi*/final
int setportalbuffersize(void|int newportalbuffersize) {
int oldportalbuffersize=portalbuffersize; if(!undefinedp(newportalbuffersize) && newportalbuffersize>0) portalbuffersize=newportalbuffersize;
519:
//! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
int setfetchlimit(void|int newfetchlimit) {
+
/*semi*/final
int setfetchlimit(void|int newfetchlimit) {
int oldfetchlimit=_fetchlimit; if(!undefinedp(newfetchlimit) && newfetchlimit>=0) _fetchlimit=newfetchlimit;
1178:
//! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
void close() {
+
/*semi*/final
void close() {
catch(cancelquery()); catch(c->sendterminate()); c=0;
1190:
.pgsql_util.unregister_backend(); }
-
void _connectfail(void|mixed err) {
+
final
void _connectfail(void|mixed err) {
PD("Connect failed %O reconnectdelay %d\n",err,reconnectdelay); destruct(waitforauthready); if(!err || reconnectdelay) {
1275:
//! //! @seealso //! @[resync()], @[cancelquery()]
-
void reload() {
+
/*semi*/final
void reload() {
resync(); }
1321:
//! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
void resync() {
+
/*semi*/final
void resync() {
mixed err; if(is_open()) { err = catch {
1349:
//! //! @seealso //! @[create()]
-
void select_db(string dbname) {
+
/*semi*/final
void select_db(string dbname) {
database=dbname; reconnect(); reconnected=0;
1389:
//! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
void set_notify_callback(string condition,
+
/*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)
1423:
//! //! @seealso //! @[big_query()], @[quotebinary()], @[create()]
-
string quote(string s) {
+
/*semi*/final
string quote(string s) {
waitauthready(); string r=_runtimeparameter.standard_conforming_strings; if(r && r=="on")
1444:
//! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
string quotebinary(string s) {
+
/*semi*/final
string quotebinary(string s) {
return replace(s, ({ "'", "\\", "\0" }), ({ "''", "\\\\", "\\000" }) ); }
1456:
//! //! @seealso //! @[drop_db()]
-
void create_db(string db) {
+
/*semi*/final
void create_db(string db) {
big_query(sprintf("CREATE DATABASE %s",db)); }
1470:
//! //! @seealso //! @[create_db()]
-
void drop_db(string db) {
+
/*semi*/final
void drop_db(string db) {
big_query(sprintf("DROP DATABASE %s",db)); }
1482:
//! //! @seealso //! @[host_info()]
-
string server_info () {
+
/*semi*/final
string server_info () {
waitauthready(); return DRIVERNAME"/"+(_runtimeparameter.server_version||"unknown"); }
1492:
//! //! @param glob //! If specified, list only those databases matching it.
-
array(string) list_dbs (void|string glob) {
+
/*semi*/final
array(string) list_dbs (void|string glob) {
array row,ret=({}); .pgsql_util.sql_result res=big_query("SELECT d.datname " "FROM pg_database d "
1510:
//! //! @param glob //! If specified, list only the tables with matching names.
-
array(string) list_tables (void|string glob) {
+
/*semi*/final
array(string) list_tables (void|string glob) {
array row,ret=({}); // This query might not work on PostgreSQL 7.4 .pgsql_util.sql_result res=big_query( // due to missing schemasupport "SELECT CASE WHEN 'public'=n.nspname THEN '' ELSE n.nspname||'.' END "
1567:
//! @param glob //! If specified, list only the tables with matching names. //! Setting it to @expr{*@} will include system columns in the list.
-
array(mapping(string:mixed)) list_fields(void|string table, void|string glob) {
+
/*semi*/final
array(mapping(string:mixed)) list_fields(void|string table,
+
void|string glob) {
array row, ret=({}); string schema=UNDEFINED;
1752:
//! @seealso //! @[big_typed_query()], @[Sql.Sql], @[Sql.sql_result], //! @[Sql.Sql()->query()], @[Sql.pgsql_util.sql_result]
-
.pgsql_util.sql_result big_query(string q,
+
/*semi*/final
.pgsql_util.sql_result big_query(string q,
void|mapping(string|int:mixed) bindings, void|int _alltyped) { throwdelayederror(this);
1936:
//! //! @seealso //! @[big_query()], @[big_typed_query()], @[Sql.Sql], @[Sql.sql_result]
-
.pgsql_util.sql_result streaming_query(string q,
+
/*semi*/final
.pgsql_util.sql_result streaming_query(string q,
void|mapping(string|int:mixed) bindings) { return big_query(q,bindings); }
1946:
//! //! @seealso //! @[big_query()], @[Sql.Sql], @[Sql.sql_result]
-
.pgsql_util.sql_result big_typed_query(string q,
+
/*semi*/final
.pgsql_util.sql_result big_typed_query(string q,
void|mapping(string|int:mixed) bindings) { return big_query(q,bindings,1); }