I have refined this to a simple repeatable test as shown below...

Basically the first set of inserts runs, but the second fails, however
if I were to submit each line individually it will work, but this is a
test case, in the real world I am migrating an existing set of sql
commands which is why I need to run them raw this way.

sequel version 3.11.0
mysql 2.8.1
ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-linux]

# test.rb
require 'rubygems'
require 'sequel'
require 'logger'

# run 'DROP DATABASE IF EXISTS test1'
# run 'CREATE DATABASE test1'

DB = Sequel.connect('mysql://r...@localhost/test1', :logger =>
Logger.new(STDOUT))

DB.create_table :test1 do
  primary_key :id
  String :name
  String :arg1
  String :arg2
  String :arg3
end

sql1= %q[
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
]

print "running inserts first time"
DB.run(sql1)
print "first set of inserts done"

sql2= %q[
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
]

print "running inserts second time"
DB.run(sql2)
print "second set of inserts done"

When run I get this error...

> ruby test1.rb
I, [2010-05-27T14:58:55.223230 #17067]  INFO -- : (0.005202s) CREATE
TABLE `test1` (`id` integer PRIMARY KEY AUTO_INCREMENT, `name`
varchar(255), `arg1` varchar(255), `arg2` varchar(255), `arg3`
varchar(255))
running inserts first timeI, [2010-05-27T14:58:55.223675 #17067]  INFO
-- : (0.000297s)
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test', 'arg1',
'arg2', 'arg3');

first set of inserts donerunning inserts second timeE,
[2010-05-27T14:58:55.223834 #17067] ERROR -- : Mysql::Error: Commands
out of sync; you can't run this command now:
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');
INSERT INTO test1 (name, arg1, arg2, arg3) VALUES ('test2', 'arg1',
'arg2', 'arg3');

/usr/local/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/sequel/adapters/
mysql.rb:160:in `query': Mysql::Error: Commands out of sync; you can't
run this command now (Sequel::DatabaseDisconnectError)
 from /usr/local/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/sequel/
adapters/mysql.rb:160:in `_execute'
 from /usr/local/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/sequel/
database.rb:454:in `log_yield'
 from /usr/local/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/sequel/
adapters/mysql.rb:160:in `_execute'
 from /usr/local/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/sequel/
adapters/mysql.rb:144:in `execute'
 from /usr/local/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/sequel/
connection_pool/threaded.rb:84:in `hold'
 from /usr/local/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/sequel/
database.rb:553:in `synchronize'
 from /usr/local/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/sequel/
adapters/mysql.rb:144:in `execute'
 from /usr/local/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/sequel/
database.rb:345:in `execute_dui'
 from /usr/local/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/sequel/
database.rb:338:in `execute_ddl'
 from /usr/local/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/sequel/
database.rb:504:in `run'
 from sequel_bug.rb:45

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