Bobspadger / pyodbc

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

"SELECT" query causes Appcrash when targeted at literals >1023 characters #202

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Connect to Database (all other queries of DB work fine). I'm using this code:

    import pyodbc
    cnxn = pyodbc.connect('DSN=Facts Database; Directory=/u/facts75;' \
                          'LogFile=\PVXODBC.LOG;RemotePVKIOHost=192.168.1.101;' \
                          'RemotePVKIOPort=20222; SERVER=NotTheServer', \
    autocommit=True)

    cursor = cnxn.cursor()

(I've fiddled with the indents when posting)

2. Try to query for a long text string. The database I'm working with has an 
entry with length 1023 and the next length is 1031. So since I can't test on 
lengths 1023<x<1031, I can't be too precise about the size that causes the 
issue. But I'm putting my money on (2^10)=1024. I'm using this code:

    num = str(input('try note number...'))
    text = cursor.execute("select note from AR_CUSTOMER_NOTES_B where \
    comp='01' and note_num='"+num+"'").fetchone()[0]
    print text

If I enter the ID number for a note that's <=1023 characters long, the cursor 
returns the text message of the note.

3. APPCRASH!!

What is the expected output? What do you see instead?
I expect the text of the note. Or, at the very least, I'd like python to return 
an error message. Instead, I get a nice message from Windows saying that 
"pythonw.exe has stopped working". Details:

Problem signature:
  Problem Event Name:   APPCRASH
  Application Name: pythonw.exe
  Application Version:  0.0.0.0
  Application Timestamp:    4cf14062
  Fault Module Name:    StackHash_0a9e
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp:   00000000
  Exception Code:   c0000005
  Exception Offset: 4b52414d
  OS Version:   6.1.7601.2.1.0.256.48
  Locale ID:    1033
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

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

Windows 7 Pro, x64 (but I'm using all 32bit python stuff because the odbc 
driver I'm working with is 32bit. And 64bit programs can't access 32 bit 
drivers)

Python 2.7.1 (32-bit version)
pyodbc 2.1.8 (win32-py2.7)
ProvideX ODBC Client 4.21.1000 for Windows.

Please provide any additional information below.
1) I do have a number of other python modules installed, scipy, numpy, pywin, 
matplotlib, etc.

2)The column information found using 
"cursor.columns(table='AR_CUSTOMER_NOTES_B',column='note').fetchall()" is 
below. It lists the data type as "LONGVARCHAR", and the column size as 9999. 
However, in the attached file (data_types.csv) listing all the data types 
supported by the ODBC driver (created by "cursor.getTypeInfo().fetchall()"), 
the column size for the same type is listed as 65535.

table_cat = None
table_schem = None
table_name = AR_CUSTOMER_NOTES_B
column_name = note
data_type = -1
type_name = LONGVARCHAR
column_size = 9999
buffer_length = 9999
decimal_digits = 0
num_prec_radix = None
nullable = 1
remarks = None
column_def = 
sql_data_type = -1
sql_datetime_sub = None
char_octet_length = 9999
ordinal_position = 2
is_nullable: YES

Original issue reported on code.google.com by sam.Cros...@gmail.com on 22 Aug 2011 at 9:38

Attachments:

GoogleCodeExporter commented 9 years ago
Updated Pyodbc to 2.1.9 (win32-py2.7). Issue remains.

Original comment by sam.Cros...@gmail.com on 23 Aug 2011 at 2:47

GoogleCodeExporter commented 9 years ago
I know 1024 can be read from some databases.  The SQL Server unit tests on 
Windows tests these:  0, 1, 255, 256, 510, 511, 512, 1023, 1024, 2047, 2048, 
4000, 4095, 4096, 4097, 10 * 1024, 20 * 1024 

I thought ProvideX was a language -- I didn't realize there was a DB also.

Can you generate an ODBC trace file for this?  That would help me reproduce the 
same situation with another database.

Also, is it possible for me to get a copy of the driver and a test database? 

Original comment by mkleehammer on 13 Sep 2011 at 10:45

GoogleCodeExporter commented 9 years ago
I don't know how to generate an ODBC trace file. I can get you a copy of the 
driver, but there's licensing involved in the installation. As for a test 
database... I'm not sure how to create one.

ProvideX is a development platform including a language (BASIC variant, if 
memory serves) and a database, fundamental GUI elements, client-server 
communication management etc. In short, all the infrastructure you'd need to 
build before you started  the visible elements of a data management software.

Original comment by sam.Cros...@gmail.com on 14 Sep 2011 at 5:30

GoogleCodeExporter commented 9 years ago

Original comment by mkleehammer on 23 Dec 2011 at 8:12

GoogleCodeExporter commented 9 years ago

Original comment by mkleehammer on 29 Sep 2012 at 6:13