[Sqlrelay-discussion] oddity with cursors in sqlrelay-0.39
Brought to you by:
mused
|
From: Guillaume G. <sql...@bl...> - 2009-02-03 18:02:01
|
Hi folks,
I'm working on a project that puts an abstraction layer around sqlrelay.
And I found something like an inconsistency in the manner the cursors
are constructed and destructed. All cursors are consumed with the error
message
"No server-side cursors were available to process the query."
I'm using sqlrelay-0.39 provided by debian
the interesting part of /etc/sqlrelay/sqlrelay.conf
<instance id="cpta" port="9000" socket="/tmp/.sqlrelay.cpta"
dbase="postgresql" connections="5" maxconnections="5" maxqueuelength="0"
growby="1" ttl="60" endofsession="rollback" sessiontimeout="600"
runasuser="sqlrelay" runasgroup="sqlrelay" cursors="40"
authtier="listener" handoff="pass">
the snippet of code that exhausts cursors
----------8<--------------------8<--------------------8<----------
#include <iostream>
#include <sqlrelay/sqlrclient.h>
using namespace std;
int main(int argc, char **argv) {
sqlrconnection *con=new
sqlrconnection("localhost",9000,"/tmp/.sqlrelay.cpta","zorro","11digitsprimenumber",1,1);
for ( int i=0 ; i<100 ; ++i ) {
sqlrcursor *cursor1=new sqlrcursor(con);
sqlrcursor *cursor2=new sqlrcursor(con);
if ( cursor1->sendQuery("SELECT 1 AS r1") == 0 ) {
cout << cursor1->errorMessage() << endl;
return 1;
}
if ( cursor2->sendQuery("SELECT 2 AS r2") == 0 ) {
cout << cursor2->errorMessage() << endl;
return 1;
}
delete cursor2;
delete cursor1;
}
return 0;
}
----------8<--------------------8<--------------------8<----------
I know that in this example sqlrcursor's pointers should be declared and
initialized outer the for loop. but it is approximatively what the
abstraction layer does with the following code :
Connection
conn("sqlrelay://zoro:11digitsprimenumber@localhost:9000/tmp/.sqlrelay.cpta");
for (...) {
Begin transaction(conn);
conn.query(...);
}
Could you tell me if I'm wrong ?
And if I'm wrong, why this strange issue occurs ?
Thanks in advance
Best regards - Guillaume Gimenez
PS: For information this pseudo code
class Begin {
Connection& conn;
public:
Begin(Connection& conn) {
conn.setAutoCommitOff();
}
~Begin() {
conn.rollback();
conn.setAutoCommitOn();
}
commit();
rollback();
...
};
class Connection {
sqlrconnection *sqlrconn;
public:
...
ResultSet query(const std::string& str);
...
}
class ResultSet {
sqlrcursor *sqlrcur;
public:
...
next();
std::string operator[](const std::string& str);
...
}
|