Re: Memory problems with dbcmd
"James K. Lowden" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 4 Dec 2012 10:45:40 +0100 Alberto Pulvirenti <[email protected]> wrote: > Can it happen that a sudden and momentary communication failure > causes dbcmd() to fail? No. > Or its failure are only due to memory allocation problems? Also no! :-) Have a look at the dbcmd() code in dblib.c. You'll note it can fail for memory allocation reasons, but also checks the parameters it was called with and the state of the connection first. The state of the connection is *not* affected by transient network problems, though. A connection's state is a function of how the most recent communication with the server fared: as long as tcp doesn't report that the server disconnected, and the client received a response (of any kind) from the server for the previous query, the connection is considered OK. OTOH if the server closed the connection, it is marked DEAD because no further use can be made of it. A db-lib function invoked with a DEAD dbproc fails immediately on seeing the DEAD status, saving pointless lost time trying to use a connection that has no peer listening on the other end. dbcmd() invokes the error handler before it returns FAIL. Your handler should display that message somewhere. HTH. --jkl