Skip to content

Commit b543850

Browse files
The method cursor.setoutputsize() no longer needs to do anything (since ODPI-C
automatically manages buffer sizes of LONG and LONG RAW columns).
1 parent fa4faa2 commit b543850

File tree

4 files changed

+8
-60
lines changed

4 files changed

+8
-60
lines changed

doc/src/cursor.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,9 @@ Cursor Object
456456

457457
.. method:: Cursor.setoutputsize(size, [column])
458458

459-
This can be used before a call to :meth:`~Cursor.execute()` to predefine
460-
memory areas for the long columns that will be fetched. The column is
461-
specified as an index into the result sequence. Not specifying the column
462-
will set the default size for all large columns in the cursor.
459+
This method does nothing and is retained solely for compatibility with the
460+
DB API. The module automatically allocates as much space as needed to fetch
461+
LONG and LONG RAW columns (or CLOB as string and BLOB as bytes).
463462

464463

465464
.. attribute:: Cursor.statement

src/Cursor.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ typedef struct {
3131
uint32_t bindArraySize;
3232
uint32_t fetchArraySize;
3333
int setInputSizes;
34-
int outputSize;
35-
int outputSizeColumn;
3634
uint64_t rowCount;
3735
uint32_t fetchBufferRowIndex;
3836
uint32_t numRowsInFetchBuffer;
@@ -238,8 +236,6 @@ static int Cursor_Init(udt_Cursor *self, PyObject *args, PyObject *keywordArgs)
238236
self->arraySize = 100;
239237
self->fetchArraySize = 100;
240238
self->bindArraySize = 1;
241-
self->outputSize = -1;
242-
self->outputSizeColumn = -1;
243239
self->isOpen = 1;
244240

245241
return 0;
@@ -436,13 +432,6 @@ static int Cursor_PerformDefine(udt_Cursor *self, uint32_t numQueryColumns)
436432
return -1;
437433
}
438434

439-
// if setoutputsize() called, use its value instead
440-
if (self->outputSize >= 0) {
441-
if (self->outputSizeColumn < 0 ||
442-
(int) pos == self->outputSizeColumn)
443-
size = self->outputSize;
444-
}
445-
446435
// determine the default type
447436
varType = VarType_FromQueryInfo(&queryInfo);
448437
if (!varType)
@@ -1447,10 +1436,6 @@ static PyObject *Cursor_Execute(udt_Cursor *self, PyObject *args,
14471436
}
14481437
}
14491438

1450-
// reset the values of setoutputsize()
1451-
self->outputSize = -1;
1452-
self->outputSizeColumn = -1;
1453-
14541439
// for queries, return the cursor for convenience
14551440
if (numQueryColumns > 0) {
14561441
Py_INCREF(self);
@@ -1827,15 +1812,15 @@ static PyObject *Cursor_SetInputSizes(udt_Cursor *self, PyObject *args,
18271812

18281813
//-----------------------------------------------------------------------------
18291814
// Cursor_SetOutputSize()
1830-
// Set the size of all of the long columns or just one of them.
1815+
// Does nothing as ODPI-C handles long columns dynamically without the need
1816+
// to specify a maximum length.
18311817
//-----------------------------------------------------------------------------
18321818
static PyObject *Cursor_SetOutputSize(udt_Cursor *self, PyObject *args)
18331819
{
1834-
self->outputSizeColumn = -1;
1835-
if (!PyArg_ParseTuple(args, "i|i", &self->outputSize,
1836-
&self->outputSizeColumn))
1837-
return NULL;
1820+
int outputSize, outputSizeColumn;
18381821

1822+
if (!PyArg_ParseTuple(args, "i|i", &outputSize, &outputSizeColumn))
1823+
return NULL;
18391824
Py_RETURN_NONE;
18401825
}
18411826

test/LongVar.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,6 @@ def testLongRawCursorDescription(self):
7878
('LONGRAWCOL', cx_Oracle.LONG_BINARY, None, None, None, None,
7979
0) ])
8080

81-
def testSetOutputSizesAll(self):
82-
"test setoutputsizes is valid (all)"
83-
self.cursor.setoutputsize(25000)
84-
self.cursor.execute("select * from TestLongRaws")
85-
longVar = self.cursor.fetchvars[1]
86-
self.assertEqual(longVar.size, 25000)
87-
88-
def testSetOutputSizesWrongColumn(self):
89-
"test setoutputsizes is valid (wrong column)"
90-
self.cursor.setoutputsize(25000, 1)
91-
self.cursor.execute("select * from TestLongs")
92-
longVar = self.cursor.fetchvars[1]
93-
self.assertEqual(longVar.size, 131072)
94-
95-
def testSetOutputSizesRightColumn(self):
96-
"test setoutputsizes is valid (right column)"
97-
self.cursor.setoutputsize(35000, 2)
98-
self.cursor.execute("select * from TestLongRaws")
99-
longVar = self.cursor.fetchvars[1]
100-
self.assertEqual(longVar.size, 35000)
101-
10281
def testArraySizeTooLarge(self):
10382
"test array size too large generates an exception"
10483
self.cursor.arraysize = 268435456

test/uLongVar.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def __PerformTest(self, a_Type, a_InputType):
3535
integerValue = i,
3636
longString = longString)
3737
self.connection.commit()
38-
self.cursor.setoutputsize(250000, 2)
3938
self.cursor.execute(u"""
4039
select *
4140
from Test%ss
@@ -75,20 +74,6 @@ def testLongRawCursorDescription(self):
7574
(u'LONGRAWCOL', cx_Oracle.LONG_BINARY, None, None, None,
7675
None, 0) ])
7776

78-
def testSetOutputSizesAll(self):
79-
"test setoutputsizes is valid (all)"
80-
self.cursor.setoutputsize(25000)
81-
self.cursor.execute(u"select * from TestLongRaws")
82-
longVar = self.cursor.fetchvars[1]
83-
self.assertEqual(longVar.size, 25000)
84-
85-
def testSetOutputSizesWrongColumn(self):
86-
"test setoutputsizes is valid (wrong column)"
87-
self.cursor.setoutputsize(25000, 1)
88-
self.cursor.execute(u"select * from TestLongRaws")
89-
longVar = self.cursor.fetchvars[1]
90-
self.assertEqual(longVar.size, 131072)
91-
9277
def testArraySizeTooLarge(self):
9378
"test array size too large generates an exception"
9479
self.cursor.arraysize = 268435456

0 commit comments

Comments
 (0)