Thread: libpqxx testers needed!

libpqxx testers needed!

From
"Jeroen T. Vermeulen"
Date:
The latest version of libpqxx, 1.2.2, introduces a new class
"CachedResult" that makes large result sets easier to handle by fetching
rows on-demand and caching them internally.  I've added some tests for
this new feature, but the code is fairly complex and I'm sure it can be
broken in ways I haven't thought of.

Is anyone out there willing to give it a whirl?  It's far from finished
now (it doesn't evict blocks yet if the cache gets too large, and there
are going to be some internal changes before I can implement iterators)
but I suspect this class may be fairly useful already.

Download it at
 ftp://gborg.postgresql.org/pub/libpqxx/stable/libpqxx-1.2.2.tar.gz


Jeroen



Re: libpqxx testers needed!

From
"Llew Sion Goodstadt"
Date:
One thing I am curious about is why strings are passed by value instead
of by constant reference.
Even granted that many standard library vendors *in the past* used
COW reference counting implementations of std::string to minimize the
cost of copying, this surely is still an unwarranted additional cost.


E.g. libpqxx-1.2.2\src\connection.cxx:427

Instead of:
void pqxx::Connection::BeginCopyRead(string Table)

Should be:
void pqxx::Connection::BeginCopyRead(const string& Table)
{ Result R( Exec(("COPY " + Table + " TO STDOUT").c_str()) ); R.CheckStatus();
}


Of course if you are going to change the string anyway inside the body
of the function, pass by const
reference is misleading for both the compiler and the user, so pass
by value would be justified. E.g. if the above example had been 
something like

void pqxx::Connection::BeginCopyRead(string Table)
{ Table = "COPY " + Table + " TO STDOUT"; Result R( Exec(Table.c_str()) ); R.CheckStatus();
}

I have found few of these cases in libpqxx.



Leo Goodstadt
MRC Functional Genetics Unit
OXFORD
OX1 3QX



Re: libpqxx testers needed!

From
"Llew Sion Goodstadt"
Date:
One thing I am curious about is why strings are passed by value instead
of by constant reference.
Even granted that many standard library vendors *in the past* used
COW reference counting implementations of std::string to minimize the
cost of copying, this surely is still an unwarranted additional cost.


E.g. libpqxx-1.2.2\src\connection.cxx:427

Instead of:
void pqxx::Connection::BeginCopyRead(string Table)

Should be:
void pqxx::Connection::BeginCopyRead(const string& Table)
{ Result R( Exec(("COPY " + Table + " TO STDOUT").c_str()) ); R.CheckStatus();
}


Of course if you are going to change the string anyway inside the body
of the function, pass by const
reference is misleading for both the compiler and the user, so pass
by value would be justified. E.g. if the above example had been 
something like

void pqxx::Connection::BeginCopyRead(string Table)
{ Table = "COPY " + Table + " TO STDOUT"; Result R( Exec(Table.c_str()) ); R.CheckStatus();
}

I have found few of these cases in libpqxx.



Leo Goodstadt
MRC Functional Genetics Unit
OXFORD
OX1 3QX



Re: libpqxx testers needed!

From
"Jeroen T. Vermeulen"
Date:
On Tue, Dec 03, 2002 at 06:25:57PM -0000, Llew Sion Goodstadt wrote:
> One thing I am curious about is why strings are passed by value instead
> of by constant reference.
Mostly because I didn't want any clutter in the early stages.  I think
of this as an optimization issue.  IIRC I've changed some of these 
instances to const std::string &, but not all of them yet.  I'll get 
back to this particular job when I have time.

Jeroen