Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this gonna take long... #29

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Conversation

braian87b
Copy link
Collaborator

No description provided.

Rafael Muñoz and others added 17 commits June 8, 2014 21:37
Add support for es_ES dates
NamedTupleRow and MutableNamedTupleRow depend on _ColBufferList being
populated, so without this change they do not work.
This is consistent with pyodbc.
I think out-of-the-box compatibility with pyodbc is a worthy goal. I
understand not wanting a hard dependency on 'recordtype' but at least
providing read-only named field access seems like an improvement.
I've run into memory corruption bugs with the following test program on
64-bit Linux, sizeof(wchar_t) == 4, sizeof(Py_UNICODE) == 4,
sizeof(SQLWCHAR) == 2.

    from pypyodbc import connect

    # Replace '...' with real values
    conn_string = 'DRIVER={SQL Server};SERVER=...;PORT=1433;UID=...;PWD=...;TDS_Version=7.1;APP=...;DATABASE=...'
    while True:
        connect(conn_string, ansi=False)

For me this typically causes libc to abort() complaining of memory
corruption, double-free, etc. within a few tens of iterations with
cpython (and quicker with pypy).

The bug seems to be in the conversion from Python string to
SQLWCHAR * when calling SQLDriverConnectW. Given the sizes above,
pypyodbc sets wchar_pointer = ctypes.c_char_p, then passes a
UTF-16-encoded byte buffer to it. ctypes.c_char_p null-terminates the
string when converting to a C array - but it only adds a single NUL
byte. unixODBC expects that argument to be a UTF-16 array, terminated by
two NUL bytes.

This fix is a bit of a hack, but it does work.

It might be clearer to define something akin to c_char_p for these
arguments, I suppose.
compact db - support for password protected db, allow space within da…
Add support for es_ES dates
Change length of state buffer from 22 to 24 bytes.
Raise OperationalError for ConnectionWrite error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants