El Sábado, 5 de Septiembre de 2009, Jeremy Evans escribió:
> > > I think it occurs when I call to ps#call (prepared stament) while the
> > > MySQL is restarting/stopped.
> 
> Is that not wrapped in a Sequel::DatabaseError (or a subclass)
> instance?



> That's the changed behavior.  Before, when the MySQL server was up
> again, the connection still thought the statement had already been
> prepared.  Now it knows that it hasn't, so it prepares the statement
> first before executing it.

It doesn't work for me.

 
> I can't replicate your issue:
> 
> $ ruby -I lib bin/sequel -E mysql://root:r...@localhost/test
> Your database is stored in DB...
> irb(main):001:0> ps = DB['SELECT 1'].prepare(:first, :a)
> => <Sequel::MySQL::Dataset/PreparedStatement "SELECT 1">
> irb(main):002:0> ps.call({})
> I, [2009-09-04T15:56:13.020397 #23364]  INFO -- : PREPARE a FROM
> 'SELECT 1'
> I, [2009-09-04T15:56:13.020999 #23364]  INFO -- : EXECUTE a
> => {:"1"=>1}
> irb(main):003:0>
> irb(main):004:0* ps.call({})
> I, [2009-09-04T15:56:21.646780 #23364]  INFO -- : EXECUTE a
> => {:"1"=>1}
> irb(main):005:0> [2] + Suspended            ruby -I lib bin/sequel -E
> mysql://root:r...@loc
> $ sudo mysqladmin --user root -p shutdown
> Password:
> Enter password:
> $ fg
> ruby -I lib bin/sequel -E mysql://root:r...@loc
> irb(main):005:0> ps.call({})
> I, [2009-09-04T15:57:17.794880 #23364]  INFO -- : EXECUTE a
> Sequel::DatabaseDisconnectError: Mysql::Error: Can't connect to local
> MySQL server through socket '/var/run/mysql/mysql.sock' (2)
>         from ./lib/sequel/adapters/mysql.rb:157:in `query'
>         from ./lib/sequel/adapters/mysql.rb:157:in `_execute'
>         from ./lib/sequel/adapters/mysql.rb:234:in
> `execute_prepared_statement'
>         from ./lib/sequel/connection_pool.rb:112:in `hold'
>         from ./lib/sequel/database.rb:482:in `synchronize'
>         from ./lib/sequel/adapters/mysql.rb:221:in
> `execute_prepared_statement'
>         from ./lib/sequel/adapters/mysql.rb:136:in `execute'
>         from ./lib/sequel/dataset.rb:334:in `execute'
>         from ./lib/sequel/adapters/mysql.rb:359:in `execute'
>         from ./lib/sequel/adapters/mysql.rb:271:in `execute'
>         from ./lib/sequel/adapters/mysql.rb:315:in `fetch_rows'
>         from ./lib/sequel/dataset.rb:189:in `each'
>         from ./lib/sequel/dataset/convenience.rb:196:in
> `single_record'
>         from ./lib/sequel/dataset/convenience.rb:59:in `first'
>         from ./lib/sequel/dataset/prepared_statements.rb:118:in `run'
>         from ./lib/sequel/dataset/prepared_statements.rb:24:in `call'
>         from (irb):5irb(main):006:0> ps.call({})
> Sequel::DatabaseConnectionError: Mysql::Error: Can't connect to local
> MySQL server through socket '/var/run/mysql/mysql.sock' (2)
>         from ./lib/sequel/adapters/mysql.rb:101:in `real_connect'
>         from ./lib/sequel/adapters/mysql.rb:101:in `connect'
>         from ./lib/sequel/database.rb:93:in `initialize'
>         from ./lib/sequel/connection_pool.rb:169:in `call'
>         from ./lib/sequel/connection_pool.rb:169:in `make_new'
>         from ./lib/sequel/connection_pool.rb:156:in `available'
>         from ./lib/sequel/connection_pool.rb:147:in `acquire'
>         from ./lib/sequel/connection_pool.rb:146:in `synchronize'
>         from ./lib/sequel/connection_pool.rb:146:in `acquire'
>         from ./lib/sequel/connection_pool.rb:102:in `hold'
>         from ./lib/sequel/database.rb:482:in `synchronize'
>         from ./lib/sequel/adapters/mysql.rb:221:in
> `execute_prepared_statement'
>         from ./lib/sequel/adapters/mysql.rb:136:in `execute'
>         from ./lib/sequel/dataset.rb:334:in `execute'
>         from ./lib/sequel/adapters/mysql.rb:359:in `execute'
>         from ./lib/sequel/adapters/mysql.rb:271:in `execute'
>         from ./lib/sequel/adapters/mysql.rb:315:in `fetch_rows'
>         from ./lib/sequel/dataset.rb:189:in `each'
>         from ./lib/sequel/dataset/convenience.rb:196:in
> `single_record'
>         from ./lib/sequel/dataset/convenience.rb:59:in `first'
>         from ./lib/sequel/dataset/prepared_statements.rb:118:in `run'
>         from ./lib/sequel/dataset/prepared_statements.rb:24:in `call'
>         from (irb):6irb(main):007:0> [2] + Suspended            ruby -
> I lib bin/sequel -E mysql://root:r...@loc
> $ fg %1
> sudo mysqld_safe > /dev/null 2>&1
> $ sudo mysqld_safe > /dev/null 2>&1
> ^Z[1] + Suspended            sudo mysqld_safe > /dev/null 2>&1
> $ bg
> [1] sudo mysqld_safe > /dev/null 2>&1
> $ fg %2
> ruby -I lib bin/sequel -E mysql://root:r...@loc
> ps.call({})
> I, [2009-09-04T15:57:55.261062 #23364]  INFO -- : PREPARE a FROM
> 'SELECT 1'
> I, [2009-09-04T15:57:55.261715 #23364]  INFO -- : EXECUTE a
> => {:"1"=>1}
> irb(main):008:0> ps.call({})
> I, [2009-09-04T15:57:57.052248 #23364]  INFO -- : EXECUTE a
> => {:"1"=>1}
> irb(main):009:0>
> 
> 
> The difference could be due to the fact that I just committed an
> exception related change to the master branch.  Please try with the
> master branch and let me know your results.  If you find that there is
> still a situation where the Mysql::Error is not being wrapped in a
> Sequel::DatabaseError, please post an example with a backtrace so I
> can track it down.


Humm, note what happens to me when trying to repeat your test:

# ruby -I lib /usr/bin/sequel -E mysql://root:xx...@localhost/xxxxxxx
Error: Sequel::AdapterNotFound: Could not load mysql adapter:
  require 'mysql' did not define Mysql::CLIENT_MULTI_RESULTS!
  You are probably using the pure ruby mysql.rb driver,
  which Sequel does not support. You need to install
  the C based adapter, and make sure that the mysql.so
  file is loaded instead of the mysql.rb file.
/usr/lib/ruby/gems/1.8/gems/sequel-3.4.0/lib/sequel/database.rb:112:in 
`adapter_class'


In fact, if I do:

irb> require "mysql"
LoadError: require 'mysql' did not define Mysql::CLIENT_MULTI_RESULTS!
  You are probably using the pure ruby mysql.rb driver,
  which Sequel does not support. You need to install
  the C based adapter, and make sure that the mysql.so
  file is loaded instead of the mysql.rb file.

        from ./mysql.rb:2
        from (irb):1:in `require'
        from (irb):1
        from :0


but if I use the mysql gem I don't get the error:

irb> require "rubygems"
true
irb:002:0> gem "mysql"
true



hummm...

which exactly version of the Ruby mysql driver must I install? is it installed 
via gem?

Thanks a lot.



-- 
Iñaki Baz Castillo <[email protected]>

--~--~---------~--~----~------------~-------~--~----~
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