[pypy-svn] r69407 - in pypy/trunk/pypy/module/oracle: . test
afa at codespeak.net
afa at codespeak.net
Thu Nov 19 01:28:50 CET 2009
Author: afa
Date: Thu Nov 19 01:28:49 2009
New Revision: 69407
Modified:
pypy/trunk/pypy/module/oracle/interp_variable.py
pypy/trunk/pypy/module/oracle/test/test_stringvar.py
Log:
implement getvalue() for LONG_STRING variables
Modified: pypy/trunk/pypy/module/oracle/interp_variable.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/interp_variable.py (original)
+++ pypy/trunk/pypy/module/oracle/interp_variable.py Thu Nov 19 01:28:49 2009
@@ -486,6 +486,17 @@
isVariableLength = True
size = 128 * 1024
+ def getValueProc(self, space, pos):
+ ptr = rffi.ptradd(self.data, pos * self.bufferSize)
+ length = rffi.cast(roci.Ptr(roci.ub4), ptr)[0]
+
+ l = []
+ i = 0
+ while i < length:
+ l.append(self.data[i + rffi.sizeof(roci.ub4)])
+ i += 1
+ return space.wrap(''.join(l))
+
def setValueProc(self, space, pos, w_value):
buf = config.StringBuffer()
buf.fill(space, w_value)
@@ -496,10 +507,10 @@
self.resize(buf.size + rffi.sizeof(roci.ub4))
# copy the string to the Oracle buffer
- data = rffi.ptradd(self.data, pos * self.bufferSize)
- rffi.cast(roci.Ptr(roci.ub4), data)[0] = rffi.cast(roci.ub4, buf.size)
+ ptr = rffi.ptradd(self.data, pos * self.bufferSize)
+ rffi.cast(roci.Ptr(roci.ub4), ptr)[0] = rffi.cast(roci.ub4, buf.size)
for index in range(buf.size):
- data[index + rffi.sizeof(roci.ub4)] = buf.ptr[index]
+ ptr[index + rffi.sizeof(roci.ub4)] = buf.ptr[index]
finally:
buf.clear()
Modified: pypy/trunk/pypy/module/oracle/test/test_stringvar.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/test/test_stringvar.py (original)
+++ pypy/trunk/pypy/module/oracle/test/test_stringvar.py Thu Nov 19 01:28:49 2009
@@ -119,11 +119,14 @@
def test_longstring(self):
cur = self.cnx.cursor()
+ output = cur.var(oracle.LONG_STRING)
cur.execute("""
declare
t_Temp varchar2(10000);
begin
t_Temp := :bigString;
+ :output := t_Temp;
end;""",
- bigString="X" * 10000)
+ bigString="X" * 10000, output=output)
+ assert output.getvalue() == "X" * 10000
More information about the Pypy-commit
mailing list