Summary:ASTERISK-05415: [patch] ODBC handles become invalid during disconnect/reconnect
Reporter:Tilghman Lesher (tilghman)Labels:
Date Opened:2005-11-01 11:19:13.000-0600Date Closed:2008-01-15 15:55:08.000-0600
Versions:Frequency of
Environment:Attachments:( 0) 20051101__res_odbc__sanity.diff.txt
Description:Currently, odbc_smart_execute() does a disconnect/reconnect sequence when a query fails to run.  Unfortunately, this won't work for databases such as SQL Server, because all statement handles become invalid when the connection is dropped.  We need to be able to re-prepare the query after a disconnect, so that the statement handles we pass to SQLExecute are valid.

This patch creates a new function, odbc_prepare_and_execute, which takes a callback to a prepare function for doing a prepare, but also allows all the other calls that may be done before an Execute (such as binding parameters, binding result sets, etc.)  This way, when we do a disconnect, we can re-prepare the statement handle exactly as we need it, before trying to Execute the query again.
Comments:By: Tilghman Lesher (tilghman) 2005-11-01 11:22:03.000-0600

I suspect the disconnect/reconnect works on MySQL, since the statements are prepared only in memory.  Such is not the case for most databases, where the prepare is done on the server and is preserved for as long as the connection is retained.  The MySQL case is probably why this sequence ever worked at all for the author.

By: Kevin P. Fleming (kpfleming) 2005-11-01 16:01:19.000-0600

It doesn't appear that this patch actually uses this new function anywhere... Do you plan to post more patches to actually use it that should go into 1.2, or is this just preparation for future work?

By: Tilghman Lesher (tilghman) 2005-11-01 16:13:18.000-0600

It is a public function, for use in other modules.

But yes, we'll eventually convert stuff away from odbc_smart_execute() for the reasons specified above.

By: Kevin P. Fleming (kpfleming) 2005-11-01 16:21:35.000-0600

Well, I'm trying to make the call whether this is a new feature or not... certainly it would help solve some problems that are clearly bugs, though, so it should probably go in, and we can try to get the conversions made before the next (last) beta gets released.

By: Tilghman Lesher (tilghman) 2005-11-01 16:25:33.000-0600

From past experience, I'd rather try to get stuff merged before I create patches that are dependent upon them.

By: Kevin P. Fleming (kpfleming) 2005-11-08 21:10:36.000-0600

Committed to CVS HEAD, thanks!

By: Digium Subversion (svnbot) 2008-01-15 15:55:08.000-0600

Repository: asterisk
Revision: 7040

U   trunk/ChangeLog
U   trunk/include/asterisk/res_odbc.h
U   trunk/res/res_odbc.c

r7040 | kpfleming | 2008-01-15 15:55:07 -0600 (Tue, 15 Jan 2008) | 2 lines

issue ASTERISK-5415