pike.git
/
lib
/
modules
/
Sql.pmod
/
pgsql_util.pmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:148:
if(!--realbuffer->stashcount) realbuffer->stashavail.signal(); lock=0; this->clear(); if(lock=realbuffer->nostash->trylock(1)) { realbuffer->started=lock; lock=0; realbuffer->sendcmd(SENDOUT); } }
-
}
+
}
;
class conxiin { inherit Stdio.Buffer:i; final Thread.Condition fillread; final Thread.Mutex fillreadmux; final function(:void) gottimeout; final int timeout; protected bool range_error(int howmuch) {
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:189:
return 0; } protected void create() { i::create(); gottimeout=nop; // Preset it with a NOP timeout=128; // Just a reasonable amount fillreadmux=Thread.Mutex(); fillread=Thread.Condition(); }
-
}
+
}
;
class conxion { inherit Stdio.Buffer:o; final conxiin i; private Thread.Queue qportals; final Thread.Mutex shortmux; final Stdio.File socket; private object pgsqlsess; private int towrite;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:399:
socket=Stdio.File(); i=conxiin(); shortmux=Thread.Mutex(); nostash=Thread.Mutex(); stashavail=Thread.Condition(); stashqueue=Thread.Queue(); stash=Stdio.Buffer(); pgsqlsess=_pgsqlsess; Thread.Thread(connectloop,nossl); }
-
}
+
}
;
//! The result object returned by @[Sql.pgsql()->big_query()], except for //! the noted differences it behaves the same as @[Sql.sql_result]. //! //! @seealso //! @[Sql.sql_result], @[Sql.pgsql], @[Sql.Sql], @[Sql.pgsql()->big_query()] class sql_result { private object pgsqlsess; private int eoffound;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:479:
} //! Returns the command-complete status for this query. //! //! @seealso //! @[affected_rows()] //! //! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
string status_command_complete() {
+
/*semi*/final
string status_command_complete() {
return statuscmdcomplete; } //! Returns the number of affected rows by this query. //! //! @seealso //! @[status_command_complete()] //! //! @note //! This function is PostgreSQL-specific, and thus it is not available //! through the generic SQL-interface.
-
int affected_rows() {
+
/*semi*/final
int affected_rows() {
int rows; if(statuscmdcomplete) sscanf(statuscmdcomplete,"%*s %d",rows); return rows; } final void _storetiming() { if(_tprepared) { _tprepared.trun=gethrtime()-_tprepared.trunstart; m_delete(_tprepared,"trunstart");
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:515:
private void waitfordescribe() { Thread.MutexKey lock=_ddescribemux->lock(); if(!datarowtypes) _ddescribe->wait(lock); lock=0; } //! @seealso //! @[Sql.sql_result()->num_fields()]
-
int num_fields() {
+
/*semi*/final
int num_fields() {
if(!datarowtypes) waitfordescribe(); trydelayederror(); return sizeof(datarowtypes); } //! @seealso //! @[Sql.sql_result()->num_rows()]
-
int num_rows() {
+
/*semi*/final
int num_rows() {
trydelayederror(); return rowsreceived; } private inline void trydelayederror() { if(_delayederror) throwdelayederror(this); } //! @seealso //! @[Sql.sql_result()->eof()]
-
int eof() {
+
/*semi*/final
int eof() {
trydelayederror(); return eoffound; } //! @seealso //! @[Sql.sql_result()->fetch_fields()]
-
array(mapping(string:mixed)) fetch_fields() {
+
/*semi*/final
array(mapping(string:mixed)) fetch_fields() {
if(!datarowtypes) waitfordescribe(); trydelayederror(); return datarowdesc+({}); } #ifdef PG_DEBUG
-
final
int
+
#define
INTVOID
int
#else
-
final
void
+
#define
INTVOID
void
#endif
-
_decodedata(int msglen,string cenc) {
+
final
INTVOID
_decodedata(int msglen,string cenc) {
_storetiming(); string serror; bytesreceived+=msglen; int cols=cr->read_int16(); array a=allocate(cols,!alltext&&Val.null); #ifdef PG_DEBUG msglen-=2+4*cols; #endif foreach(datarowtypes;int i;int typ) { int collen=cr->read_sint(4);
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:961:
} //! @returns //! One result row at a time. //! //! When using COPY FROM STDOUT, this method returns one row at a time //! as a single string containing the entire row. //! //! @seealso //! @[eof()], @[send_row()]
-
array(mixed) fetch_row() {
+
/*semi*/final
array(mixed) fetch_row() {
int|array datarow; if(arrayp(datarow=datarows->try_read())) return datarow; if(!eoffound) { if(!datarow && (PD("%O Block for datarow\n",_portalname), arrayp(datarow=datarows->read()))) return datarow; eoffound=1; datarows->write(1); // Signal EOF for other threads
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:985:
} //! @returns //! Multiple result rows at a time (at least one). //! //! When using COPY FROM STDOUT, this method returns one row at a time //! as a single string containing the entire row. //! //! @seealso //! @[eof()], @[fetch_row()]
-
array(array(mixed)) fetch_row_array() {
+
/*semi*/final
array(array(mixed)) fetch_row_array() {
if(eoffound) return 0; array(array|int) datarow=datarows->try_read_array(); if(!datarow) datarow=datarows->read_array(); if(arrayp(datarow[-1])) return datarow; trydelayederror(); eoffound=1; datarows->write(1); // Signal EOF for other threads
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1011:
//! array of strings to be processed by the COPY command; when sending //! the amount of data sent per call does not have to hit row or column //! boundaries. //! //! The COPY FROM STDIN sequence needs to be completed by either //! explicitly or implicitly destroying the result object, or by passing no //! argument to this method. //! //! @seealso //! @[fetch_row()], @[eof()]
-
void send_row(void|string|array(string) copydata) {
+
/*semi*/final
void send_row(void|string|array(string) copydata) {
trydelayederror(); if(copydata) { PD("CopyData\n"); c->start()->add_int8('d')->add_hstring(copydata,4,4)->sendcmd(SENDOUT); } else _releasesession(); } private void run_result_cb( function(sql_result, array(mixed), mixed ...:void) callback,
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1037:
eoffound=1; callout(callback, 0, this, 0, @args); } //! Sets up a callback for every row returned from the database. //! First argument passed is the resultobject itself, second argument //! is the result row (zero on EOF). //! //! @seealso //! @[fetch_row()]
-
void set_result_callback(
+
/*semi*/final
void set_result_callback(
function(sql_result, array(mixed), mixed ...:void) callback, mixed ... args) { if(callback) Thread.Thread(run_result_cb,callback,args); } private void run_result_array_cb( function(sql_result, array(array(mixed)), mixed ...:void) callback, array(mixed) args) { array(array|int) datarow;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1063:
callout(callback, 0, this, datarow=datarow[..<1], @args); callout(callback, 0, this, 0, @args); } //! Sets up a callback for sets of rows returned from the database. //! First argument passed is the resultobject itself, second argument //! is the array of result rows (zero on EOF). //! //! @seealso //! @[fetch_row()]
-
void set_result_array_callback(
+
/*semi*/final
void set_result_array_callback(
function(sql_result, array(array(mixed)), mixed ...:void) callback, mixed ... args) { if(callback) Thread.Thread(run_result_array_cb,callback,args); }
-
}
+
}
;