Skip to content

Commit b0e5c91

Browse files
author
clach04
committed
IngresDBI Trac ticket #502 select on LONG NVARCHAR (aka NCLOB) return empty strings
LONG NVARCHAR length indicator orInd was not being set resulting in empty strings being returned. Noticed same inconsistency with other LONG types (LONG BYTE and LONG VARCHAR), lack of correct orInd was not returning incorrect results for these types but is inconsistent hence the change. Whilst delving into this code added needed debug statement so that unsupported types are seen in trace logs. git-svn-id: http://code.ingres.com/ingres/drivers/python/main@2286 45b5d43f-8932-4c86-835a-3654e5842839
1 parent 24dd332 commit b0e5c91

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

dbi/iidbicurs.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@
152152
** Crash was caused by access to uninitialized pointer.
153153
** Bindparam code for NULL/None removed, now uses generic bind code
154154
** as used for strings and decimal.
155+
** 24-Nov-2009 (clach04)
156+
** Trac ticket 502 empty string returned for LONG NVARCHAR/NCLOB columns
157+
** LONG NVARCHAR length indicator orInd was not being set
158+
** resulting in empty strings being returned. Noticed same
159+
** issue with other LONG types (LONG BYTE and LONG VARCHAR),
160+
** lack of correct orInd was not an issue for these types
161+
** but is inconsistent hence the change.
155162
**/
156163

157164
/*
@@ -662,7 +669,7 @@ dbi_cursorFetchone( IIDBI_STMT *pstmt )
662669
RETCODE rc, return_code;
663670
HSTMT hstmt = pstmt->hdr.handle;
664671
int i, nType;
665-
SQLINTEGER orind;
672+
SQLINTEGER orind=0;
666673
#define SEGMENT_SIZE 1000000
667674
char *segment = NULL;
668675
int count;
@@ -699,6 +706,7 @@ dbi_cursorFetchone( IIDBI_STMT *pstmt )
699706
pstmt->descriptor[i]->data = NULL;
700707
pstmt->descriptor[i]->isNull = 0;
701708
pstmt->descriptor[i]->precision = 0;
709+
pstmt->descriptor[i]->orInd = 0;
702710
if (pstmt->outputColumnIndex && (i+1) ==
703711
pstmt->outputColumnIndex)
704712
segment_size = pstmt->outputSegmentSize;
@@ -757,6 +765,7 @@ dbi_cursorFetchone( IIDBI_STMT *pstmt )
757765
{
758766
pstmt->descriptor[i]->data = segment;
759767
pstmt->descriptor[i]->precision = count;
768+
pstmt->descriptor[i]->orInd = count;
760769
}
761770
}
762771
if (!SQL_SUCCEEDED(rc))
@@ -779,6 +788,7 @@ dbi_cursorFetchone( IIDBI_STMT *pstmt )
779788
pstmt->descriptor[i]->data = NULL;
780789
pstmt->descriptor[i]->isNull = 0;
781790
pstmt->descriptor[i]->precision = 0;
791+
pstmt->descriptor[i]->orInd = 0;
782792
if (pstmt->outputColumnIndex && (i+1) ==
783793
pstmt->outputColumnIndex)
784794
segment_size = pstmt->outputSegmentSize;
@@ -806,6 +816,7 @@ dbi_cursorFetchone( IIDBI_STMT *pstmt )
806816
{
807817
pstmt->descriptor[i]->data = segment;
808818
pstmt->descriptor[i]->precision = orind;
819+
pstmt->descriptor[i]->orInd = orind;
809820
}
810821
else
811822
{
@@ -841,6 +852,7 @@ dbi_cursorFetchone( IIDBI_STMT *pstmt )
841852
{
842853
pstmt->descriptor[i]->data = segment;
843854
pstmt->descriptor[i]->precision = count;
855+
pstmt->descriptor[i]->orInd = count;
844856
}
845857
}
846858
if (!SQL_SUCCEEDED(rc))
@@ -862,6 +874,7 @@ dbi_cursorFetchone( IIDBI_STMT *pstmt )
862874
pstmt->descriptor[i]->data = NULL;
863875
pstmt->descriptor[i]->isNull = 0;
864876
pstmt->descriptor[i]->precision = 0;
877+
pstmt->descriptor[i]->orInd = 0;
865878
if (pstmt->outputColumnIndex && (i+1) ==
866879
pstmt->outputColumnIndex)
867880
segment_size = pstmt->outputSegmentSize;
@@ -920,6 +933,7 @@ dbi_cursorFetchone( IIDBI_STMT *pstmt )
920933
{
921934
pstmt->descriptor[i]->data = segment;
922935
pstmt->descriptor[i]->precision = count;
936+
pstmt->descriptor[i]->orInd = count;
923937
}
924938
}
925939
if (!SQL_SUCCEEDED(rc))

dbi/ingresdbi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@
255255
** calls to (for instance) fetch on a closed session will be using
256256
** invalid pointers as the driver is responsible for free'ing each
257257
** connection/cursror resource. Other Windows ODBC drivers also crash.
258+
** 24-Nov-2009 (clach04)
259+
** Added debug trace for unknown types on select/fetch.
258260
**/
259261

260262
static PyObject *IIDBI_Warning;
@@ -4517,6 +4519,7 @@ static PyObject *IIDBI_cursorFetch(IIDBI_CURSOR *self)
45174519
break;
45184520

45194521
default:
4522+
DBPRINTF(DBI_TRC_STAT)("IIDBI_cursorFetch defaulting col %d type descriptor[i]->type %d\n", i, descriptor[i]->type);
45204523
PyTuple_SetItem(row, i,
45214524
PyString_FromStringAndSize(descriptor[i]->data,
45224525
(Py_ssize_t) descriptor[i]->orInd)

0 commit comments

Comments
 (0)