ODBC driver failure

ODBC driver failure

am 05.12.2005 16:16:46 von Ludek Finstrle

--lrZ03NoBR/3+SXJZ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello,

ODBC driver fail (raise exception) with these steps:
1) SQLPrepare (SELECT relname FROM pg_class WHERE relname != ?)
2) SQLExecute

I found the bug and fix it. Patch is attached.

Regards

Luf

--lrZ03NoBR/3+SXJZ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="psqlodbc-bindparam_count_error.diff"

diff -c psqlodbc.orig\convert.c psqlodbc\convert.c
*** psqlodbc.orig\convert.c Wed Nov 30 13:44:14 2005
--- psqlodbc\convert.c Mon Dec 05 17:17:11 2005
***************
*** 1860,1873 ****
}
if (marker_count > 0)
{
! CVT_APPEND_CHAR(qb, '(');
! for (i = 0; i < marker_count; i++)
{
! if (i > 0)
! CVT_APPEND_STR(qb, ", ");
! CVT_APPEND_STR(qb, pgtype_to_name(stmt, ipdopts->parameters[i].PGType));
}
- CVT_APPEND_CHAR(qb, ')');
}
CVT_APPEND_STR(qb, " as ");
for (qp->opos = 0; qp->opos < qp->stmt_len; qp->opos++)
--- 1860,1883 ----
}
if (marker_count > 0)
{
! if (ipdopts && (ipdopts->allocated == marker_count))
{
! CVT_APPEND_CHAR(qb, '(');
! for (i = 0; i < marker_count; i++)
! {
! if (i > 0)
! CVT_APPEND_STR(qb, ", ");
! CVT_APPEND_STR(qb, pgtype_to_name(stmt, ipdopts->parameters[i].PGType));
! }
! CVT_APPEND_CHAR(qb, ')');
! }
! else
! {
! SC_set_error(stmt, STMT_COUNT_FIELD_INCORRECT, "The # of binded parameters < the # of parameter markers");
! SC_set_sqlstate(stmt, "07002");
! QB_Destructor(qb);
! return SQL_ERROR;
}
}
CVT_APPEND_STR(qb, " as ");
for (qp->opos = 0; qp->opos < qp->stmt_len; qp->opos++)

--lrZ03NoBR/3+SXJZ
Content-Type: text/plain
Content-Disposition: inline
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

--lrZ03NoBR/3+SXJZ--

Re: ODBC driver failure

am 05.12.2005 17:45:27 von Dave Page

=20

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org=20
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Ludek Finstrle
> Sent: 05 December 2005 15:17
> To: pgsql-odbc@postgresql.org
> Subject: [ODBC] ODBC driver failure
>=20
> Hello,
>=20
> ODBC driver fail (raise exception) with these steps:
> 1) SQLPrepare (SELECT relname FROM pg_class WHERE relname !=3D ?)
> 2) SQLExecute
>=20
> I found the bug and fix it. Patch is attached.

Thanks Luf, patch applied.

BTW, did I understand from your earlier email that you are still looking
at the other server side prepare issue we've been discussing with
Rainer, or is the last patch good in your opinion?

Regards, Dave.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Re: ODBC driver failure

am 05.12.2005 18:00:40 von Ludek Finstrle

> BTW, did I understand from your earlier email that you are still looking
> at the other server side prepare issue we've been discussing with
> Rainer, or is the last patch good in your opinion?

I think psqlodbc-server_side_prepare.diff and
psqlodbc_server_side_prepare2.diff are good enough. But I'm waiting if
Rainer send steps which leads to bug.

