mysql 2.7 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
- <!-- $Id: README.html,v 1.16 2005/08/21 15:20:45 tommy Exp $ -->
2
+ <!-- $Id: README.html 244 2009-02-01 08:43:39Z tommy $ -->
3
3
  <html>
4
4
  <head>
5
5
  <meta http-equiv="content-style-type" content="text/css">
@@ -22,8 +22,8 @@
22
22
 
23
23
  <h2>Requirement</h2>
24
24
  <ul>
25
- <li>MySQL 4.0.22/4.1.13/5.0.11
26
- <li>Ruby 1.8.2
25
+ <li>MySQL 5.0.67
26
+ <li>Ruby 1.8.7, 1.9.1
27
27
  </ul>
28
28
  <p>
29
29
  The module may work for other versions, but that has not been verified.
@@ -84,7 +84,7 @@
84
84
  2nd:
85
85
  </p>
86
86
  <pre class="code">
87
- % ruby ./test.rb [<i>hostname</i> [<i>user</i> [<i>passwd</i> [<i>dbname</i> [<i>port</i> [<i>socket</i> [<i>flag</i>]]]]]]]
87
+ % ruby ./test.rb -- [<i>hostname</i> [<i>user</i> [<i>passwd</i> [<i>dbname</i> [<i>port</i> [<i>socket</i> [<i>flag</i>]]]]]]]
88
88
  </pre>
89
89
 
90
90
  <p>
@@ -103,6 +103,9 @@
103
103
  <pre class="code">
104
104
  % env LD_RUN_PATH=<i>libmysqlclient.so directory</i> make
105
105
  </pre>
106
+ <p>
107
+ test.rb is tested on Linux only.
108
+ </p>
106
109
 
107
110
  <h2>Usage</h2>
108
111
  <p>
@@ -384,9 +387,13 @@
384
387
  <dd>
385
388
  <p>
386
389
  do query and execute block with Mysql::Result object.
387
- if you specify multiple query, then repeat block.
388
- set_server_option(Mysql::OPTION_MULTI_STATEMENTS) is executed automatically.
389
- </p>
390
+ Mysql::Result object is freed when exiting block.
391
+ If multiple statement mode, it does repeat block each query.
392
+ </p>
393
+ <p>
394
+ Since MySQL/Ruby 2.8, it no longer turn on multiple statement mode automatically.
395
+ If you want to turn on multiple statement mode, set Mysql::CLIENT_MULTI_STATEMENTS for Mysql.connect or execute Mysql#set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON).
396
+ </p>
390
397
 
391
398
  <dt>refresh(r)
392
399
  <dd>
@@ -697,7 +704,7 @@ st.close
697
704
  <tr><td>FLOAT, DOUBLE<td>Float
698
705
  <tr><td>DECIMAL<td>String
699
706
  <tr><td>DATE, DATETIME, TIMESTAMP, TIME<td>Mysql::Time
700
- <tr><td>CHAR, VARCHAR, BINARY, VARBINARY, TINYBLOB, TINYTEXT, TINYBLOB, TINYTEXT, MEDIUMBLOB, MEDIUMTEXT, LONGBLOB, LONGTEXT, ENUM, SET<td>String
707
+ <tr><td>CHAR, VARCHAR, BINARY, VARBINARY, TINYBLOB, TINYTEXT, TINYBLOB, TINYTEXT, MEDIUMBLOB, MEDIUMTEXT, LONGBLOB, LONGTEXT, ENUM, SET, BIT<td>String
701
708
  <tr><td>NULL<td>NilClass
702
709
  </table>
703
710
 
@@ -811,6 +818,87 @@ st.close
811
818
 
812
819
  <h2>History</h2>
813
820
  <dl>
821
+ <dt>2009-02-01
822
+ <dd>
823
+ version 2.8.1<br>
824
+ <ul>
825
+ <li>correspond to Ruby 1.9.1
826
+ </ul>
827
+
828
+ <dt>2008-09-29
829
+ <dd>
830
+ version 2.8<br>
831
+ version 2.7.7
832
+ <ul>
833
+ <li>When connecting to MySQL, EINTR is occurred sometimes ([ruby-dev:31842])
834
+ <li>MySQL/Ruby 2.7.* can not be compiled on Ruby 1.8.5.
835
+ </ul>
836
+
837
+ <dt>2008-06-20
838
+ <dd>
839
+ version 2.8pre4<br>
840
+ <ul>
841
+ <li>[ruby-dev:35152]
842
+ </ul>
843
+
844
+ <dt>2008-06-17
845
+ <dd>
846
+ version 2.8pre3<br>
847
+ version 2.7.6
848
+ <ul>
849
+ <li>On 64bit machine, Mysql::Stmt#execute raise error on large numeric value(>= 2**30).
850
+ </ul>
851
+
852
+ <dt>2008-03-08
853
+ <dd>
854
+ version 2.8pre2<br>
855
+ version 2.7.5
856
+ <ul>
857
+ <li>On 64bit machine, Mysql::Stmt#fetch return invalid numeric value.
858
+ </ul>
859
+
860
+ <dt>2007-12-26
861
+ <dd>
862
+ version 2.8pre1
863
+ <ul>
864
+ <li>for Ruby 1.9.0
865
+ <li>Incompat: Mysql::Result#each_hash don't create column name string each row. it's shared.
866
+ <li>Incompat: Mysql#query with block no longer turn on multi-statements mode automatically.
867
+ </ul>
868
+
869
+ <dt>2007-08-22
870
+ <dd>
871
+ version 2.7.4
872
+ <ul>
873
+ <li>BUG: Mysql::Stmt#execute memory leak.
874
+ </ul>
875
+
876
+ <dt>2006-12-20
877
+ <dd>
878
+ version 2.7.3
879
+ <ul>
880
+ <li>BUG: Mysql#query with block is stopped when last query failed.
881
+ </ul>
882
+
883
+ <dt>2006-10-28
884
+ <dd>
885
+ version 2.7.2
886
+ <ul>
887
+ <li>BUG: Mysql::Stmt#result_metadata don't return nil. (Thanks to Hidetoshi)
888
+ <li>BUG: Mysql#close check mysql_errno.
889
+ <li>BUG: multistatement Mysql#query with block ignore error.
890
+ <li>extconf.rb for Visual C++. (Thanks to Shugo Maeda)
891
+ <li>support MySQL BIT type.
892
+ <li>add Mysql::Field::TYPE_BIT, TYPE_NEWDECIMAL.
893
+ </ul>
894
+
895
+ <dt>2006-06-04
896
+ <dd>
897
+ version 2.7.1
898
+ <ul>
899
+ <li>change free() to xfree(). To avoid crash on Windows. (Thanks Tobias Grimm)
900
+ </ul>
901
+
814
902
  <dt>2005-08-22
815
903
  <dd>
816
904
  version 2.7
@@ -1004,7 +1092,7 @@ st.close
1004
1092
  <address><a href="mailto:tommy@tmtm.org">TOMITA Masahiro</a></address>
1005
1093
  <!-- Created: Sun Aug 29 11:52:09 JST 2004 -->
1006
1094
  <!-- hhmts start -->
1007
- Last modified: Mon Aug 22 00:20:00 JST 2005
1095
+ Last modified: Sun Feb 1 17:40:49 JST 2009
1008
1096
  <!-- hhmts end -->
1009
1097
  </body>
1010
1098
  </html>
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
- <!-- $Id: README_ja.html,v 1.20 2005/08/21 15:20:45 tommy Exp $ -->
2
+ <!-- $Id: README_ja.html 244 2009-02-01 08:43:39Z tommy $ -->
3
3
  <html>
4
4
  <head>
5
5
  <meta http-equiv="content-style-type" content="text/css">
@@ -21,8 +21,8 @@
21
21
 
22
22
  <h2>ɬ�פʤ��</h2>
23
23
  <ul>
24
- <li>MySQL 4.0.22/4.1.13/5.0.11
25
- <li>Ruby 1.8.2
24
+ <li>MySQL 5.0.67
25
+ <li>Ruby 1.8.7, 1.9.1
26
26
  </ul>
27
27
  <p>
28
28
  �����ʳ��Ǥ� make �Ǥ��뤫�⤷��ޤ��󤬡���ǧ���Ƥޤ���
@@ -80,7 +80,7 @@
80
80
  ���Ǵ�ñ�ʥƥ��Ȥ��Ǥ��ޤ���
81
81
  </p>
82
82
  <pre class="code">
83
- % ruby ./test.rb [<i>hostname</i> [<i>user</i> [<i>passwd</i> [<i>dbname</i> [<i>port</i> [<i>socket</i> [<i>flag</i>]]]]]]]
83
+ % ruby ./test.rb -- [<i>hostname</i> [<i>user</i> [<i>passwd</i> [<i>dbname</i> [<i>port</i> [<i>socket</i> [<i>flag</i>]]]]]]]
84
84
  </pre>
85
85
 
86
86
  <p>
@@ -100,6 +100,10 @@
100
100
  <pre class="code">
101
101
  % env LD_RUN_PATH=<i>libmysqlclient.so�ξ��</i> make
102
102
  </pre>
103
+ <p>
104
+ test.rb �� Linux ��Ǥ�ư�����ǧ���Ƥ��ޤ���
105
+ ¾�Υץ�åȥե�����Ǥϥ��顼���Ф뤫�⤷��ޤ���
106
+ </p>
103
107
 
104
108
  <h2>�Ȥ���</h2>
105
109
  <p>
@@ -393,9 +397,13 @@
393
397
  <p>
394
398
  �������¹Ԥ��ޤ���
395
399
  �����꤬��̤��֤���硢Mysql::Result ���֥������Ȥ�����Ȥ��ƥ֥��å���¹Ԥ��ޤ���
396
- �����ˡ�;�פǶ��ڤ�줿ʣ���Υ��������ꤷ�����ϡ�������ο������֥��å��򷫤��֤��ޤ���
397
- ��ưŪ�� set_server_option(Mysql::OPTION_MULTI_STATEMENTS) ���¹Ԥ���ޤ���
398
- </p>
400
+ �֥��å���λ���� Mysql::Result ���֥������Ȥϲ�������ޤ���
401
+ �ޥ�����ơ��ȥ��ȥ⡼�ɤǡ������ˡ�;�פǶ��ڤ�줿ʣ���Υ��������ꤷ�����ϡ�������ο������֥��å��򷫤��֤��ޤ���
402
+ </p>
403
+ <p>
404
+ MySQL/Ruby 2.8 ����ϡ���ưŪ�˥ޥ�����ơ��ȥ��ȥ⡼�ɤˤϤʤ�ʤ��ʤ�ޤ�����
405
+ Mysql.connect �� flag �� Mysql::CLIENT_MULTI_STATEMENTS ����ꤹ�뤫��Mysql#set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON) ��¹Ԥ��Ƥ���������
406
+ </p>
399
407
 
400
408
  <dt>refresh(r)
401
409
  <dd>
@@ -743,7 +751,7 @@ st.close
743
751
  <tr><td>FLOAT, DOUBLE<td>Float
744
752
  <tr><td>DECIMAL<td>String
745
753
  <tr><td>DATE, DATETIME, TIMESTAMP, TIME<td>Mysql::Time
746
- <tr><td>CHAR, VARCHAR, BINARY, VARBINARY, TINYBLOB, TINYTEXT, TINYBLOB, TINYTEXT, MEDIUMBLOB, MEDIUMTEXT, LONGBLOB, LONGTEXT, ENUM, SET<td>String
754
+ <tr><td>CHAR, VARCHAR, BINARY, VARBINARY, TINYBLOB, TINYTEXT, TINYBLOB, TINYTEXT, MEDIUMBLOB, MEDIUMTEXT, LONGBLOB, LONGTEXT, ENUM, SET, BIT<td>String
747
755
  <tr><td>NULL<td>NilClass
748
756
  </table>
749
757
 
@@ -891,6 +899,87 @@ st.close
891
899
 
892
900
  <h2>����</h2>
893
901
  <dl>
902
+ <dt>2009-02-01
903
+ <dd>
904
+ version 2.8.1<br>
905
+ <ul>
906
+ <li>Ruby 1.9.1 �����
907
+ </ul>
908
+
909
+ <dt>2008-09-29
910
+ <dd>
911
+ version 2.8<br>
912
+ version 2.7.7
913
+ <ul>
914
+ <li>MySQL�ؤ���³���� SIGVTALRM �� EINTR �ˤʤ뤳�Ȥ������������ ([ruby-dev:31842])
915
+ <li>MySQL/Ruby 2.7.* �� Ruby 1.8.5 �ǥ���ѥ���Ǥ��ʤ��ä���
916
+ </ul>
917
+
918
+ <dt>2008-06-20
919
+ <dd>
920
+ version 2.8pre4
921
+ <ul>
922
+ <li>���顼����ե�����򳰤���������¾��[ruby-dev:35152]
923
+ </ul>
924
+
925
+ <dt>2008-06-17
926
+ <dd>
927
+ version 2.8pre3<br>
928
+ version 2.7.6
929
+ <ul>
930
+ <li>64bit �Ķ��� Mysql::Stmt#execute ���礭�ʿ���(2**30 �ʾ�)�ǥ��顼�ˤʤ����������
931
+ </ul>
932
+
933
+ <dt>2008-03-08
934
+ <dd>
935
+ version 2.8pre2<br>
936
+ version 2.7.5
937
+ <ul>
938
+ <li>64bit �Ķ��� Mysql::Stmt#fetch �ǿ��ͤ���������������
939
+ </ul>
940
+
941
+ <dt>2007-12-26
942
+ <dd>
943
+ version 2.8pre1
944
+ <ul>
945
+ <li>Ruby 1.9.0 �б�
946
+ <li>Incompat: Mysql::Result#each_hash ������˥����̾ʸ�������������ΤǤϤʤ�����ͭ����褦�ˤ�����
947
+ <li>Incompat: �֥��å��Ĥ� Mysql#query �Ǽ�ưŪ�˥ޥ�����ơ��ȥ��ȥ⡼�ɤˤʤ�ʤ��褦�ˤ�����
948
+ </ul>
949
+
950
+ <dt>2007-08-22
951
+ <dd>
952
+ version 2.7.4
953
+ <ul>
954
+ <li>BUG: Mysql::Stmt#execute ������꡼�����Ƥ�����
955
+ </ul>
956
+
957
+ <dt>2006-12-20
958
+ <dd>
959
+ version 2.7.3
960
+ <ul>
961
+ <li>BUG: �֥��å��Ĥ� Mysql#query �����Ǹ�Υ����꤬���顼�ξ�����ߤ��Ƥ��ޤ���
962
+ </ul>
963
+
964
+ <dt>2006-10-28
965
+ <dd>
966
+ version 2.7.2
967
+ <ul>
968
+ <li>BUG: ��̤��֤��ʤ�������� Mysql::Stmt#result_metadata �� nil ���Ѥ����褦�ˤ��� (Thanks to Hidetoshi)
969
+ <li>BUG: Mysql#close �� mysql_errno �򸫤ʤ��褦���ѹ�
970
+ <li>BUG: �֥��å��Ĥ� Mysql#query ��ʣ�����ơ��ȥ��Ȼ��˥��顼��̵�뤷�Ƥ�����
971
+ <li>extconf.rb �� Visual C++ �б� (Thanks to Shugo Maeda)
972
+ <li>BIT�����б�
973
+ <li>Mysql::Field �� TYPE_BIT, TYPE_NEWDECIMAL �ɲ�
974
+ </ul>
975
+
976
+ <dt>2006-06-04
977
+ <dd>
978
+ version 2.7.1
979
+ <ul>
980
+ <li>free() �� xfree() ���ѹ���Windows �ǤΥ���å���β���Τ��ᡣ(Tobias Grimm �˴���)
981
+ </ul>
982
+
894
983
  <dt>2005-08-22
895
984
  <dd>
896
985
  version 2.7
@@ -1228,7 +1317,7 @@ st.close
1228
1317
  <address><a href="mailto:tommy@tmtm.org">TOMITA Masahiro</a></address>
1229
1318
  <!-- Created: Sun Aug 29 11:52:09 JST 2004 -->
1230
1319
  <!-- hhmts start -->
1231
- Last modified: Mon Aug 22 00:19:08 JST 2005
1320
+ Last modified: Sun Feb 1 17:41:18 JST 2009
1232
1321
  <!-- hhmts end -->
1233
1322
  </body>
1234
1323
  </html>
File without changes
@@ -0,0 +1,16 @@
1
+ # support multiple ruby version (fat binaries under windows)
2
+ begin
3
+ require 'mysql_api'
4
+ rescue LoadError
5
+ if RUBY_PLATFORM =~ /mingw|mswin/ then
6
+ RUBY_VERSION =~ /(\d+.\d+)/
7
+ require "#{$1}/mysql_api"
8
+ end
9
+ end
10
+
11
+ # define version string to be used internally for the Gem by Hoe.
12
+ class Mysql
13
+ module GemVersion
14
+ VERSION = '2.8.1'
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ require 'rubygems/package_task'
2
+ require 'hoe'
3
+
4
+ HOE = Hoe.spec 'mysql' do
5
+ self.rubyforge_name = 'mysql-win'
6
+ self.author = ['TOMITA Masahiro']
7
+ self.email = %w[tommy@tmtm.org]
8
+ self.need_tar = false
9
+ self.need_zip = false
10
+
11
+ spec_extras[:required_ruby_version] = Gem::Requirement.new('>= 1.8.6')
12
+
13
+ spec_extras[:extensions] = ["ext/mysql_api/extconf.rb"]
14
+
15
+ extra_dev_deps << ['rake-compiler', "~> 0.5"]
16
+ end
17
+
18
+ file "#{HOE.spec.name}.gemspec" => ['Rakefile', 'tasks/gem.rake'] do |t|
19
+ puts "Generating #{t.name}"
20
+ File.open(t.name, 'w') { |f| f.puts HOE.spec.to_yaml }
21
+ end
22
+
23
+ desc "Generate or update the standalone gemspec file for the project"
24
+ task :gemspec => ["#{HOE.spec.name}.gemspec"]
@@ -0,0 +1,30 @@
1
+ # use rake-compiler for building the extension
2
+ require 'rake/extensiontask'
3
+
4
+ MYSQL_VERSION = "5.0.83"
5
+ MYSQL_MIRROR = ENV['MYSQL_MIRROR'] || "http://mysql.localhost.net.ar"
6
+
7
+ Rake::ExtensionTask.new('mysql_api', HOE.spec) do |ext|
8
+ # reference where the vendored MySQL got extracted
9
+ mysql_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', "mysql-#{MYSQL_VERSION}-win32"))
10
+
11
+ # define target for extension (supporting fat binaries)
12
+ if RUBY_PLATFORM =~ /mingw/ then
13
+ ruby_ver = RUBY_VERSION.match(/(\d+\.\d+)/)[1]
14
+ ext.lib_dir = "lib/#{ruby_ver}"
15
+ end
16
+
17
+ # automatically add build options to avoid need of manual input
18
+ if RUBY_PLATFORM =~ /mswin|mingw/ then
19
+ ext.config_options << "--with-mysql-include=#{mysql_lib}/include"
20
+ ext.config_options << "--with-mysql-lib=#{mysql_lib}/lib/opt"
21
+ else
22
+ ext.cross_compile = true
23
+ ext.cross_platform = ['i386-mingw32', 'i386-mswin32']
24
+ ext.cross_config_options << "--with-mysql-include=#{mysql_lib}/include"
25
+ ext.cross_config_options << "--with-mysql-lib=#{mysql_lib}/lib/opt"
26
+ end
27
+ end
28
+
29
+ # ensure things are compiled prior testing
30
+ task :test => [:compile]
@@ -0,0 +1,41 @@
1
+ require 'rake/clean'
2
+ require 'rake/extensioncompiler'
3
+
4
+ # download mysql library and headers
5
+ directory "vendor"
6
+
7
+ file "vendor/mysql-noinstall-#{MYSQL_VERSION}-win32.zip" => ['vendor'] do |t|
8
+ base_version = MYSQL_VERSION.gsub(/\.[0-9]+$/, '')
9
+ url = "http://dev.mysql.com/get/Downloads/MySQL-#{base_version}/#{File.basename(t.name)}/from/#{MYSQL_MIRROR}/"
10
+ when_writing "downloading #{t.name}" do
11
+ cd File.dirname(t.name) do
12
+ sh "wget -c #{url} || curl -C - -O #{url}"
13
+ end
14
+ end
15
+ end
16
+
17
+ file "vendor/mysql-#{MYSQL_VERSION}-win32/include/mysql.h" => ["vendor/mysql-noinstall-#{MYSQL_VERSION}-win32.zip"] do |t|
18
+ full_file = File.expand_path(t.prerequisites.last)
19
+ when_writing "creating #{t.name}" do
20
+ cd "vendor" do
21
+ sh "unzip #{full_file} mysql-#{MYSQL_VERSION}-win32/bin/** mysql-#{MYSQL_VERSION}-win32/include/** mysql-#{MYSQL_VERSION}-win32/lib/**"
22
+ end
23
+ # update file timestamp to avoid Rake perform this extraction again.
24
+ touch t.name
25
+ end
26
+ end
27
+
28
+ # clobber expanded packages
29
+ CLOBBER.include("vendor/mysql-#{MYSQL_VERSION}-win32")
30
+
31
+ # vendor:mysql
32
+ task 'vendor:mysql' => ["vendor/mysql-#{MYSQL_VERSION}-win32/include/mysql.h"]
33
+
34
+ # hook into cross compilation vendored mysql dependency
35
+ if RUBY_PLATFORM =~ /mingw|mswin/ then
36
+ Rake::Task['compile'].prerequisites.unshift 'vendor:mysql'
37
+ else
38
+ if Rake::Task.tasks.map {|t| t.name }.include? 'cross'
39
+ Rake::Task['cross'].prerequisites.unshift 'vendor:mysql'
40
+ end
41
+ end
@@ -1,22 +1,36 @@
1
1
  #!/usr/local/bin/ruby
2
- # $Id: test.rb,v 1.16 2005/08/21 15:12:34 tommy Exp $
2
+ # $Id: test.rb 244 2009-02-01 08:43:39Z tommy $
3
3
 
4
4
  require "test/unit"
5
- require "./mysql.o"
5
+ require 'ostruct'
6
+ require 'mysql'
7
+
8
+ CONFIG = OpenStruct.new
9
+ CONFIG.host = ENV['MYSQL_HOST'] || 'localhost'
10
+ CONFIG.port = ENV['MYSQL_PORT'] || '3306'
11
+ CONFIG.user = ENV['MYSQL_USER'] || 'root'
12
+ CONFIG.pass = ENV['MYSQL_PASS'] || ''
13
+ CONFIG.sock = ENV['MYSQL_SOCK']
14
+ CONFIG.flag = ENV['MYSQL_FLAG']
15
+ CONFIG.database = ENV['MYSQL_DATABASE'] || 'test'
6
16
 
7
17
  class TC_Mysql < Test::Unit::TestCase
8
18
  def setup()
9
- @host, @user, @pass, db, port, sock, flag = ARGV
10
- @db = db || "test"
11
- @port = port.to_i
12
- @sock = sock.nil? || sock.empty? ? nil : sock
13
- @flag = flag.to_i
19
+ @host = CONFIG.host
20
+ @user = CONFIG.user
21
+ @pass = CONFIG.pass
22
+ @db = CONFIG.database
23
+
24
+ @port = CONFIG.port.to_i
25
+ @sock = CONFIG.sock
26
+ @flag = CONFIG.flag.to_i
14
27
  end
28
+
15
29
  def teardown()
16
30
  end
17
31
 
18
32
  def test_version()
19
- assert_equal(20700, Mysql::VERSION)
33
+ assert_equal(20801, Mysql::VERSION)
20
34
  end
21
35
 
22
36
  def test_init()
@@ -48,11 +62,11 @@ class TC_Mysql < Test::Unit::TestCase
48
62
  end
49
63
 
50
64
  def test_get_client_info()
51
- assert_match(/^\d.\d+.\d+(-.*)?$/, Mysql.get_client_info())
65
+ assert_match(/^\d.\d+.\d+[a-z]?(-.*)?$/, Mysql.get_client_info())
52
66
  end
53
67
 
54
68
  def test_client_info()
55
- assert_match(/^\d.\d+.\d+(-.*)?$/, Mysql.client_info())
69
+ assert_match(/^\d.\d+.\d+[a-z]?(-.*)?$/, Mysql.client_info())
56
70
  end
57
71
 
58
72
  def test_options()
@@ -95,15 +109,20 @@ end
95
109
 
96
110
  class TC_Mysql2 < Test::Unit::TestCase
97
111
  def setup()
98
- @host, @user, @pass, db, port, sock, flag = ARGV
99
- @db = db || "test"
100
- @port = port.to_i
101
- @sock = sock.nil? || sock.empty? ? nil : sock
102
- @flag = flag.to_i
112
+ @host = CONFIG.host
113
+ @user = CONFIG.user
114
+ @pass = CONFIG.pass
115
+ @db = CONFIG.database
116
+
117
+ @port = CONFIG.port.to_i
118
+ @sock = CONFIG.sock
119
+ @flag = CONFIG.flag.to_i
120
+
103
121
  @m = Mysql.new(@host, @user, @pass, @db, @port, @sock, @flag)
104
122
  end
123
+
105
124
  def teardown()
106
- @m.close
125
+ @m.close if @m
107
126
  end
108
127
 
109
128
  def test_affected_rows()
@@ -142,6 +161,41 @@ class TC_Mysql2 < Test::Unit::TestCase
142
161
  end
143
162
  end if Mysql.client_version >= 40100
144
163
 
164
+ def test_query_with_block()
165
+ if @m.server_version >= 40100 then
166
+ @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON)
167
+ expect = [["1","2","3"], ["4","5","6"]]
168
+ @m.query("select 1,2,3; select 4,5,6") {|res|
169
+ assert_equal(1, res.num_rows)
170
+ assert_equal(expect.shift, res.fetch_row)
171
+ }
172
+ assert(expect.empty?)
173
+ expect = [["1","2","3"], ["4","5","6"]]
174
+ assert_raises(Mysql::Error) {
175
+ @m.query("select 1,2,3; hoge; select 4,5,6") {|res|
176
+ assert_equal(1, res.num_rows)
177
+ assert_equal(expect.shift, res.fetch_row)
178
+ }
179
+ }
180
+ assert_equal(1, expect.size)
181
+ expect = [["1","2","3"], ["4","5","6"]]
182
+ assert_raises(Mysql::Error) {
183
+ @m.query("select 1,2,3; select 4,5,6; hoge") {|res|
184
+ assert_equal(1, res.num_rows)
185
+ assert_equal(expect.shift, res.fetch_row)
186
+ }
187
+ }
188
+ assert(expect.empty?)
189
+ end
190
+ end
191
+
192
+ def test_query_with_block_single()
193
+ @m.query("select 1,2,3") {|res|
194
+ assert_equal(1, res.num_rows)
195
+ assert_equal(["1","2","3"], res.fetch_row)
196
+ }
197
+ end
198
+
145
199
  def test_set_server_option()
146
200
  if @m.server_version >= 40101 then
147
201
  assert_equal(@m, @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON))
@@ -151,11 +205,15 @@ class TC_Mysql2 < Test::Unit::TestCase
151
205
 
152
206
  def test_sqlstate()
153
207
  if @m.server_version >= 40100 then
154
- assert_equal("00000", @m.sqlstate)
208
+ if RUBY_PLATFORM !~ /mingw|mswin/ then
209
+ assert_equal("00000", @m.sqlstate)
210
+ else
211
+ assert_equal("HY000", @m.sqlstate)
212
+ end
155
213
  assert_raises(Mysql::Error){@m.query("hogehoge")}
156
214
  assert_equal("42000", @m.sqlstate)
157
215
  end
158
- end if Mysql.client_version >= 40100
216
+ end
159
217
 
160
218
  def test_query_with_result()
161
219
  assert_equal(true, @m.query_with_result)
@@ -176,16 +234,21 @@ end
176
234
 
177
235
  class TC_MysqlRes < Test::Unit::TestCase
178
236
  def setup()
179
- @host, @user, @pass, db, port, sock, flag = ARGV
180
- @db = db || "test"
181
- @port = port.to_i
182
- @sock = sock.nil? || sock.empty? ? nil : sock
183
- @flag = flag.to_i
237
+ @host = CONFIG.host
238
+ @user = CONFIG.user
239
+ @pass = CONFIG.pass
240
+ @db = CONFIG.database
241
+
242
+ @port = CONFIG.port.to_i
243
+ @sock = CONFIG.sock
244
+ @flag = CONFIG.flag.to_i
245
+
184
246
  @m = Mysql.new(@host, @user, @pass, @db, @port, @sock, @flag)
185
247
  @m.query("create temporary table t (id int, str char(10), primary key (id))")
186
248
  @m.query("insert into t values (1, 'abc'), (2, 'defg'), (3, 'hi'), (4, null)")
187
249
  @res = @m.query("select * from t")
188
250
  end
251
+
189
252
  def teardown()
190
253
  @res.free
191
254
  @m.close
@@ -244,7 +307,7 @@ class TC_MysqlRes < Test::Unit::TestCase
244
307
  @res.data_seek(1)
245
308
  assert_equal(["2","defg"], @res.fetch_row)
246
309
  end
247
-
310
+
248
311
  def test_row_seek()
249
312
  assert_equal(["1","abc"], @res.fetch_row)
250
313
  pos = @res.row_tell
@@ -376,13 +439,18 @@ end
376
439
 
377
440
  class TC_MysqlStmt < Test::Unit::TestCase
378
441
  def setup()
379
- @host, @user, @pass, db, port, sock, flag = ARGV
380
- @db = db || "test"
381
- @port = port.to_i
382
- @sock = sock.nil? || sock.empty? ? nil : sock
383
- @flag = flag.to_i
442
+ @host = CONFIG.host
443
+ @user = CONFIG.user
444
+ @pass = CONFIG.pass
445
+ @db = CONFIG.database
446
+
447
+ @port = CONFIG.port.to_i
448
+ @sock = CONFIG.sock
449
+ @flag = CONFIG.flag.to_i
450
+
384
451
  @m = Mysql.new(@host, @user, @pass, @db, @port, @sock, @flag)
385
452
  end
453
+
386
454
  def teardown()
387
455
  end
388
456
 
@@ -406,14 +474,19 @@ end if Mysql.client_version >= 40100
406
474
 
407
475
  class TC_MysqlStmt2 < Test::Unit::TestCase
408
476
  def setup()
409
- @host, @user, @pass, db, port, sock, flag = ARGV
410
- @db = db || "test"
411
- @port = port.to_i
412
- @sock = sock.nil? || sock.empty? ? nil : sock
413
- @flag = flag.to_i
477
+ @host = CONFIG.host
478
+ @user = CONFIG.user
479
+ @pass = CONFIG.pass
480
+ @db = CONFIG.database
481
+
482
+ @port = CONFIG.port.to_i
483
+ @sock = CONFIG.sock
484
+ @flag = CONFIG.flag.to_i
485
+
414
486
  @m = Mysql.new(@host, @user, @pass, @db, @port, @sock, @flag)
415
487
  @s = @m.stmt_init()
416
488
  end
489
+
417
490
  def teardown()
418
491
  @s.close
419
492
  @m.close
@@ -457,7 +530,7 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
457
530
  end
458
531
  =end
459
532
 
460
- def test_bind_result_nil()
533
+ def test_bind_result_nil()
461
534
  if @m.server_version >= 40100 then
462
535
  @m.query("create temporary table t (i int, c char(10), d double, t datetime)")
463
536
  @m.query("insert into t values (123, '9abcdefg', 1.2345, 20050802235011)")
@@ -510,7 +583,7 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
510
583
  @s.execute
511
584
  a = @s.fetch
512
585
  if Mysql.client_version < 50000 then
513
- assert_equal([123, 9, 1, 2005], a)
586
+ assert_equal([123, 9, 1, 2005], a)
514
587
  else
515
588
  assert_equal([123, 9, 1, 20050802235011.0], a)
516
589
  end
@@ -654,6 +727,17 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
654
727
  end
655
728
  end
656
729
 
730
+ def test_execute5()
731
+ if @m.server_version >= 40100 then
732
+ [30, 31, 32, 62, 63].each do |i|
733
+ v, = @m.prepare("select cast(? as signed)").execute(2**i-1).fetch
734
+ assert_equal(2**i-1, v)
735
+ v, = @m.prepare("select cast(? as signed)").execute(-(2**i)).fetch
736
+ assert_equal(-(2**i), v)
737
+ end
738
+ end
739
+ end
740
+
657
741
  def test_fetch()
658
742
  if @m.server_version >= 40100 then
659
743
  @s.prepare("select 123, 'abc', null")
@@ -662,6 +746,31 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
662
746
  end
663
747
  end
664
748
 
749
+ def test_fetch_bit()
750
+ if @m.client_version >= 50003 and @m.server_version >= 50003 then
751
+ @m.query("create temporary table t (i bit(8))")
752
+ @m.query("insert into t values (0),(-1),(127),(-128),(255),(-255),(256)")
753
+ @s.prepare("select i from t")
754
+ @s.execute
755
+ assert_equal(["\x00"], @s.fetch)
756
+ assert_equal(["\xff"], @s.fetch)
757
+ assert_equal(["\x7f"], @s.fetch)
758
+ assert_equal(["\xff"], @s.fetch)
759
+ assert_equal(["\xff"], @s.fetch)
760
+ assert_equal(["\xff"], @s.fetch)
761
+ assert_equal(["\xff"], @s.fetch)
762
+ @m.query("create temporary table t2 (i bit(64))")
763
+ @m.query("insert into t2 values (0),(-1),(4294967296),(18446744073709551615),(18446744073709551616)")
764
+ @s.prepare("select i from t2")
765
+ @s.execute
766
+ assert_equal(["\x00\x00\x00\x00\x00\x00\x00\x00"], @s.fetch)
767
+ assert_equal(["\xff\xff\xff\xff\xff\xff\xff\xff"], @s.fetch)
768
+ assert_equal(["\x00\x00\x00\x01\x00\x00\x00\x00"], @s.fetch)
769
+ assert_equal(["\xff\xff\xff\xff\xff\xff\xff\xff"], @s.fetch)
770
+ assert_equal(["\xff\xff\xff\xff\xff\xff\xff\xff"], @s.fetch)
771
+ end
772
+ end
773
+
665
774
  def test_fetch_tinyint()
666
775
  if @m.server_version >= 40100 then
667
776
  @m.query("create temporary table t (i tinyint)")
@@ -796,7 +905,11 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
796
905
  assert_equal([-1], @s.fetch)
797
906
  assert_equal([9223372036854775807], @s.fetch)
798
907
  assert_equal([-9223372036854775808], @s.fetch)
799
- assert_equal([-1], @s.fetch) # MySQL problem
908
+ if @m.server_version >= 50000 then
909
+ assert_equal([9223372036854775807], @s.fetch)
910
+ else
911
+ assert_equal([-1], @s.fetch) # MySQL problem
912
+ end
800
913
  assert_equal([-9223372036854775808], @s.fetch)
801
914
  assert_equal([9223372036854775807], @s.fetch)
802
915
  end
@@ -809,16 +922,20 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
809
922
  @s.prepare("select i from t")
810
923
  @s.execute
811
924
  assert_equal([0], @s.fetch)
812
- assert_equal([-1], @s.fetch) # MySQL & MySQL/Ruby problem
813
- assert_equal([9223372036854775807], @s.fetch)
814
- if @m.server_version < 50000 then
815
- assert_equal([-9223372036854775808], @s.fetch) # MySQL problem
925
+ if @m.server_version >= 50000 then
926
+ assert_equal([0], @s.fetch)
816
927
  else
928
+ assert_equal([18446744073709551615], @s.fetch) # MySQL problem
929
+ end
930
+ assert_equal([9223372036854775807], @s.fetch)
931
+ if @m.server_version >= 50000 then
817
932
  assert_equal([0], @s.fetch)
933
+ else
934
+ assert_equal([9223372036854775808], @s.fetch) # MySQL problem
818
935
  end
819
- assert_equal([-1], @s.fetch) # MySQL/Ruby problem
936
+ assert_equal([18446744073709551615], @s.fetch)
820
937
  assert_equal([0], @s.fetch)
821
- assert_equal([-1], @s.fetch) # MySQL/Ruby problem
938
+ assert_equal([18446744073709551615], @s.fetch)
822
939
  end
823
940
  end
824
941
 
@@ -857,12 +974,10 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
857
974
  @s.prepare("select i from t")
858
975
  @s.execute
859
976
  assert_equal([0], @s.fetch)
860
- assert_equal(-Float::MAX, @s.fetch[0])
861
- if Mysql.client_version <= 40109 then # higher version has bug
862
- assert_equal(-Float::MIN, @s.fetch[0])
863
- assert_equal(Float::MIN, @s.fetch[0])
864
- assert_equal(Float::MAX, @s.fetch[0])
865
- end
977
+ assert_in_delta(-Float::MAX, @s.fetch[0], Float::EPSILON)
978
+ assert_in_delta(-Float::MIN, @s.fetch[0], Float::EPSILON)
979
+ assert_in_delta(Float::MIN, @s.fetch[0], Float::EPSILON)
980
+ assert_in_delta(Float::MAX, @s.fetch[0], Float::EPSILON)
866
981
  end
867
982
  end
868
983
 
@@ -874,11 +989,9 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
874
989
  @s.execute
875
990
  assert_equal([0], @s.fetch)
876
991
  assert_equal([0], @s.fetch)
877
- if Mysql.client_version <= 40109 then # higher version has bug
878
- assert_equal([0], @s.fetch)
879
- assert_equal(Float::MIN, @s.fetch[0])
880
- assert_equal(Float::MAX, @s.fetch[0])
881
- end
992
+ assert_equal([0], @s.fetch)
993
+ assert_in_delta(Float::MIN, @s.fetch[0], Float::EPSILON)
994
+ assert_in_delta(Float::MAX, @s.fetch[0], Float::EPSILON)
882
995
  end
883
996
  end
884
997
 
@@ -943,11 +1056,11 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
943
1056
  def test_fetch_timestamp()
944
1057
  if @m.server_version >= 40100 then
945
1058
  @m.query("create temporary table t (i timestamp)")
946
- @m.query("insert into t values ('1970-01-01 12:00:00'),('2037-12-31 23:59:59')")
1059
+ @m.query("insert into t values ('1970-01-02 00:00:00'),('2037-12-30 23:59:59')")
947
1060
  @s.prepare("select i from t")
948
1061
  @s.execute
949
- assert_equal([Mysql::Time.new(1970,1,1,12,0,0)], @s.fetch)
950
- assert_equal([Mysql::Time.new(2037,12,31,23,59,59)], @s.fetch)
1062
+ assert_equal([Mysql::Time.new(1970,1,2,0,0,0)], @s.fetch)
1063
+ assert_equal([Mysql::Time.new(2037,12,30,23,59,59)], @s.fetch)
951
1064
  end
952
1065
  end
953
1066
 
@@ -1006,7 +1119,11 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
1006
1119
  @s.prepare("select i from t")
1007
1120
  @s.execute
1008
1121
  assert_equal([nil], @s.fetch)
1009
- assert_equal(["abc"], @s.fetch)
1122
+ if @m.server_version >= 50000 then
1123
+ assert_equal(["abc\0\0\0\0\0\0\0"], @s.fetch)
1124
+ else
1125
+ assert_equal(["abc"], @s.fetch)
1126
+ end
1010
1127
  end
1011
1128
  end
1012
1129
 
@@ -1246,6 +1363,14 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
1246
1363
  end
1247
1364
  end
1248
1365
 
1366
+ def test_result_metadata_nodata()
1367
+ if @m.server_version >= 40100 then
1368
+ @m.query("create temporary table t (i int)")
1369
+ @s.prepare("insert into t values (1)")
1370
+ assert_equal(nil, @s.result_metadata())
1371
+ end
1372
+ end
1373
+
1249
1374
  def test_row_seek_tell()
1250
1375
  if @m.server_version >= 40100 then
1251
1376
  @m.query("create temporary table t (i int)")
@@ -1277,7 +1402,11 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
1277
1402
  def test_sqlstate()
1278
1403
  if @m.server_version >= 40100 then
1279
1404
  @s.prepare("select 1")
1280
- assert_equal("", @s.sqlstate)
1405
+ if @m.client_version >= 50000 then
1406
+ assert_equal("00000", @s.sqlstate)
1407
+ else
1408
+ assert_equal("", @s.sqlstate)
1409
+ end
1281
1410
  assert_raises(Mysql::Error){@s.prepare("hogehoge")}
1282
1411
  assert_equal("42000", @s.sqlstate)
1283
1412
  end
@@ -1288,7 +1417,7 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
1288
1417
  @s.store_result()
1289
1418
  end
1290
1419
  =end
1291
-
1420
+
1292
1421
  end if Mysql.client_version >= 40100
1293
1422
 
1294
1423
  class TC_MysqlTime < Test::Unit::TestCase