tiny_tds 3.2.0-aarch64-linux-gnu

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 (71) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +20 -0
  3. data/.gitattributes +1 -0
  4. data/.github/workflows/ci.yml +590 -0
  5. data/.gitignore +22 -0
  6. data/.rubocop.yml +31 -0
  7. data/CHANGELOG.md +305 -0
  8. data/CODE_OF_CONDUCT.md +31 -0
  9. data/Gemfile +2 -0
  10. data/ISSUE_TEMPLATE.md +38 -0
  11. data/MIT-LICENSE +23 -0
  12. data/README.md +493 -0
  13. data/Rakefile +67 -0
  14. data/VERSION +1 -0
  15. data/bin/defncopy-ttds +3 -0
  16. data/bin/tsql-ttds +3 -0
  17. data/docker-compose.yml +34 -0
  18. data/exe/.keep +0 -0
  19. data/ext/tiny_tds/client.c +492 -0
  20. data/ext/tiny_tds/client.h +53 -0
  21. data/ext/tiny_tds/extconf.rb +190 -0
  22. data/ext/tiny_tds/extconsts.rb +8 -0
  23. data/ext/tiny_tds/result.c +626 -0
  24. data/ext/tiny_tds/result.h +32 -0
  25. data/ext/tiny_tds/tiny_tds_ext.c +15 -0
  26. data/ext/tiny_tds/tiny_tds_ext.h +17 -0
  27. data/lib/tiny_tds/2.7/tiny_tds.so +0 -0
  28. data/lib/tiny_tds/3.0/tiny_tds.so +0 -0
  29. data/lib/tiny_tds/3.1/tiny_tds.so +0 -0
  30. data/lib/tiny_tds/3.2/tiny_tds.so +0 -0
  31. data/lib/tiny_tds/3.3/tiny_tds.so +0 -0
  32. data/lib/tiny_tds/3.4/tiny_tds.so +0 -0
  33. data/lib/tiny_tds/bin.rb +90 -0
  34. data/lib/tiny_tds/client.rb +132 -0
  35. data/lib/tiny_tds/error.rb +12 -0
  36. data/lib/tiny_tds/gem.rb +23 -0
  37. data/lib/tiny_tds/result.rb +5 -0
  38. data/lib/tiny_tds/version.rb +3 -0
  39. data/lib/tiny_tds.rb +42 -0
  40. data/patches/freetds/1.00.27/0001-mingw_missing_inet_pton.diff +34 -0
  41. data/patches/freetds/1.00.27/0002-Don-t-use-MSYS2-file-libws2_32.diff +28 -0
  42. data/patches/libiconv/1.14/1-avoid-gets-error.patch +17 -0
  43. data/ports/aarch64-linux-gnu/bin/defncopy +0 -0
  44. data/ports/aarch64-linux-gnu/bin/tsql +0 -0
  45. data/ports/aarch64-linux-gnu/lib/libsybdb.so.5 +0 -0
  46. data/setup_cimgruby_dev.sh +25 -0
  47. data/start_dev.sh +21 -0
  48. data/tasks/native_gem.rake +16 -0
  49. data/tasks/package.rake +6 -0
  50. data/tasks/ports.rake +24 -0
  51. data/tasks/test.rake +7 -0
  52. data/test/bin/install-freetds.sh +18 -0
  53. data/test/bin/install-mssql.ps1 +42 -0
  54. data/test/bin/install-mssqltools.sh +9 -0
  55. data/test/bin/install-openssl.sh +18 -0
  56. data/test/bin/restore-from-native-gem.ps1 +10 -0
  57. data/test/bin/setup_tinytds_db.sh +7 -0
  58. data/test/bin/setup_volume_permissions.sh +10 -0
  59. data/test/client_test.rb +266 -0
  60. data/test/gem_test.rb +100 -0
  61. data/test/result_test.rb +708 -0
  62. data/test/schema/1px.gif +0 -0
  63. data/test/schema/sqlserver_2017.sql +140 -0
  64. data/test/schema/sqlserver_azure.sql +140 -0
  65. data/test/schema_test.rb +417 -0
  66. data/test/sql/db-create.sql +18 -0
  67. data/test/sql/db-login.sql +38 -0
  68. data/test/test_helper.rb +244 -0
  69. data/test/thread_test.rb +89 -0
  70. data/tiny_tds.gemspec +31 -0
  71. metadata +259 -0
