[Oledb-dev] fix/hack for bug [#1000379] Bad bool values

Victor Snezhko snezhko at indorsoft.ru
Fri Apr 14 12:34:13 UTC 2006


Hmm... the text of my message is not shown by the mailman,
reposting it:

Hello!

Until now PgOLEDB have returned incorrect boolean values - true
instead of false. I have found a cause for this
behaviour. Implementation of the DataConvert method seems to be buggy
somewhere deep inside VC6 provider templates. IRowsetImpl::GetData
contains the following code:

if (pBindCur->dwPart & DBPART_VALUE)
{
  hr = spConvert->DataConvert(pColCur->wType, pBindCur->wType,
                              cbCol, &cbDst, (BYTE*)(pSrcData) + pColCur->cbOffset,
                              pDstTemp, pBindCur->cbMaxLen, dbStat, &dbStat,
                              pBindCur->bPrecision, pBindCur->bScale,0);
}

For DBTYPE_BOOL type, false value, not the byte at pDstTemp is
written, but the least but one significant bit of the following byte
is cleared (pDstTemp: 00 FF -> 00 FD)!

A simple workaround is to apply this patch which makes pgoledb return
2-byte booleans: 

Index: PgSess.cpp
===================================================================
RCS file: /cvsroot/oledb/oledb/PgSess.cpp,v
retrieving revision 1.37
diff -u -r1.37 PgSess.cpp
--- PgSess.cpp	25 Apr 2005 21:12:27 -0000	1.37
+++ PgSess.cpp	14 Apr 2006 12:02:01 -0000
@@ -55,7 +55,7 @@
 };
 const typeinfo CPgSession::s_types_type[]={
     /* 17 */ typeinfo( DBTYPE_BYTES|DBTYPE_BYREF, ~0, COPY_binray, typeinfo::StdGWwidth, typeinfo::StdPGC_memcpy, typeinfo::StdPGWidth, 1 ), // 17 - bytea
-    /* 16 */ typeinfo( DBTYPE_BOOL, 1, typeinfo::StdC_memcpy, typeinfo::StdGW_1, typeinfo::StdPGC_memcpy, typeinfo::StdPGWidth1, 1 ), // 16 - bool
+    /* 16 */ typeinfo( DBTYPE_BOOL, 1, typeinfo::StdC_memcpy, typeinfo::StdGW_2, typeinfo::StdPGC_memcpy, typeinfo::StdPGWidth1, 1 ), // 16 - bool
     /* 19 */ typeinfo( DBTYPE_WSTR, ~0, COPY_string, GetWidth_string, PGC_string, PGWidthString, 2 ), // 19 - name - 63-char type for storing system identifiers
     /* 20 */ typeinfo( DBTYPE_I8, 20, typeinfo::StdC_ntoh_8, typeinfo::StdGW_8, typeinfo::StdPGC_h2n_8, typeinfo::StdPGWidth8, 8 ), // 20 - int8
     /* 21 */ typeinfo( DBTYPE_I2, 5, typeinfo::StdC_ntoh_2, typeinfo::StdGW_2, typeinfo::StdPGC_h2n_2, typeinfo::StdPGWidth2, 2 ), // 21 - int2

It works for me, but testing/suggestions are welcome.

P.S.: for some strange reason the state of the bug is "Deleted", but
no workaround have been recorded in the database...

-- 
WBR, Victor V. Snezhko
E-mail: snezhko at indorsoft.ru




More information about the Oledb-devel mailing list