tiny_tds 3.0.0-x64-mingw32 → 3.2.0-x64-mingw32

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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +194 -74
  3. data/CHANGELOG.md +12 -0
  4. data/Gemfile +1 -1
  5. data/README.md +59 -50
  6. data/Rakefile +46 -37
  7. data/VERSION +1 -1
  8. data/ext/tiny_tds/extconf.rb +169 -70
  9. data/ext/tiny_tds/extconsts.rb +3 -4
  10. data/lib/tiny_tds/2.7/tiny_tds.so +0 -0
  11. data/lib/tiny_tds/3.0/tiny_tds.so +0 -0
  12. data/lib/tiny_tds/bin.rb +12 -26
  13. data/lib/tiny_tds/client.rb +38 -42
  14. data/lib/tiny_tds/error.rb +0 -2
  15. data/lib/tiny_tds/gem.rb +5 -9
  16. data/lib/tiny_tds/result.rb +0 -2
  17. data/lib/tiny_tds/version.rb +1 -1
  18. data/lib/tiny_tds.rb +28 -47
  19. data/ports/x64-mingw32/{freetds/1.4.23/bin → bin}/defncopy.exe +0 -0
  20. data/ports/x64-mingw32/bin/libsybdb-5.dll +0 -0
  21. data/ports/x64-mingw32/bin/tsql.exe +0 -0
  22. data/tasks/native_gem.rake +11 -18
  23. data/tasks/package.rake +1 -3
  24. data/tasks/ports.rake +7 -91
  25. data/tasks/test.rake +3 -5
  26. data/test/bin/install-freetds.sh +2 -4
  27. data/test/bin/restore-from-native-gem.ps1 +10 -0
  28. data/test/client_test.rb +106 -112
  29. data/test/gem_test.rb +32 -108
  30. data/test/result_test.rb +208 -221
  31. data/test/schema_test.rb +177 -181
  32. data/test/test_helper.rb +59 -64
  33. data/test/thread_test.rb +22 -31
  34. data/tiny_tds.gemspec +28 -29
  35. metadata +27 -43
  36. data/ports/x64-mingw32/freetds/1.4.23/bin/bsqldb.exe +0 -0
  37. data/ports/x64-mingw32/freetds/1.4.23/bin/datacopy.exe +0 -0
  38. data/ports/x64-mingw32/freetds/1.4.23/bin/freebcp.exe +0 -0
  39. data/ports/x64-mingw32/freetds/1.4.23/bin/libct-4.dll +0 -0
  40. data/ports/x64-mingw32/freetds/1.4.23/bin/libsybdb-5.dll +0 -0
  41. data/ports/x64-mingw32/freetds/1.4.23/bin/osql +0 -393
  42. data/ports/x64-mingw32/freetds/1.4.23/bin/tdspool.exe +0 -0
  43. data/ports/x64-mingw32/freetds/1.4.23/bin/tsql.exe +0 -0
  44. data/ports/x64-mingw32/freetds/1.4.23/lib/libct.dll.a +0 -0
  45. data/ports/x64-mingw32/freetds/1.4.23/lib/libct.la +0 -41
  46. data/ports/x64-mingw32/freetds/1.4.23/lib/libsybdb.dll.a +0 -0
  47. data/ports/x64-mingw32/freetds/1.4.23/lib/libsybdb.la +0 -41
  48. data/ports/x64-mingw32/libiconv/1.17/bin/iconv.exe +0 -0
  49. data/ports/x64-mingw32/libiconv/1.17/bin/libcharset-1.dll +0 -0
  50. data/ports/x64-mingw32/libiconv/1.17/bin/libiconv-2.dll +0 -0
  51. data/ports/x64-mingw32/libiconv/1.17/lib/libcharset.dll.a +0 -0
  52. data/ports/x64-mingw32/libiconv/1.17/lib/libcharset.la +0 -41
  53. data/ports/x64-mingw32/libiconv/1.17/lib/libiconv.dll.a +0 -0
  54. data/ports/x64-mingw32/libiconv/1.17/lib/libiconv.la +0 -41
  55. data/ports/x64-mingw32/openssl/3.4.0/bin/c_rehash +0 -252
  56. data/ports/x64-mingw32/openssl/3.4.0/bin/libcrypto-3-x64.dll +0 -0
  57. data/ports/x64-mingw32/openssl/3.4.0/bin/libssl-3-x64.dll +0 -0
  58. data/ports/x64-mingw32/openssl/3.4.0/bin/openssl.exe +0 -0
  59. data/tasks/ports/freetds.rb +0 -32
  60. data/tasks/ports/libiconv.rb +0 -26
  61. data/tasks/ports/openssl.rb +0 -62
  62. data/tasks/ports/recipe.rb +0 -64
  63. data/test/benchmark/query.rb +0 -77
  64. data/test/benchmark/query_odbc.rb +0 -106
  65. data/test/benchmark/query_tinytds.rb +0 -126
data/lib/tiny_tds/gem.rb CHANGED
@@ -1,26 +1,22 @@
1
- require 'rbconfig'
1
+ require "rbconfig"
2
2
 
3
3
  module TinyTds
4
4
  module Gem
5
5
  class << self
6
6
  def root_path
7
- File.expand_path '../../..', __FILE__
7
+ File.expand_path "../../..", __FILE__
8
8
  end
9
9
 
10
10
  def ports_root_path
11
- File.join(root_path,'ports')
11
+ File.join(root_path, "ports")
12
12
  end
13
13
 
14
14
  def ports_bin_paths
15
- Dir.glob(File.join(ports_root_path,ports_host,'**','bin'))
15
+ Dir.glob(File.join(ports_root_path, "**", "bin"))
16
16
  end
17
17
 
18
18
  def ports_lib_paths
19
- Dir.glob(File.join(ports_root_path,ports_host,'**','lib'))
20
- end
21
-
22
- def ports_host
23
- RbConfig::CONFIG["arch"]
19
+ Dir.glob(File.join(ports_root_path, "**", "lib"))
24
20
  end
25
21
  end
26
22
  end
@@ -1,7 +1,5 @@
1
1
  module TinyTds
2
2
  class Result
3
-
4
3
  include Enumerable
5
-
6
4
  end
7
5
  end
@@ -1,3 +1,3 @@
1
1
  module TinyTds
2
- VERSION = File.read(File.expand_path('../../../VERSION', __FILE__)).chomp
2
+ VERSION = File.read(File.expand_path("../../../VERSION", __FILE__)).chomp
3
3
  end
data/lib/tiny_tds.rb CHANGED
@@ -1,61 +1,42 @@
1
- # encoding: UTF-8
2
- require 'date'
3
- require 'bigdecimal'
4
- require 'rational'
1
+ require "date"
2
+ require "bigdecimal"
5
3
 
6
- require 'tiny_tds/version'
7
- require 'tiny_tds/error'
8
- require 'tiny_tds/client'
9
- require 'tiny_tds/result'
10
- require 'tiny_tds/gem'
4
+ require "tiny_tds/version"
5
+ require "tiny_tds/error"
6
+ require "tiny_tds/client"
7
+ require "tiny_tds/result"
8
+ require "tiny_tds/gem"
11
9
 
12
- # Support multiple ruby versions, fat binaries under Windows.
13
- if RUBY_PLATFORM =~ /mingw|mswin/ && RUBY_VERSION =~ /(\d+.\d+)/
14
- ver = Regexp.last_match(1)
10
+ module TinyTds
11
+ # Is this file part of a fat binary gem with bundled freetds?
12
+ # This path must be enabled by add_dll_directory on Windows.
13
+ gplat = ::Gem::Platform.local
14
+ FREETDS_LIB_PATH = Dir[File.expand_path("../ports/#{gplat.cpu}-#{gplat.os}*/lib", __dir__)].first
15
15
 
16
16
  add_dll_path = proc do |path, &block|
17
- begin
18
- require 'ruby_installer/runtime'
19
- RubyInstaller::Runtime.add_dll_directory(path, &block)
20
- rescue LoadError
21
- old_path = ENV['PATH']
22
- ENV['PATH'] = "#{path};#{old_path}"
17
+ if RUBY_PLATFORM =~ /(mswin|mingw)/i && path
23
18
  begin
19
+ require "ruby_installer/runtime"
20
+ RubyInstaller::Runtime.add_dll_directory(path, &block)
21
+ rescue LoadError
22
+ old_path = ENV["PATH"]
23
+ ENV["PATH"] = "#{path};#{old_path}"
24
24
  block.call
25
- ensure
26
- ENV['PATH'] = old_path
27
- end
28
- end
29
- end
30
-
31
- add_dll_paths = proc do |paths, &block|
32
- if path=paths.shift
33
- add_dll_path.call(path) do
34
- add_dll_paths.call(paths, &block)
25
+ ENV["PATH"] = old_path
35
26
  end
36
27
  else
28
+ # libsybdb is found by a relative rpath in the cross compiled extension dll
29
+ # or by the system library loader
37
30
  block.call
38
31
  end
39
32
  end
40
33
 
41
- # Temporary add bin directories for DLL search, so that freetds DLLs can be found.
42
- add_dll_paths.call( TinyTds::Gem.ports_bin_paths ) do
43
- begin
44
- require "tiny_tds/#{ver}/tiny_tds"
45
- rescue LoadError
46
- require 'tiny_tds/tiny_tds'
47
- end
48
- end
49
- else
50
- # Load dependent shared libraries into the process, so that they are already present,
51
- # when tiny_tds.so is loaded. This ensures, that shared libraries are loaded even when
52
- # the path is different between build and run time (e.g. Heroku).
53
- ports_libs = File.join(TinyTds::Gem.ports_root_path,
54
- "#{RbConfig::CONFIG['host']}/lib/*.so")
55
- Dir[ports_libs].each do |lib|
56
- require 'fiddle'
57
- Fiddle.dlopen(lib)
34
+ add_dll_path.call(FREETDS_LIB_PATH) do
35
+ # Try the <major>.<minor> subdirectory for fat binary gems
36
+ major_minor = RUBY_VERSION[/^(\d+\.\d+)/] or
37
+ raise "Oops, can't extract the major/minor version from #{RUBY_VERSION.dump}"
38
+ require "tiny_tds/#{major_minor}/tiny_tds"
39
+ rescue LoadError
40
+ require "tiny_tds/tiny_tds"
58
41
  end
59
-
60
- require 'tiny_tds/tiny_tds'
61
42
  end
Binary file
@@ -1,23 +1,16 @@
1
- # encoding: UTF-8
1
+ CrossLibraries.each do |xlib|
2
+ platform = xlib.platform
2
3
 
3
- desc 'Build the native binary gems using rake-compiler-dock'
4
- task 'gem:native' => ['ports:cross'] do
5
- require 'rake_compiler_dock'
4
+ desc "Build fat binary gem for platform #{platform}"
5
+ task "gem:native:#{platform}" do
6
+ require "rake_compiler_dock"
6
7
 
7
- # make sure to install our bundle
8
- sh "bundle package --all" # Avoid repeated downloads of gems by using gem files from the host.
9
-
10
- GEM_PLATFORM_HOSTS.each do |plat, meta|
11
- RakeCompilerDock.sh "bundle --local && RUBY_CC_VERSION=#{meta[:ruby_versions]} rake native:#{plat} gem", platform: plat
8
+ RakeCompilerDock.sh <<-EOT, platform: platform
9
+ bundle install &&
10
+ rake native:#{platform} pkg/#{SPEC.full_name}-#{platform}.gem MAKEOPTS=-j`nproc` RUBY_CC_VERSION=#{RakeCompilerDock.set_ruby_cc_version("~> 2.7", "~> 3.0")} MAKEFLAGS="V=1"
11
+ EOT
12
12
  end
13
- end
14
-
15
- # assumes you are in a container provided by Rake compiler
16
- # if not, use the task above
17
- task 'gem:for_platform', [:gem_platform] do |_task, args|
18
- args.with_defaults(gem_platform: RbConfig::CONFIG["arch"])
19
13
 
20
- sh "bundle install"
21
- Rake::Task["ports:compile"].invoke(GEM_PLATFORM_HOSTS[args.gem_platform][:host], args.gem_platform)
22
- sh "RUBY_CC_VERSION=#{GEM_PLATFORM_HOSTS[args.gem_platform][:ruby_versions]} rake native:#{args.gem_platform} gem"
14
+ desc "Build the native binary gems"
15
+ multitask "gem:native" => "gem:native:#{platform}"
23
16
  end
data/tasks/package.rake CHANGED
@@ -1,8 +1,6 @@
1
- # encoding: UTF-8
2
- require 'rubygems/package_task'
1
+ require "rubygems/package_task"
3
2
 
4
3
  Gem::PackageTask.new(SPEC) do |pkg|
5
4
  pkg.need_tar = false
6
5
  pkg.need_zip = false
7
6
  end
8
-
data/tasks/ports.rake CHANGED
@@ -1,108 +1,24 @@
1
- # encoding: UTF-8
2
- require 'mini_portile2'
3
- require 'fileutils'
4
- require_relative 'ports/libiconv'
5
- require_relative 'ports/openssl'
6
- require_relative 'ports/freetds'
7
- require_relative '../ext/tiny_tds/extconsts'
1
+ require_relative "../ext/tiny_tds/extconsts"
8
2
 
9
3
  namespace :ports do
10
4
  libraries_to_compile = {
11
- openssl: Ports::Openssl.new(OPENSSL_VERSION),
12
- libiconv: Ports::Libiconv.new(ICONV_VERSION),
13
- freetds: Ports::Freetds.new(FREETDS_VERSION)
5
+ openssl: OPENSSL_VERSION,
6
+ libiconv: ICONV_VERSION,
7
+ freetds: FREETDS_VERSION
14
8
  }
15
9
 
16
- directory "ports"
17
- CLEAN.include "ports/*mingw*"
18
- CLEAN.include "ports/*.installed"
19
-
20
- task :openssl, [:host, :gem_platform] do |_task, args|
21
- args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
22
-
23
- libraries_to_compile[:openssl].files = [OPENSSL_SOURCE_URI]
24
- libraries_to_compile[:openssl].host = args.host
25
- libraries_to_compile[:openssl].gem_platform = args.gem_platform
26
-
27
- libraries_to_compile[:openssl].cook
28
- libraries_to_compile[:openssl].activate
29
- end
30
-
31
- task :libiconv, [:host, :gem_platform] do |_task, args|
32
- args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
33
-
34
- libraries_to_compile[:libiconv].files = [ICONV_SOURCE_URI]
35
- libraries_to_compile[:libiconv].host = args.host
36
- libraries_to_compile[:libiconv].gem_platform = args.gem_platform
37
- libraries_to_compile[:libiconv].cook
38
- libraries_to_compile[:libiconv].activate
39
- end
40
-
41
- task :freetds, [:host, :gem_platform] do |_task, args|
42
- args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
43
-
44
- libraries_to_compile[:freetds].files = [FREETDS_SOURCE_URI]
45
- libraries_to_compile[:freetds].host = args.host
46
- libraries_to_compile[:freetds].gem_platform = args.gem_platform
47
-
48
- if libraries_to_compile[:openssl]
49
- # freetds doesn't have an option that will provide an rpath
50
- # so we do it manually
51
- ENV['OPENSSL_CFLAGS'] = "-Wl,-rpath -Wl,#{libraries_to_compile[:openssl].path}/lib64"
52
- # Add the pkgconfig file with MSYS2'ish path, to prefer our ports build
53
- # over MSYS2 system OpenSSL.
54
- ENV['PKG_CONFIG_PATH'] = "#{libraries_to_compile[:openssl].path.gsub(/^(\w):/i) { "/" + $1.downcase }}/lib64/pkgconfig:#{ENV['PKG_CONFIG_PATH']}"
55
- libraries_to_compile[:freetds].configure_options << "--with-openssl=#{libraries_to_compile[:openssl].path}"
56
- end
57
-
58
- if libraries_to_compile[:libiconv]
59
- libraries_to_compile[:freetds].configure_options << "--with-libiconv-prefix=#{libraries_to_compile[:libiconv].path}"
60
- end
61
-
62
- libraries_to_compile[:freetds].cook
63
- libraries_to_compile[:freetds].activate
64
- end
65
-
66
- task :compile, [:host, :gem_platform] do |_task, args|
67
- args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
68
-
69
- puts "Compiling ports for #{args.host} (Ruby platform #{args.gem_platform}) ..."
70
-
71
- libraries_to_compile.keys.each do |lib|
72
- Rake::Task["ports:#{lib}"].invoke(args.host, args.gem_platform)
73
- end
74
- end
75
-
76
- desc 'Build the ports windows binaries via rake-compiler-dock'
77
- task 'cross' do
78
- require 'rake_compiler_dock'
79
-
80
- # build the ports for all our cross compile hosts
81
- GEM_PLATFORM_HOSTS.each do |gem_platform, meta|
82
- # make sure to install our bundle
83
- build = ['bundle']
84
- build << "RUBY_CC_VERSION=#{meta[:ruby_versions]} rake ports:compile[#{meta[:host]},#{gem_platform}] MAKE='make -j`nproc`'"
85
- RakeCompilerDock.sh build.join(' && '), platform: gem_platform
86
- end
87
- end
88
-
89
10
  desc "Notes the actual versions for the compiled ports into a file"
