Re: Segfault When Fetching NVARCHAR(MAX) Column

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CAHt6W4dgtHemPuuB1xdM4+bjF-DC=076=NAiLDahnoULKaozOA@mail.gmail.com>
>
> Which PyODBC/unixODBC version are you using?
> I bet is a mismatch between SQLWCHAR and Py_UNICODE type.
>
> Looking at not-working log mssql returns 0x49c == 1180. PyODBC try to
> read 1024 bytes and get 1022 bytes which left 158 bytes to read then
> PyODBC try to read 160 bytes (158 + 2 terminator). All is correct and
> should work but then pyodbc cores... Allocations seem good and should
> not cause problems however if Python is using Py_UNICODE_SIZE == 4
> should even convert string from UCS-2 to UCS-4 (I didn't test this).
>
> Which operating system/version are you using ?
>

On Ubuntu...


$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
>>> conn = pyodbc.connect('DSN=sqlexpress;UID=sa;PWD=XXXXXX;')
>>> cursor = conn.cursor()
>>> cursor.execute("SELECT N'ciao a tutti'")
<pyodbc.Cursor object at 0x22bf450>
>>> cursor.fetchall()
[(u'\U00690063\U006f0061\U00610020\U00740020\U00740075\U00690074', )]
>>> u'ciao'
u'ciao'
>>>


$ python -c "import sys;print(sys.maxunicode<66000)and'UCS2'or'UCS4'"
UCS4


No comment....

freddy77
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.