@@ -0,0 +1,90 @@
1
+ require_relative "version"
2
+ require_relative "gem"
3
+ require "shellwords"
4
+
5
+ module TinyTds
6
+ class Bin
7
+ attr_reader :name
8
+
9
+ class << self
10
+ def exe(name, *args)
11
+ bin = new(name)
12
+ puts bin.info unless args.any? { |x| x == "-q" }
13
+ bin.run(*args)
14
+ end
15
+ end
16
+
17
+ def initialize(name)
18
+ @root = Gem.root_path
19
+ @exts = (ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]) | [".exe"]
20
+
21
+ @name = name
22
+ @binstub = find_bin
23
+ @exefile = find_exe
24
+ end
25
+
26
+ def run(*args)
27
+ with_ports_paths do
28
+ return nil unless path
29
+ Kernel.system Shellwords.join(args.unshift(path))
30
+ $CHILD_STATUS.to_i
31
+ end
32
+ end
33
+
34
+ def path
35
+ @path ||= (@exefile && File.exist?(@exefile)) ? @exefile : which
36
+ end
37
+
38
+ def info
39
+ "[TinyTds][v#{TinyTds::VERSION}][#{name}]: #{path}"
40
+ end
41
+
42
+ private
43
+
44
+ def search_paths
45
+ ENV["PATH"].split File::PATH_SEPARATOR
46
+ end
47
+
48
+ def with_ports_paths
49
+ old_path = ENV["PATH"]
50
+
51
+ begin
52
+ ENV["PATH"] = [
53
+ Gem.ports_bin_paths,
54
+ old_path
55
+ ].flatten.join File::PATH_SEPARATOR
56
+
57
+ yield if block_given?
58
+ ensure
59
+ ENV["PATH"] = old_path
60
+ end
61
+ end
62
+
63
+ def find_bin
64
+ File.join @root, "bin", name
65
+ end
66
+
67
+ def find_exe
68
+ Gem.ports_bin_paths.each do |bin|
69
+ @exts.each do |ext|
70
+ f = File.join bin, "#{name}#{ext}"
71
+ return f if File.exist?(f)
72
+ end
73
+ end
74
+ nil
75
+ end
76
+
77
+ def which
78
+ search_paths.each do |path|
79
+ @exts.each do |ext|
80
+ exe = File.expand_path File.join(path, "#{name}#{ext}"), @root
81
+ next if exe == @binstub
82
+ next unless File.executable?(exe)
83
+
84
+ return exe
85
+ end
86
+ end
87
+ nil
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,132 @@
1
+ module TinyTds
2
+ class Client
3
+ @default_query_options = {
4
+ as: :hash,
5
+ symbolize_keys: false,
6
+ cache_rows: true,
7
+ timezone: :local,
8
+ empty_sets: true
9
+ }
10
+
11
+ attr_reader :query_options
12
+ attr_reader :message_handler
13
+
14
+ class << self
15
+ attr_reader :default_query_options
16
+
17
+ # Most, if not all, iconv encoding names can be found by ruby. Just in case, you can
18
+ # overide this method to return a string name that Encoding.find would work with. Default
19
+ # is to return the passed encoding.
20
+ #
21
+ def transpose_iconv_encoding(encoding)
22
+ encoding
23
+ end
24
+
25
+ def local_offset
26
+ ::Time.local(2010).utc_offset.to_r / 86_400
27
+ end
28
+ end
29
+
30
+ # rubocop:disable Metrics/AbcSize
31
+ # rubocop:disable Metrics/MethodLength
32
+ # rubocop:disable Metrics/CyclomaticComplexity
33
+ # rubocop:disable Metrics/PerceivedComplexity
34
+ def initialize(opts = {})
35
+ if opts[:dataserver].to_s.empty? && opts[:host].to_s.empty?
36
+ raise ArgumentError, "missing :host option if no :dataserver given"
37
+ end
38
+
39
+ @message_handler = opts[:message_handler]
40
+ if @message_handler && !@message_handler.respond_to?(:call)
41
+ raise ArgumentError, ":message_handler must implement `call` (eg, a Proc or a Method)"
42
+ end
43
+
44
+ opts[:username] = parse_username(opts)
45
+ @query_options = self.class.default_query_options.dup
46
+ opts[:password] = opts[:password].to_s if opts[:password] && opts[:password].to_s.strip != ""
47
+ opts[:appname] ||= "TinyTds"
48
+ opts[:tds_version] = tds_versions_setter(opts)
49
+ opts[:use_utf16] = opts[:use_utf16].nil? || ["true", "1", "yes"].include?(opts[:use_utf16].to_s)
50
+ opts[:login_timeout] ||= 60
51
+ opts[:timeout] ||= 5
52
+ opts[:encoding] = (opts[:encoding].nil? || opts[:encoding].casecmp("utf8").zero?) ? "UTF-8" : opts[:encoding].upcase
53
+ opts[:port] ||= 1433
54
+ opts[:dataserver] = "#{opts[:host]}:#{opts[:port]}" if opts[:dataserver].to_s.empty?
55
+ forced_integer_keys = [:login_timeout, :port, :timeout]
56
+ forced_integer_keys.each { |k| opts[k] = opts[k].to_i if opts[k] }
57
+ connect(opts)
58
+ end
59
+
60
+ def tds_73?
61
+ tds_version >= 11
62
+ end
63
+
64
+ def tds_version_info
65
+ info = TDS_VERSIONS_GETTERS[tds_version]
66
+ "#{info[:name]} - #{info[:description]}" if info
67
+ end
68
+
69
+ def active?
70
+ !closed? && !dead?
71
+ end
72
+
73
+ private
74
+
75
+ def parse_username(opts)
76
+ host = opts[:host]
77
+ username = opts[:username]
78
+ return username if username.nil? || !opts[:azure]
79
+ return username if username.include?("@") && !username.include?("database.windows.net")
80
+ user, domain = username.split("@")
81
+ domain ||= host
82
+ "#{user}@#{domain.split(".").first}"
83
+ end
84
+
85
+ def tds_versions_setter(opts = {})
86
+ v = opts[:tds_version] || ENV["TDSVER"] || "7.3"
87
+ TDS_VERSIONS_SETTERS[v.to_s]
88
+ end
89
+
90
+ # From sybdb.h comments:
91
+ # DBVERSION_xxx are used with dbsetversion()
92
+ #
93
+ TDS_VERSIONS_SETTERS = {
94
+ "unknown" => 0,
95
+ "46" => 1,
96
+ "100" => 2,
97
+ "42" => 3,
98
+ "70" => 4,
99
+ "7.0" => 4,
100
+ "71" => 5,
101
+ "7.1" => 5,
102
+ "80" => 5,
103
+ "8.0" => 5,
104
+ "72" => 6,
105
+ "7.2" => 6,
106
+ "90" => 6,
107
+ "9.0" => 6,
108
+ "73" => 7,
109
+ "7.3" => 7
110
+ }.freeze
111
+
112
+ # From sybdb.h comments:
113
+ # DBTDS_xxx are returned by DBTDS()
114
+ # The integer values of the constants are poorly chosen.
115
+ #
116
+ TDS_VERSIONS_GETTERS = {
117
+ 0 => {name: "DBTDS_UNKNOWN", description: "Unknown"},
118
+ 1 => {name: "DBTDS_2_0", description: "Pre 4.0 SQL Server"},
119
+ 2 => {name: "DBTDS_3_4", description: "Microsoft SQL Server (3.0)"},
120
+ 3 => {name: "DBTDS_4_0", description: "4.0 SQL Server"},
121
+ 4 => {name: "DBTDS_4_2", description: "4.2 SQL Server"},
122
+ 5 => {name: "DBTDS_4_6", description: "2.0 OpenServer and 4.6 SQL Server."},
123
+ 6 => {name: "DBTDS_4_9_5", description: "4.9.5 (NCR) SQL Server"},
124
+ 7 => {name: "DBTDS_5_0", description: "5.0 SQL Server"},
125
+ 8 => {name: "DBTDS_7_0", description: "Microsoft SQL Server 7.0"},
126
+ 9 => {name: "DBTDS_7_1/DBTDS_8_0", description: "Microsoft SQL Server 2000"},
127
+ 10 => {name: "DBTDS_7_2/DBTDS_9_0", description: "Microsoft SQL Server 2005"},
128
+ 11 => {name: "DBTDS_7_3", description: "Microsoft SQL Server 2008"},
129
+ 12 => {name: "DBTDS_7_4", description: "Microsoft SQL Server 2012/2014"}
130
+ }.freeze
131
+ end
132
+ end
@@ -0,0 +1,12 @@
1
+ module TinyTds
2
+ class Error < StandardError
3
+ attr_accessor :source, :severity, :db_error_number, :os_error_number
4
+
5
+ def initialize(message)
6
+ super
7
+ @severity = nil
8
+ @db_error_number = nil
9
+ @os_error_number = nil
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ require "rbconfig"
2
+
3
+ module TinyTds
4
+ module Gem
5
+ class << self
6
+ def root_path
7
+ File.expand_path "../../..", __FILE__
8
+ end
9
+
10
+ def ports_root_path
11
+ File.join(root_path, "ports")
12
+ end
13
+
14
+ def ports_bin_paths
15
+ Dir.glob(File.join(ports_root_path, "**", "bin"))
16
+ end
17
+
18
+ def ports_lib_paths
19
+ Dir.glob(File.join(ports_root_path, "**", "lib"))
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module TinyTds
2
+ class Result
3
+ include Enumerable
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module TinyTds
2
+ VERSION = File.read(File.expand_path("../../../VERSION", __FILE__)).chomp
3
+ end
data/lib/tiny_tds.rb ADDED
@@ -0,0 +1,42 @@
1
+ require "date"
2
+ require "bigdecimal"
3
+
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"
9
+
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
+
16
+ add_dll_path = proc do |path, &block|
17
+ if RUBY_PLATFORM =~ /(mswin|mingw)/i && path
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
+ block.call
25
+ ENV["PATH"] = old_path
26
+ end
27
+ else
28
+ # libsybdb is found by a relative rpath in the cross compiled extension dll
29
+ # or by the system library loader
30
+ block.call
31
+ end
32
+ end
33
+
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"
41
+ end
42
+ end
@@ -0,0 +1,34 @@
1
+ diff --git a/src/tds/tls.c b/src/tds/tls.c
2
+ index 09e7fa0..1da18f6 100644
3
+ --- a/src/tds/tls.c
4
+ +++ b/src/tds/tls.c
5
+ @@ -101,6 +101,29 @@
6
+ #define SSL_PTR BIO_get_data(bio)
7
+ #endif
8
+
9
+ +/*
10
+ + * Add a workaround for older Mingw versions without inet_pton().
11
+ + * This means RubyInstallers DevKit-4.7.2 in particular.
12
+ + */
13
+ +#if defined(__MINGW32__) && !defined(InetPtonA)
14
+ + #include <windows.h>
15
+ +
16
+ + static HMODULE ws2_32 = NULL;
17
+ + typedef INT (WINAPI * __inet_pton)(INT Family, LPCWSTR pStringBuf, PVOID pAddr);
18
+ + static __inet_pton _inet_pton = NULL;
19
+ +
20
+ + INT WINAPI inet_pton(INT Family, LPCWSTR pStringBuf, PVOID pAddr)
21
+ + {
22
+ + if (_inet_pton == NULL) {
23
+ + ws2_32 = LoadLibraryEx("Ws2_32.dll", NULL, 0);
24
+ +
25
+ + _inet_pton = (__inet_pton)GetProcAddress(ws2_32, "inet_pton");
26
+ + }
27
+ +
28
+ + return (_inet_pton)(Family, pStringBuf, pAddr);
29
+ + }
30
+ +#endif
31
+ +
32
+ static SSL_RET
33
+ tds_pull_func_login(SSL_PULL_ARGS)
34
+ {
@@ -0,0 +1,28 @@
1
+ From 56e8972f66c3e948e2ad6885595c58fd23dcdb37 Mon Sep 17 00:00:00 2001
2
+ From: Lars Kanis <kanis@comcard.de>
3
+ Date: Thu, 6 Jul 2017 17:09:40 +0200
4
+ Subject: [PATCH] Don't use MSYS2 file libws2_32.a for MINGW build
5
+
6
+ This file is intended for MSYS2/cygwin builds and blocks OpenSSL
7
+ detection of freetds on i686.
8
+ ---
9
+ configure | 2 --
10
+ configure.ac | 2 --
11
+ 2 files changed, 4 deletions(-)
12
+
13
+ diff --git a/configure b/configure
14
+ index 9495a49..31eb01d 100644
15
+ --- a/configure
16
+ +++ b/configure
17
+ @@ -15915,8 +15915,6 @@ case $host in
18
+ tds_mingw=yes
19
+ if test "$host_cpu" = "x86_64"; then
20
+ LIBS="-lws2_32"
21
+ - elif test -r /usr/lib/w32api/libws2_32.a; then
22
+ - LIBS="-L/usr/lib/w32api -lws2_32"
23
+ else
24
+ LIBS="-lws2_32"
25
+ fi
26
+ --
27
+ 2.6.2.windows.1
28
+
@@ -0,0 +1,17 @@
1
+ --- a/srclib/stdio.in.h 2017-01-22 01:23:00.000000000 -0400
2
+ +++ b/srclib/stdio.in.h 2017-01-22 01:24:00.000000000 -0400
3
+ @@ -695,8 +695,14 @@
4
+ /* It is very rare that the developer ever has full control of stdin,
5
+ so any use of gets warrants an unconditional warning. Assume it is
6
+ always declared, since it is required by C89. */
7
+ +#if defined(__GLIBC__) && !defined(__UCLIBC__)
8
+ +# ifdef __GLIBC_PREREQ
9
+ +# if !__GLIBC_PREREQ(2, 16)
10
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
11
+ +# endif
12
+ +# endif
13
+ +#endif
14
+ #endif
15
+
16
+
17
+ #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
Binary file
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -x
4
+ set -e
5
+
6
+ # this should mirror the steps outlined in the circleci yml
7
+ echo "Installing mssql-tools..."
8
+ sleep 5
9
+ sudo -E ./test/bin/install-mssqltools.sh
10
+
11
+ echo "Configurating tinytds test database..."
12
+ sleep 5
13
+ ./test/bin/setup_tinytds_db.sh
14
+
15
+ echo "Building openssl library..."
16
+ sleep 5
17
+ sudo -E ./test/bin/install-openssl.sh
18
+
19
+ echo "Building freetds library..."
20
+ sleep 5
21
+ sudo -E ./test/bin/install-freetds.sh
22
+
23
+ echo "Installing gems..."
24
+ sleep 5
25
+ bundle install
data/start_dev.sh ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -x
4
+ set -e
5
+
6
+ # set volume read/write permissions to work both outside and inside container
7
+ sudo ./test/bin/setup_volume_permissions.sh
8
+
9
+ docker-compose up -d
10
+ echo "Waiting for containers to start..."
11
+ sleep 10
12
+
13
+ # setup circleci ruby container for development
14
+ docker exec cimg_ruby bash -c './setup_cimgruby_dev.sh'
15
+
16
+ # enter container
17
+ set +x
18
+ echo "cimg/ruby container is ready for tiny_tds development.........."
19
+ echo "To enter container run: docker exec -it cimg_ruby /bin/bash"
20
+ echo "To build solution run: docker exec cimg_ruby bash -c 'bundle exec rake build'"
21
+ echo "To test solution run: docker exec cimg_ruby bash -c 'bundle exec rake test'"
@@ -0,0 +1,16 @@
1
+ CrossLibraries.each do |xlib|
2
+ platform = xlib.platform
3
+
4
+ desc "Build fat binary gem for platform #{platform}"
5
+ task "gem:native:#{platform}" do
6
+ require "rake_compiler_dock"
7
+
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
+ end
13
+
14
+ desc "Build the native binary gems"
15
+ multitask "gem:native" => "gem:native:#{platform}"
16
+ end
@@ -0,0 +1,6 @@
1
+ require "rubygems/package_task"
2
+
3
+ Gem::PackageTask.new(SPEC) do |pkg|
4
+ pkg.need_tar = false
5
+ pkg.need_zip = false
6
+ end
data/tasks/ports.rake ADDED
@@ -0,0 +1,24 @@
1
+ require_relative "../ext/tiny_tds/extconsts"
2
+
3
+ namespace :ports do
4
+ libraries_to_compile = {
5
+ openssl: OPENSSL_VERSION,
6
+ libiconv: ICONV_VERSION,
7
+ freetds: FREETDS_VERSION
8
+ }
9
+
10
+ desc "Notes the actual versions for the compiled ports into a file"
11
+ task "version_file", [:gem_platform] do |_task, args|
12
+ args.with_defaults(gem_platform: RbConfig::CONFIG["arch"])
13
+
14
+ ports_version = {}
15
+
16
+ libraries_to_compile.each do |library, version|
17
+ ports_version[library] = version
18
+ end
19
+
20
+ ports_version[:platform] = args.gem_platform
21
+
22
+ File.write(".ports_versions", ports_version)
23
+ end
24
+ end
data/tasks/test.rake ADDED
@@ -0,0 +1,7 @@
1
+ require "rake/testtask"
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << "test"
5
+ t.test_files = FileList["test/**/*_test.rb"]
6
+ t.verbose = true
7
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -x
4
+ set -e
5
+
6
+ if [ -z "$FREETDS_VERSION" ]; then
7
+ FREETDS_VERSION=$(ruby -r "./ext/tiny_tds/extconsts.rb" -e "puts FREETDS_VERSION")
8
+ fi
9
+
10
+ wget http://www.freetds.org/files/stable/freetds-$FREETDS_VERSION.tar.gz
11
+ tar -xzf freetds-$FREETDS_VERSION.tar.gz
12
+ cd freetds-$FREETDS_VERSION
13
+ ./configure
14
+ make
15
+ sudo make install
16
+ cd ..
17
+ rm -rf freetds-$FREETDS_VERSION
18
+ rm freetds-$FREETDS_VERSION.tar.gz
@@ -0,0 +1,42 @@
1
+ param ([int] $Version)
2
+
3
+ $ProgressPreference = 'SilentlyContinue'
4
+
5
+ $DownloadLinkTable = @{
6
+ 2017 = "https://go.microsoft.com/fwlink/?linkid=829176";
7
+ 2019 = "https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SQLEXPR_x64_ENU.exe";
8
+ 2022 = "https://download.microsoft.com/download/3/8/d/38de7036-2433-4207-8eae-06e247e17b25/SQLEXPR_x64_ENU.exe";
9
+ }
10
+
11
+ $MajorVersionTable = @{
12
+ 2017 = 14;
13
+ 2019 = 15;
14
+ 2022 = 16;
15
+ }
16
+
17
+ if (-not(Test-path "C:\Downloads")) {
18
+ mkdir "C:\Downloads"
19
+ }
20
+
21
+ $sqlInstallationFile = "C:\Downloads\sqlexpress.exe"
22
+ if (-not(Test-path $sqlInstallationFile -PathType leaf)) {
23
+ Write-Host "Downloading SQL Express ..."
24
+ Invoke-WebRequest -Uri $DownloadLinkTable[$Version] -OutFile "C:\Downloads\sqlexpress.exe"
25
+ }
26
+
27
+ Write-Host "Installing SQL Express ..."
28
+ Start-Process -Wait -FilePath "C:\Downloads\sqlexpress.exe" -ArgumentList /qs, /x:"C:\Downloads\setup"
29
+ C:\Downloads\setup\setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS
30
+
31
+ Write-Host "Configuring SQL Express ..."
32
+ stop-service MSSQL`$SQLEXPRESS
33
+ set-itemproperty -path "HKLM:\software\microsoft\microsoft sql server\mssql$($MajorVersionTable[$Version]).SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall" -name tcpdynamicports -value ''
34
+ set-itemproperty -path "HKLM:\software\microsoft\microsoft sql server\mssql$($MajorVersionTable[$Version]).SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall" -name tcpport -value 1433
35
+ set-itemproperty -path "HKLM:\software\microsoft\microsoft sql server\mssql$($MajorVersionTable[$Version]).SQLEXPRESS\mssqlserver\" -name LoginMode -value 2
36
+
37
+ Write-Host "Starting SQL Express ..."
38
+ start-service MSSQL`$SQLEXPRESS
39
+
40
+ Write-Host "Configuring MSSQL for TinyTDS ..."
41
+ & sqlcmd -i './test/sql/db-create.sql'
42
+ & sqlcmd -i './test/sql/db-login.sql'
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -x
4
+ set -e
5
+
6
+ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
7
+ curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
8
+ sudo apt-get update
9
+ sudo ACCEPT_EULA=Y apt-get -y install mssql-tools unixodbc-dev
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -x
4
+ set -e
5
+
6
+ if [ -z "$OPENSSL_VERSION" ]; then
7
+ OPENSSL_VERSION=$(ruby -r "./ext/tiny_tds/extconsts.rb" -e "puts OPENSSL_VERSION")
8
+ fi
9
+
10
+ wget https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
11
+ tar -xzf openssl-$OPENSSL_VERSION.tar.gz
12
+ cd openssl-$OPENSSL_VERSION
13
+ ./config --prefix=/opt/local --openssldir=/opt/local
14
+ make
15
+ make install_sw install_ssldirs
16
+ cd ..
17
+ rm -rf openssl-$OPENSSL_VERSION
18
+ rm openssl-$OPENSSL_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)}
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -x
4
+ set -e
5
+
6
+ /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -i ./test/sql/db-create.sql
7
+ /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -i ./test/sql/db-login.sql
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -x
4
+
5
+ sudo groupadd -g 3434 circleci_tinytds
6
+ sudo usermod -a -G circleci_tinytds $USER
7
+ sudo useradd circleci_tinytds -u 3434 -g 3434
8
+ sudo usermod -a -G circleci_tinytds circleci_tinytds
9
+ sudo chgrp -R circleci_tinytds .
10
+ sudo chmod -R g+rwx .