BTW do you know why ExecDirect test open cursor? I'm talking about
SELECT statements. Cursor is opened in PGAPI_Execute so there can't
be called ExecDirect after Execute or ExecDirect. There is no limitation
for calling Execute, Prepare, Execute :-( Check in SQLDirect is done
by SC_opencheck:
if (res = SC_get_Curres(self), NULL != res)
{
if (res->backend_tuples)
{
SC_set_error(self, STMT_SEQUENCE_ERROR, "The cursor is open.");
SC_log_error(func, "", self);
return TRUE;
}
}
I have no idea why is it doing this way :-(

Luf

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Re: ODBC driver failure

am 05.12.2005 18:13:09 von Dave Page

=20

> -----Original Message-----
> From: Ludek Finstrle [mailto:luf@pzkagis.cz]=20
> Sent: 05 December 2005 17:01
> To: Dave Page
> Cc: pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] ODBC driver failure
>=20
> > BTW, did I understand from your earlier email that you are=20
> still looking
> > at the other server side prepare issue we've been discussing with
> > Rainer, or is the last patch good in your opinion?
>=20
> I think psqlodbc-server_side_prepare.diff and

Which ones that one? - I lost track :-(

> psqlodbc_server_side_prepare2.diff are good enough. But I'm waiting if
> Rainer send steps which leads to bug.

Got that one.

> BTW do you know why ExecDirect test open cursor? I'm talking about
> SELECT statements. Cursor is opened in PGAPI_Execute so there can't
> be called ExecDirect after Execute or ExecDirect. There is no=20
> limitation
> for calling Execute, Prepare, Execute :-( Check in SQLDirect is done
> by SC_opencheck:
> if (res =3D SC_get_Curres(self), NULL !=3D res)
> {
> if (res->backend_tuples)
> {
> SC_set_error(self, STMT_SEQUENCE_ERROR, "The=20
> cursor is open.");
> SC_log_error(func, "", self);
> return TRUE;
> }
> }
> I have no idea why is it doing this way :-(

No, nor do I offhand. I'm really busy at the moment though - do you have
time to investigate further please?

Thanks, Dave.

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Re: ODBC driver failure

am 05.12.2005 19:06:45 von Ludek Finstrle

> > I think psqlodbc-server_side_prepare.diff and
>
> Which ones that one? - I lost track :-(

This is included in psqlodbc-08.01.0102.

> > psqlodbc_server_side_prepare2.diff are good enough. But I'm waiting if
> > Rainer send steps which leads to bug.
>
> Got that one.

Do you mean diff or sequence of steps?

> time to investigate further please?

I have a lot of other work. Maybe later.
There is problem with bytea, Autocommit and Cancel, ColAttribure (maybe
this is problem of VB6 RowCount).
When there is no one report it. I didn't investigate it in near future.
And there is question of cleaning old unused code.

Luf

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: ODBC driver failure

am 05.12.2005 20:52:56 von Dave Page

On 5/12/05 6:06 pm, "Ludek Finstrle" wrote:

>>> I think psqlodbc-server_side_prepare.diff and
>>
>> Which ones that one? - I lost track :-(
>
> This is included in psqlodbc-08.01.0102.

Ah that one- thanks.

>>> psqlodbc_server_side_prepare2.diff are good enough. But I'm waiting if
>>> Rainer send steps which leads to bug.
>>
>> Got that one.
>
> Do you mean diff or sequence of steps?

Diff. I'll apply it tomorrow.

>> time to investigate further please?
>
> I have a lot of other work. Maybe later.
> There is problem with bytea, Autocommit and Cancel, ColAttribure (maybe
> this is problem of VB6 RowCount).
> When there is no one report it. I didn't investigate it in near future.
> And there is question of cleaning old unused code.

Yeah. We'll get there in the end!!!

Regards, Dave



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Re: ODBC driver failure

am 14.12.2005 15:11:15 von Ludek Finstrle

> > BTW do you know why ExecDirect test open cursor? I'm talking about
> > SELECT statements. Cursor is opened in PGAPI_Execute so there can't
> > be called ExecDirect after Execute or ExecDirect. There is no
> > limitation
> > for calling Execute, Prepare, Execute :-( Check in SQLDirect is done
> > by SC_opencheck:
> > if (res = SC_get_Curres(self), NULL != res)
> > {
> > if (res->backend_tuples)
> > {
> > SC_set_error(self, STMT_SEQUENCE_ERROR, "The
> > cursor is open.");
> > SC_log_error(func, "", self);
> > return TRUE;
> > }
> > }
> > I have no idea why is it doing this way :-(
>
> No, nor do I offhand. I'm really busy at the moment though - do you have
> time to investigate further please?

I'm studying ODBC specification and I find answer. psqlODBC behaviour is
right. The app have to close cursor prior to Execute new query.
So this is done ;-)

Luf

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Re: ODBC driver failure

am 14.12.2005 15:19:03 von Dave Page

=20

> -----Original Message-----
> From: Ludek Finstrle [mailto:luf@pzkagis.cz]=20
> Sent: 14 December 2005 14:11
> To: Dave Page
> Cc: pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] ODBC driver failure
>=20
> > > BTW do you know why ExecDirect test open cursor? I'm talking about
> > > SELECT statements. Cursor is opened in PGAPI_Execute so=20
> there can't
> > > be called ExecDirect after Execute or ExecDirect. There is no=20
> > > limitation
> > > for calling Execute, Prepare, Execute :-( Check in=20
> SQLDirect is done
> > > by SC_opencheck:
> > > if (res =3D SC_get_Curres(self), NULL !=3D res)
> > > {
> > > if (res->backend_tuples)
> > > {
> > > SC_set_error(self, STMT_SEQUENCE_ERROR, "The=20
> > > cursor is open.");
> > > SC_log_error(func, "", self);
> > > return TRUE;
> > > }
> > > }
> > > I have no idea why is it doing this way :-(
> >=20
> > No, nor do I offhand. I'm really busy at the moment though=20
> - do you have
> > time to investigate further please?
>=20
> I'm studying ODBC specification and I find answer. psqlODBC=20
> behaviour is
> right. The app have to close cursor prior to Execute new query.
> So this is done ;-)

:-)

/D

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend