Re: C++ client libs

From: Adam Haberlach <adam(at)newsnipple(dot)com>
To: Randy Jonasz <rjonasz(at)click2net(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: C++ client libs
Date: 2000-10-03 21:43:13
Message-ID: 20001003144312.A3547@ricochet.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 03, 2000 at 02:47:45PM -0400, Randy Jonasz wrote:

> I was wondering if anyone could offer me some pointers in extending the
> C++ classes used for client applications? I'm interested in developing a
> set of C++ classes which will interact directly with the postgres back-end
> with the following enhancements to the current implementation:
>
> These are preliminary musings and definitely open to change.
>
> 1) Implement connections as a stream object. e.g.
> db = new pg_database(char * connection_params);
> db << sql_string;

I don't really like heavy overloading of stream-type things.
In this case I think it may make sense, but I prefer
the db.Exec(sql_string) system for clarity...

> 2) Implement results as a returned object from pg_database
> result = db.exec();
> result >> field1 >> field2 >> field3;
> and
> field = result["field"];
> field = result[fieldnum];

The above system puts some state into the result object. Overloading
array operators can be sketchy, too.

The current system definitely needs to decouple the result from the
connection. I find that the current API causes most implementations
to create a lot of independent connections to the backend.

> 3) Implement asynchronous calls to the back-end permitting multiple
> queries to be executed concurrently

Yes. I was going to do this in order to make use of the NOTIFY/LISTEN
functionality as well.

> 4) Implement a standard set of exceptions which can be thrown
> ex. if connection to back-end is interrupted or cannot be established
> within 30 seconds of the first attempt, throw.

If you really want exceptions, sure. I don't like 'em myself, but I
can understand their advantages.

> 5) I'm looking at making the libraries portable between FreeBSD, Solaris
> Linux and Win32.

Please add BeOS that that list--I'll help keep it in line.

> If anyone has suggestions/additions to this list it would be greatly
> appreciated!

I'm very interested in helping with this (it is on my list of projects
and I've managed to stop adding new ones to the list for now). Should
we take this off-list, or keep it here?

In either case, I'll spend some time formally thinking about my
perfect API and we can get together and compare notes...

--
Adam Haberlach | A billion hours ago, human life appeared on
adam(at)newsnipple(dot)com | earth. A billion minutes ago, Christianity
http://www.newsnipple.com | emerged. A billion Coca-Colas ago was
'88 EX500 | yesterday morning. -1996 Coca-Cola Ann. Rpt.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-10-03 23:34:53 Re: AIX compile ?? libcrypt HELP !!
Previous Message Clark, Joel 2000-10-03 21:15:29 RE: C++ client libs