pike.git/lib/modules/Sql.pmod/pgsql.pike:292:
//! Everything ok.
//! @value 1
//! The connection has reconnected automatically.
//! @value -1
//! The server has gone away, and the connection is dead.
//! @endint
//!
//! @seealso
//! @[is_open()]
int ping() {
- return is_open() && !catch(c->start()->sendcmd(flushsend))
+ return is_open() && !catch(c->start()->sendcmd(FLUSHSEND))
? !!reconnected : -1;
}
private .pgsql_util.conxion getsocket(void|int nossl) {
return .pgsql_util.conxion(this,qportals,(int)nossl);
}
//! 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.
void cancelquery() {
PD("CancelRequest\n");
.pgsql_util.conxion lcon=getsocket(1);
lcon->add_int32(16)->add_int32(PG_PROTOCOL(1234,5678))
- ->add_int32(backendpid)->add(cancelsecret)->sendcmd(flushsend);
+ ->add_int32(backendpid)->add(cancelsecret)->sendcmd(FLUSHSEND);
lcon->close();
#ifdef PG_DEBUGMORE
PD("Closetrace %O\n",backtrace());
#endif
if(c) {
.pgsql_util.conxion plugbuffer=c->start(1);
foreach(qportals->peek_array();;int|.pgsql_util.sql_result portal)
if(objectp(portal))
portal->_closeportal(plugbuffer);
- plugbuffer->sendcmd(sendout);
+ plugbuffer->sendcmd(SENDOUT);
}
}
//! Changes the connection charset. When set to @expr{"UTF8"@}, the query,
//! parameters and results can be Pike-native wide strings.
//!
//! @param charset
//! A PostgreSQL charset name.
//!
//! @seealso
pike.git/lib/modules/Sql.pmod/pgsql.pike:614:
plugbuffer->add("database\0")->add(database)->add_int8(0);
_options.reconnect=undefinedp(_options.reconnect) || _options.reconnect;
foreach(_options
-(<"use_ssl","force_ssl","cache_autoprepared_statements","reconnect",
"text_query","is_superuser","server_encoding","server_version",
"integer_datetimes","session_authorization">);
string name;mixed value)
plugbuffer->add(name)->add_int8(0)->add((string)value)->add_int8(0);
plugbuffer->add_int8(0);
PD("%O\n",(string)plugbuffer);
- ci->start()->add_hstring(plugbuffer,4,4)->sendcmd(sendout);
+ ci->start()->add_hstring(plugbuffer,4,4)->sendcmd(SENDOUT);
} // Do not flush at this point, PostgreSQL 9.4 disapproves
cancelsecret=0;
#ifdef PG_DEBUG
PD("Processloop\n");
string datarowdebug;
int datarowdebugcount;
void showportal(int msgtype) {
if(objectp(portal))
PD("%d<%O %d %c switch portal\n",
pike.git/lib/modules/Sql.pmod/pgsql.pike:761:
break;
default:
PD("Unknown Authentication Method %c\n",authtype);
errtype=protocolunsupported;
break;
}
switch(errtype) {
case noerror:
if(cancelsecret!="")
ci->start()->add_int8('p')->add_hstring(sendpass,4,5)
- ->add_int8(0)->sendcmd(sendout);
+ ->add_int8(0)->sendcmd(SENDOUT);
break; // No flushing here, PostgreSQL 9.4 disapproves
default:
case protocolunsupported:
ERROR("Unsupported authenticationmethod %c\n",authtype);
break;
}
break;
}
case 'K':
msglen-=4+4;backendpid=ci->read_int32();
pike.git/lib/modules/Sql.pmod/pgsql.pike:1084: Inside #if defined(PG_DEBUG)
portal._datarows->write(({ci->read(msglen)}));
#ifdef PG_DEBUG
msglen=0;
#endif
portal->_processdataready();
break;
case 'G':
portal->_setrowdesc(getcols());
PD("<%O CopyInResponse %d columns\n",
portal._portalname,sizeof(portal._datarowdesc));
- portal._state=copyinprogress;
+ portal._state=COPYINPROGRESS;
{
Thread.MutexKey resultlock=portal._resultmux->lock();
portal._newresult.signal();
resultlock=0;
}
break;
case 'c':
#ifdef PG_DEBUG
PD("<%O CopyDone\n",portal._portalname);
msglen-=4;
pike.git/lib/modules/Sql.pmod/pgsql.pike:1222:
case protocolerror:
msg=sprintf("Protocol error with database %s",host_info());
break;
case noerror:
continue; // Normal production loop
}
ERROR(a2nls(lastmessage+=({msg})));
}
}; // We only get here if there is an error
if(err==MAGICTERMINATE) { // Announce connection termination to server
- ci->start()->add("X\0\0\0\4")->sendcmd(sendout);
+ ci->start()->add("X\0\0\0\4")->sendcmd(SENDOUT);
terminating=1;
if(!sizeof(ci))
break;
}
if(stringp(err)) {
.pgsql_util.sql_result or;
if(!objectp(or=portal))
or=this;
if(!or._delayederror)
or._delayederror=err;
pike.git/lib/modules/Sql.pmod/pgsql.pike:1390:
foreach(_prepareds;;mapping tp) {
m_delete(tp,"datatypeoid");
m_delete(tp,"datarowdesc");
}
Thread.Thread(reset_dbsession); // Urgently and deadlockfree
}
}
private void sendsync() {
_readyforquerycount++;
- c->start()->sendcmd(syncsend);
+ c->start()->sendcmd(SYNCSEND);
}
//! @decl void resync()
//!
//! Resyncs the database session; typically used to make sure the session is
//! not still in a dangling transaction.
//!
//! If called while the connection is in idle state, the function is
//! lightweight and briefly touches base with the database server to
//! make sure client and server are in sync.
pike.git/lib/modules/Sql.pmod/pgsql.pike:1956:
}
if(invalidatecache) {
invalidatecache=0;
foreach(_prepareds;;mapping np) {
closestatement(plugbuffer,np.preparedname);
m_delete(np,"preparedname");
}
}
if(sizeof(plugbuffer)) {
PD("%O\n",(string)plugbuffer);
- plugbuffer->sendcmd(flushsend); // close expireds
+ plugbuffer->sendcmd(FLUSHSEND); // close expireds
} else
- plugbuffer->sendcmd(); // close start()
+ plugbuffer->sendcmd(KEEP); // close start()
tstart=gethrtime();
} else // sql_result autoassigns to portal
tp=UNDEFINED;
.pgsql_util.sql_result portal;
portal=.pgsql_util.sql_result(this,c,q,
portalbuffersize,_alltyped,from,forcetext);
portal._tprepared=tp;
#ifdef PG_STATS
portalsopened++;
#endif
clearmessage=1;
if(forcetext) { // FIXME What happens if portals are still open?
portal._unnamedportalkey=_unnamedportalmux->lock(1);
portal._portalname="";
portal->_openportal();
_readyforquerycount++;
Thread.MutexKey lock=unnamedstatement->lock(1);
c->start(1)->add_int8('Q')->add_hstring(q,4,4+1)->add_int8(0)
- ->sendcmd(flushlogsend,portal);
+ ->sendcmd(FLUSHLOGSEND,portal);
lock=0;
PD("Simple query: %O\n",q);
} else {
object plugbuffer;
if(!sizeof(preparedname) || !tp || !tp.preparedname) {
if(!sizeof(preparedname))
preparedname=
(portal._unnamedstatementkey=
(syncparse?unnamedstatement->lock:unnamedstatement->trylock)(1))
? "" : PTSTMTPREFIX+int2hex(ptstmtcount++);
pike.git/lib/modules/Sql.pmod/pgsql.pike:2001:
// followed by a flush, it makes a VERY noticeable difference in
// performance if it is omitted; seems like a flaw in the PostgreSQL
// server v8.3.3
PD("Parse statement %O=%O\n",preparedname,q);
plugbuffer=c->start()->add_int8('P')
->add_hstring(({preparedname,0,q,"\0\0\0"}),4,4)->add(PGFLUSH);
}
if(!tp || !tp.datatypeoid) {
PD("Describe statement %O\n",preparedname);
(plugbuffer||c->start())->add_int8('D')
- ->add_hstring(({'S',preparedname,0}),4,4)->sendcmd(flushsend,portal);
+ ->add_hstring(({'S',preparedname,0}),4,4)->sendcmd(FLUSHSEND,portal);
} else {
if(plugbuffer)
- plugbuffer->sendcmd();
+ plugbuffer->sendcmd(KEEP);
#ifdef PG_STATS
skippeddescribe++;
#endif
portal->_setrowdesc(tp.datarowdesc);
}
portal._preparedname=preparedname;
if((portal._tprepared=tp) && tp.datatypeoid) {
mixed e=catch(portal->_preparebind(tp.datatypeoid));
if(e && !portal._delayederror)
throw(e);