[freetds] MS query notifications patch

Richard Hughes cyreve at gmail.com
Wed Apr 23 13:50:57 EDT 2014


On 2014-04-18 at 09:39, Frediano Ziglio wrote:
> 2014-04-16 19:12 GMT+01:00 Richard Hughes <cyreve at gmail.com>:
>> I needed support for SQL Server 2005's Query Notifications feature, so
>> here's a patch against tip.
>
> The big concern is that I think that this feature works also for every
> queries not for just sql ones. I'll add some comments on your code. I
> think we should test what happens for prepared statements or RPCs.

You're right. I was too stuck in my particular use-case to consider
that RPC might be possible. I actually can't think of realistic design
for an client application that would set up parameterized query
notifications, however the server does support it so I've gone ahead
and implemented it. Unfortunately this makes the patch a whole lot
bigger, and a large part of my delay in getting back to you was spent
changing my mind several times about the neatest way to squeeze it in.
You may wish to read the diff with ignore-whitespace, because I ended
up pulling a load of if statements out into their own functions.

>> @@ -228,6 +229,11 @@ prepare_call(struct _hstmt * stmt)
>>      else
>>          return SQL_ERROR;
>>
>> +    if (tds_dstr_isempty(&stmt->attr.qn_msgtext) != tds_dstr_isempty(&stmt->attr.qn_options))
>> +        return SQL_SUCCESS_WITH_INFO;
>> +    if (!tds_dstr_isempty(&stmt->attr.qn_msgtext) && !IS_TDS72_PLUS(stmt->dbc->tds_socket->conn))
>> +        return SQL_SUCCESS_WITH_INFO;
>> +
>
> I'm not sure this is the right place. Also I think MS add some error
> to the statement. I didn't find from documentation which error should
> be reported.

Yes - the _WITH_INFO part should have been a clue that I needed to
return some info. MS Native Client returns HY000 for the first case
and still executes the query, but I don't have a pre-2005 server to
find out what should happen in the second case so I just left it as a
generic error.

All your other comments have been swept up in to the big restructuring
I needed to do to get RPC working.

Richard.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freetds-mssql-query-notifications-v2.diff
Type: application/octet-stream
Size: 38902 bytes
Desc: not available
URL: <http://lists.ibiblio.org/pipermail/freetds/attachments/20140423/f49e9b8b/attachment-0001.obj>


More information about the FreeTDS mailing list