From: | Aidan Mountford <Aidan(at)oz(dot)to> |
---|---|
To: | "'pgsql-patches(at)postgresql(dot)org'" <pgsql-patches(at)postgresql(dot)org> |
Subject: | ODBC Boolean handling |
Date: | 2001-08-01 13:59:51 |
Message-ID: | B08465D85C11D41199720040053101D50F3E8B@DEVELOPMENT1 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
I had a few issues with boolean handling in ODBC driver.
1) When a row is retrieved, and then a SQL_FETCH_FIRST is issued, the check
in convert.c
does not consider the fact that the value in the field has been altered to
be a '1' if the
backend handed it a 't'. The net result being that the first row on any
subsequent queries
has all it's boolean set to 0.
2) I had issues with some utilities that, when casting from string to
boolean, and having
the global 'bools as char' set, require that -1 = True, and 0 = false.
The following patch fixes both of these issues..
Cheers for building a fantastic product
Aidan
cvs diff convert.c (in directory C:\CVS-POSTGRES\pgsql\src\interfaces\odbc\)
Index: convert.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/odbc/convert.c,v
retrieving revision 1.44
diff -r1.44 convert.c
295c295,307
< if (s[0] == 'T' || s[0] == 't')
---
> /* Aidan Mountford (aidan(at)oz(dot)to) 1/08/2001:
>
> >> if (s[0] == 'T' || s[0] == 't')
<<< This wont work...
>
> When MoveFirst is called twice on
one set of tuples,
> this will have the effect of setting
s[0] to 1 on the
> first pass, and s[0] on the second.
>
> This is bad ;)
>
> */
>
> if (s[0] == 'T' || s[0] == 't' || s[0] ==
'1')
415c428
< len = 1;
---
>
418c431,449
< strcpy(rgbValueBindRow, value);
---
> /* Aidan Mountford (aidan(at)oz(dot)to)
1/08/2001:
>
> When returning a CHAR
datatype, return -1
> instead of +1.
>
> That way if someone casts it
back to a boolean
> again - it will work.
> */
> if ( *(char *) value = '1')
> {
> strcpy(rgbValueBindRow, "-1");
> len = 2;
> }
> else
> {
> strcpy(rgbValueBindRow, "0");
> len = 1;
> }
>
1160a1192,1193
>
>
1161a1195
>
.....................................................
. Cisco Certified Network Associate
. Microsoft Certified Professional
. 3Com 3Wizard
.
. Technical Director
. MindVision Interactive Pty. Ltd.
. http://www.mindvision.com.au
. PH: +61-8-8212-9544
. FAX: +61-8-8212-9644
. 48 Light Square
. Adelaide SA
. AUSTRALIA 5000
.....................................................
"Remember, There is always scope for things to be worse"
From | Date | Subject | |
---|---|---|---|
Next Message | Liam Stewart | 2001-08-01 17:17:00 | Re: Patch to add insert of multiple tuples per INSERT statement |
Previous Message | Aidan Mountford | 2001-08-01 06:58:30 | ODBC Patch to deal with poor boolean handling. |