tanrj / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

Printing character data results from Teradata results in "\x00\x00\x00\x00" prefixed tuple/mangled data... #146

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Connect to Teradata (version 12 or 13) from Linux using pyodbc 2.1.8 + 
python 2.4.
2. Do a SHOW TABLE on an object
3. Print the rows from the fetchall()

What is the expected output?

Something like:

("CREATE SET TABLE dba_tool.test1 ,NO FALLBACK ,
     NO BEFORE JOURNAL,
     NO AFTER JOURNAL,
     CHECKSUM = DEFAULT
     (
      t1 INTEGER,
      HOST_IP_ADDR CHAR(16)

[truncated output...]

What do you see instead?

("\x00\x00\x00\x00TE SET TABLE dba_tool.test1 ,NO FALLBACK ,
     NO BEFORE JOURNAL,
     NO AFTER JOURNAL,
     CHECKSUM = DEFAULT
     (
      t1 INTEGER,
      HOST_IP_ADDR CHAR(16)

[truncated output...]

What version of the product are you using? On what operating system?

Using Pyodbc 2.1.8.  Running on RHES, as below

uname -a 
Linux phxaisadm002 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 
x86_64 x86_64 GNU/Linux

Please provide any additional information below.

Original issue reported on code.google.com by textur...@gmail.com on 18 Dec 2010 at 8:40

GoogleCodeExporter commented 8 years ago
Solved this finally...

setup.py required some additional parameters to be set

extra_link_args    = ['-L/opt/teradata/client/ODBC_64/lib']

# Python functions take a lot of 'char *' that really should be const.  gcc 
complains about this *a lot*
 extra_compile_args = ['-Wno-write-strings', '-I/opt/teradata/client/ODBC_64/include', '-DSQL_CP_ONE_PER_HENV=2']

Additionally, there were a few changes that needed to be made to the 
sourcefiles, but that is a separate issue..

Original comment by textur...@gmail.com on 6 Jan 2011 at 11:33

GoogleCodeExporter commented 8 years ago
I am facing the same problem w/ another database. 

@textures2 could you outline which source files you had to modify. 

Running openSuse11.x
uname -a
Linux gelsenkirchen 2.6.31.5-0.1-desktop #1 SMP PREEMPT 2009-10-26 15:49:03 
+0100 x86_64 x86_64 x86_64 GNU/Linux

pyodbc version = 2.1.8

>>> row
(..., '\x00\x00\x00\x00lay', ...)

expected would be

'display'

the ODBC trace contains the following details

SQLGetData 2011-04-29 08:00:33.073488
StatementHandle  [in]    : 0x000000000081d690
ColumnNumber     [in]    : 2
TargetType       [in]    : SQL_C_CHAR
TargetValuePtr   [out]   : 0x00007fff948a8520
BufferLength     [in]    : 1024
ValuePtr         [out]   : SQL_UB_OFF

::GETOBJECT SQLCURS_5 RESULT[0059218C3C7F0000]
COLUMN
INDEX TYPE       AT LENGTH     INDICATOR          DATA               POSITION
2     ASCII       T 1024       0x00007fff948a8100 0x00007fff948a8520 
0x0000000000000000 
DATA
INDEX TYPE       AT LENGTH        INDICATOR     DATA
2     ASCII       T 1024          7             'display'
StrLen_or_IndPtr [out]    : 7
SQLRETURN                : SQL_SUCCESS

Any help is appreciated.

Original comment by schapra...@gmail.com on 29 Apr 2011 at 10:49

GoogleCodeExporter commented 8 years ago
Any update on this 'matthieu...@hpi.uni-potsdam.de'?? 

I am getting the same problem where the first 4 characters are replaced with 
'\x00\x00\x00\x00' ?

Linux <name> 2.6.18-348.3.1.el5 #1 SMP Tue Mar 5 13:19:32 EST 2013 x86_64 
x86_64 x86_64 GNU/Linux
pyodbc-2.1.5-2.el5

Original comment by archank2...@gmail.com on 28 Mar 2013 at 9:19