|
|
sybperl-l Archive
Up Prev Next
From: Gisle Aas <aas at bergen dot sn dot no>
Subject: Re: Multiple CTlib CS_COMMAND structures
Date: Jan 15 1996 4:05PM
Michael Peppler wrote:
> > The allocation of a CS_CONNECTION and a CS_COMMAND are bundled
> > together inside the perl ct_connect routine. This means that it is not
> > possible to have several CS_COMMAND structures share the same
> > CS_CONNECTION.
> >
> > We would like to be able have different perl connection objects
> > (Sybase::CTlib objects) that have different CS_COMMAND but share the
> > same CS_CONNECTION. Do you have any plans to include support for this?
>
> I had coded this in my first version, but I took it out again because I
> didn't see the use. Now I do see the use :-)
>
> Maybe I'll add it again... let me rummage through the old code to see
> if this is an easy addition...
We would be very grateful if you were able to fix this soon.... Please!!
We need this feature badly, so we will probably make some kind patch
if you don't have the time to do something about it now.
My plan would be to do code it something like this:
struct mycon {
CS_CONNECTION *connection;
int refcount; /* how many conInfo reference this */
}
struct conInfo {
ConType type;
int numCols;
ColData *coldata;
CS_DATAFMT *datafmt;
struct mycon *connection;
CS_COMMAND *cmd;
CS_INT lastResult;
}
static CS_CONNECTION
*get_con(dbp)
SV *dbp;
{
ConInfo *info = get_ConInfo(dbp);
return info->connection->connection;
}
The refcount will be initialized to 1 in ct_connect() and we would add
1 to it each time it is shared (ct_cmd_alloc()). The ref count will be
decremented in DESTROY and the connection will be closed when refcount
reach zero.
This approach does not seem to be too much work. Have I overlooked
something?
--Gisle
|