On Sep 4, 2:14 pm, Iñaki Baz Castillo <[email protected]> wrote:
> If I create a MySQL prepared stament, use it and latter restart MySQL then
> Sequel receives this error for the next query using the prepared stament:
>
>   !! Unexpected error while processing request: Mysql::Error: Unknown prepared
>   statement handler (get_document) given to EXECUTE
>
> I do understand what happens: prepared staments are stored in the server and
> lost on restart.
>
> However, I expect that Sequel could have an automatic way to re-generate the
> prepared staments if it's not recognized by the DB server.

The prepared statements are stored per connection instance.
Unfortunately, the MySQL adapter has automatic reconnection turned on,
but there should probably be an option to disable that.  The MySQL
adapter code also has the ability to raise the DatabaseDisconnectError
(which is the correct Sequel way to handle things), but it's possible
the automatic reconnection by the driver is used in some cases.

> Also, I would like to do it manually by catching the exception, but
> unfortunatelly the raised exception is generic:
>
>   Sequel::DatabaseError: Mysql::Error: Unknown prepared statement
>   handler (get_document) given to EXECUTE
>
> This is, by inspecting the exception (Sequel::DatabaseError), I cannot know
> the reason of the failure (parsing the exception reason is not very reliable).

I'm about to commit a patch that will include the underlying exception
as a wrapped exception, so you can do:

  rescue Sequel::Error => e
    case e.wrapped_exception
    when Mysql::Error
      ...
    end
  end

> I've also realized that when using MySQL, if the database is stopped (or there
> is a network/socket error) then when performing a query I get the folowing
> exception:
>
>   Mysql::Error - Can't connect to local MySQL server through socket
>   '/var/run/mysqld/mysqld.sock'
>
> This is, the raised exception is totally dependant on the adapter. Shouldn't
> Sequel capture these exception and convert them to a generic Sequel exception?
> If not, I should add:
>   rescue Mysql::Error, Postgress::ConnectionError ...
> and so, which is not very cool.

In cases where Sequel isn't converting them to an instance of
Sequel::DatabaseError, those are probably bugs that should be fixed.

Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to