90
11
  task "version_file", [:gem_platform] do |_task, args|
91
12
  args.with_defaults(gem_platform: RbConfig::CONFIG["arch"])
92
13
 
93
14
  ports_version = {}
94
15
 
95
- libraries_to_compile.each do |library, library_recipe|
96
- ports_version[library] = library_recipe.version
16
+ libraries_to_compile.each do |library, version|
17
+ ports_version[library] = version
97
18
  end
98
19
 
99
20
  ports_version[:platform] = args.gem_platform
100
21
 
101
- File.open(".ports_versions", "w") do |f|
102
- f.write ports_version
103
- end
22
+ File.write(".ports_versions", ports_version)
104
23
  end
105
24
  end
106
-
107
- desc 'Build ports and activate libraries for the current architecture.'
108
- task :ports => ['ports:compile']
data/tasks/test.rake CHANGED
@@ -1,9 +1,7 @@
1
- # encoding: UTF-8
2
- require 'rake/testtask'
1
+ require "rake/testtask"
3
2
 
4
3
  Rake::TestTask.new do |t|
5
- t.libs << 'test'
6
- t.test_files = FileList['test/**/*_test.rb']
4
+ t.libs << "test"
5
+ t.test_files = FileList["test/**/*_test.rb"]
7
6
  t.verbose = true
8
7
  end
9
-
@@ -10,11 +10,9 @@ fi
10
10
  wget http://www.freetds.org/files/stable/freetds-$FREETDS_VERSION.tar.gz
11
11
  tar -xzf freetds-$FREETDS_VERSION.tar.gz
12
12
  cd freetds-$FREETDS_VERSION
13
- ./configure --prefix=/opt/local \
14
- --with-openssl=/opt/local \
15
- --with-tdsver=7.3
13
+ ./configure
16
14
  make
17
- make install
15
+ sudo make install
18
16
  cd ..
19
17
  rm -rf freetds-$FREETDS_VERSION
20
18
  rm freetds-$FREETDS_VERSION.tar.gz
@@ -0,0 +1,10 @@
1
+ $gemVersion = (Get-Content VERSION).Trim()
2
+ $gemToUnpack = "./tiny_tds-$gemVersion-$env:RUBY_ARCHITECTURE.gem"
3
+
4
+ Write-Host "Looking to unpack $gemToUnpack"
5
+ gem unpack --target ./tmp "$gemToUnpack"
6
+
7
+ # Restore precompiled code
8
+ $source = (Resolve-Path ".\tmp\tiny_tds-$gemVersion-$env:RUBY_ARCHITECTURE\lib\tiny_tds").Path
9
+ $destination = (Resolve-Path ".\lib\tiny_tds").Path
10
+ Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)}