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

Connection messages lost in presence of preceding result set #9

Open
craigahobbs opened this issue Sep 28, 2017 · 2 comments
Open

Connection messages lost in presence of preceding result set #9

craigahobbs opened this issue Sep 28, 2017 · 2 comments

Comments

@craigahobbs
Copy link

craigahobbs commented Sep 28, 2017

Run the following code and notice the output:

import ctds

connection = ctds.connect(
    'localhost',
    user='sa',
    password='password',
    database='Mortgage'
)
with connection.cursor() as cursor:
    cursor.execute('''\
SELECT N'Before';

DECLARE @Cmd NVARCHAR(MAX);
SET @Cmd = N'RAISERROR(@Msg,@Severity,10) WITH NOWAIT;';
EXEC sp_executesql @Cmd,
                   N'@Msg NVARCHAR(MAX),@Severity INT',
                   N'Hello!,'
                   0;

SELECT N'After';
''')
    for message in connection.messages:
        print('=== msg ===', message['description'])
    while cursor.description:
        row = cursor.fetchone()
        if row:
            print('=== row ===', row[0])
        else:
            print('=== row === weird, null row in result set???')
        cursor.nextset()

Actual output:

=== row === Before
=== row === weird, null row in result set???
=== row === After

Expected output:

=== msg === Hello!
=== row === Before
=== row === After

Notice the message is lost in the actual case and also the unexpected null row. If you comment out the "Before" select you get the message and you don't get the unexpected null row.

@craigahobbs
Copy link
Author

Behavior unchanged in libfreetds dev.1.00.304

@joshuahlang
Copy link
Collaborator

This is due to: FreeTDS/freetds#156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants