tiny_tds 3.2.1 → 3.3.0
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.
- checksums.yaml +4 -4
- data/.devcontainer/Dockerfile +21 -0
- data/.devcontainer/boot.sh +6 -0
- data/.devcontainer/compose.yaml +40 -0
- data/.devcontainer/devcontainer.json +30 -0
- data/.github/workflows/ci.yml +17 -5
- data/CHANGELOG.md +7 -0
- data/README.md +17 -33
- data/Rakefile +5 -0
- data/VERSION +1 -1
- data/astyle.conf +8 -0
- data/ext/tiny_tds/client.c +163 -64
- data/ext/tiny_tds/extconsts.rb +2 -2
- data/ext/tiny_tds/result.c +171 -42
- data/ext/tiny_tds/result.h +2 -2
- data/ext/tiny_tds/tiny_tds_ext.c +2 -1
- data/lib/tiny_tds/bin.rb +2 -2
- data/lib/tiny_tds/gem.rb +6 -6
- data/lib/tiny_tds.rb +1 -2
- data/test/bin/restore-from-native-gem.ps1 +7 -1
- data/test/gem_test.rb +23 -28
- data/test/thread_test.rb +1 -1
- data/tiny_tds.gemspec +2 -2
- metadata +8 -14
- data/docker-compose.yml +0 -34
- data/setup_cimgruby_dev.sh +0 -25
- data/start_dev.sh +0 -21
- data/test/bin/install-mssql.ps1 +0 -42
- data/test/bin/install-mssqltools.sh +0 -9
- data/test/bin/install-openssl.sh +0 -18
- data/test/bin/setup_tinytds_db.sh +0 -7
- data/test/bin/setup_volume_permissions.sh +0 -10
data/lib/tiny_tds/gem.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "rbconfig"
|
2
|
-
|
3
1
|
module TinyTds
|
4
2
|
module Gem
|
5
3
|
class << self
|
@@ -11,12 +9,14 @@ module TinyTds
|
|
11
9
|
File.join(root_path, "ports")
|
12
10
|
end
|
13
11
|
|
14
|
-
def
|
15
|
-
Dir.glob(File.join(ports_root_path, "
|
12
|
+
def ports_bin_and_lib_paths
|
13
|
+
Dir.glob(File.join(ports_root_path, "#{gem_platform.cpu}-#{gem_platform.os}*", "{bin,lib}"))
|
16
14
|
end
|
17
15
|
|
18
|
-
|
19
|
-
|
16
|
+
private
|
17
|
+
|
18
|
+
def gem_platform
|
19
|
+
::Gem::Platform.local
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/tiny_tds.rb
CHANGED
@@ -10,8 +10,7 @@ require "tiny_tds/gem"
|
|
10
10
|
module TinyTds
|
11
11
|
# Is this file part of a fat binary gem with bundled freetds?
|
12
12
|
# This path must be enabled by add_dll_directory on Windows.
|
13
|
-
|
14
|
-
FREETDS_LIB_PATH = Dir[File.expand_path("../ports/#{gplat.cpu}-#{gplat.os}*/{bin,lib}", __dir__)].first
|
13
|
+
FREETDS_LIB_PATH = TinyTds::Gem.ports_bin_and_lib_paths.first
|
15
14
|
|
16
15
|
add_dll_path = proc do |path, &block|
|
17
16
|
if RUBY_PLATFORM =~ /(mswin|mingw)/i && path
|
@@ -4,7 +4,13 @@ $gemToUnpack = "./tiny_tds-$gemVersion-$env:RUBY_ARCHITECTURE.gem"
|
|
4
4
|
Write-Host "Looking to unpack $gemToUnpack"
|
5
5
|
gem unpack --target ./tmp "$gemToUnpack"
|
6
6
|
|
7
|
-
# Restore precompiled code
|
7
|
+
# Restore precompiled code (Gem code)
|
8
8
|
$source = (Resolve-Path ".\tmp\tiny_tds-$gemVersion-$env:RUBY_ARCHITECTURE\lib\tiny_tds").Path
|
9
9
|
$destination = (Resolve-Path ".\lib\tiny_tds").Path
|
10
10
|
Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)}
|
11
|
+
|
12
|
+
# Restore precompiled code (ports)
|
13
|
+
$source = (Resolve-Path ".\tmp\tiny_tds-$gemVersion-$env:RUBY_ARCHITECTURE\ports").Path
|
14
|
+
New-Item -ItemType Directory -Path ".\ports" -Force
|
15
|
+
$destination = (Resolve-Path ".\ports").Path
|
16
|
+
Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)}
|
data/test/gem_test.rb
CHANGED
@@ -7,11 +7,9 @@ class GemTest < Minitest::Spec
|
|
7
7
|
describe TinyTds::Gem do
|
8
8
|
# We're going to muck with some system globals so lets make sure
|
9
9
|
# they get set back later
|
10
|
-
original_platform = RbConfig::CONFIG["arch"]
|
11
10
|
original_pwd = Dir.pwd
|
12
11
|
|
13
12
|
after do
|
14
|
-
RbConfig::CONFIG["arch"] = original_platform
|
15
13
|
Dir.chdir original_pwd
|
16
14
|
end
|
17
15
|
|
@@ -43,56 +41,53 @@ class GemTest < Minitest::Spec
|
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
46
|
-
describe "#
|
47
|
-
let(:
|
44
|
+
describe "#ports_bin_and_lib_paths" do
|
45
|
+
let(:ports_bin_and_lib_paths) { TinyTds::Gem.ports_bin_and_lib_paths }
|
48
46
|
|
49
47
|
describe "when the ports directories exist" do
|
50
|
-
let(:
|
51
|
-
ports_host_root = File.join(gem_root, "ports", "
|
52
|
-
[
|
53
|
-
File.join("a", "bin"),
|
54
|
-
File.join("a", "inner", "bin"),
|
55
|
-
File.join("b", "bin")
|
56
|
-
].map do |p|
|
48
|
+
let(:fake_bin_and_lib_path) do
|
49
|
+
ports_host_root = File.join(gem_root, "ports", "x86_64-unknown")
|
50
|
+
["bin", "lib"].map do |p|
|
57
51
|
File.join(ports_host_root, p)
|
58
52
|
end
|
59
53
|
end
|
60
54
|
|
61
55
|
before do
|
62
|
-
|
63
|
-
fake_bin_paths.each do |path|
|
56
|
+
fake_bin_and_lib_path.each do |path|
|
64
57
|
FileUtils.mkdir_p(path)
|
65
58
|
end
|
66
59
|
end
|
67
60
|
|
68
61
|
after do
|
69
62
|
FileUtils.remove_entry_secure(
|
70
|
-
File.join(gem_root, "ports", "
|
63
|
+
File.join(gem_root, "ports", "x86_64-unknown"), true
|
71
64
|
)
|
72
65
|
end
|
73
66
|
|
74
67
|
it "should return all the bin directories" do
|
75
|
-
|
76
|
-
|
68
|
+
fake_platform = Gem::Platform.new("x86_64-unknown")
|
69
|
+
|
70
|
+
Gem::Platform.stub(:local, fake_platform) do
|
71
|
+
_(ports_bin_and_lib_paths.sort).must_equal fake_bin_and_lib_path.sort
|
77
72
|
|
78
|
-
|
79
|
-
|
80
|
-
|
73
|
+
# should return the same regardless of path
|
74
|
+
Dir.chdir "/"
|
75
|
+
_(ports_bin_and_lib_paths.sort).must_equal fake_bin_and_lib_path.sort
|
76
|
+
end
|
81
77
|
end
|
82
78
|
end
|
83
79
|
|
84
80
|
describe "when the ports directories are missing" do
|
85
|
-
before do
|
86
|
-
RbConfig::CONFIG["arch"] = "fake-host-without-dirs"
|
87
|
-
end
|
88
|
-
|
89
81
|
it "should return no directories" do
|
90
|
-
|
91
|
-
end
|
82
|
+
fake_platform = Gem::Platform.new("x86_64-unknown")
|
92
83
|
|
93
|
-
|
94
|
-
|
95
|
-
|
84
|
+
Gem::Platform.stub(:local, fake_platform) do
|
85
|
+
_(ports_bin_and_lib_paths).must_be_empty
|
86
|
+
|
87
|
+
# should be empty regardless of path
|
88
|
+
Dir.chdir "/"
|
89
|
+
_(ports_bin_and_lib_paths).must_be_empty
|
90
|
+
end
|
96
91
|
end
|
97
92
|
end
|
98
93
|
end
|
data/test/thread_test.rb
CHANGED
@@ -65,7 +65,7 @@ class ThreadTest < TinyTds::TestCase
|
|
65
65
|
result = client.execute "waitfor delay '00:00:#{delay}'; select db_name()"
|
66
66
|
result.each { |r| puts r }
|
67
67
|
rescue TinyTds::Error => e
|
68
|
-
if e.message
|
68
|
+
if e.message.include?("connection timed out")
|
69
69
|
exception = true
|
70
70
|
end
|
71
71
|
end
|
data/tiny_tds.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
2
|
-
|
2
|
+
version = File.read(File.expand_path("VERSION", __dir__)).strip
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "tiny_tds"
|
6
|
-
s.version =
|
6
|
+
s.version = version
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Ken Collins", "Erik Bryn", "Will Bond"]
|
9
9
|
s.email = ["ken@metaskills.net", "will@wbond.net"]
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_tds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins
|
8
8
|
- Erik Bryn
|
9
9
|
- Will Bond
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: bigdecimal
|
@@ -165,6 +164,10 @@ extensions:
|
|
165
164
|
extra_rdoc_files: []
|
166
165
|
files:
|
167
166
|
- ".codeclimate.yml"
|
167
|
+
- ".devcontainer/Dockerfile"
|
168
|
+
- ".devcontainer/boot.sh"
|
169
|
+
- ".devcontainer/compose.yaml"
|
170
|
+
- ".devcontainer/devcontainer.json"
|
168
171
|
- ".gitattributes"
|
169
172
|
- ".github/workflows/ci.yml"
|
170
173
|
- ".gitignore"
|
@@ -177,9 +180,9 @@ files:
|
|
177
180
|
- README.md
|
178
181
|
- Rakefile
|
179
182
|
- VERSION
|
183
|
+
- astyle.conf
|
180
184
|
- bin/defncopy-ttds
|
181
185
|
- bin/tsql-ttds
|
182
|
-
- docker-compose.yml
|
183
186
|
- exe/.keep
|
184
187
|
- ext/tiny_tds/client.c
|
185
188
|
- ext/tiny_tds/client.h
|
@@ -199,19 +202,12 @@ files:
|
|
199
202
|
- patches/freetds/1.00.27/0001-mingw_missing_inet_pton.diff
|
200
203
|
- patches/freetds/1.00.27/0002-Don-t-use-MSYS2-file-libws2_32.diff
|
201
204
|
- patches/libiconv/1.14/1-avoid-gets-error.patch
|
202
|
-
- setup_cimgruby_dev.sh
|
203
|
-
- start_dev.sh
|
204
205
|
- tasks/native_gem.rake
|
205
206
|
- tasks/package.rake
|
206
207
|
- tasks/ports.rake
|
207
208
|
- tasks/test.rake
|
208
209
|
- test/bin/install-freetds.sh
|
209
|
-
- test/bin/install-mssql.ps1
|
210
|
-
- test/bin/install-mssqltools.sh
|
211
|
-
- test/bin/install-openssl.sh
|
212
210
|
- test/bin/restore-from-native-gem.ps1
|
213
|
-
- test/bin/setup_tinytds_db.sh
|
214
|
-
- test/bin/setup_volume_permissions.sh
|
215
211
|
- test/client_test.rb
|
216
212
|
- test/gem_test.rb
|
217
213
|
- test/result_test.rb
|
@@ -229,7 +225,6 @@ licenses:
|
|
229
225
|
- MIT
|
230
226
|
metadata:
|
231
227
|
msys2_mingw_dependencies: freetds
|
232
|
-
post_install_message:
|
233
228
|
rdoc_options:
|
234
229
|
- "--charset=UTF-8"
|
235
230
|
require_paths:
|
@@ -245,8 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
245
240
|
- !ruby/object:Gem::Version
|
246
241
|
version: '0'
|
247
242
|
requirements: []
|
248
|
-
rubygems_version: 3.
|
249
|
-
signing_key:
|
243
|
+
rubygems_version: 3.6.9
|
250
244
|
specification_version: 4
|
251
245
|
summary: TinyTDS - A modern, simple and fast FreeTDS library for Ruby using DB-Library.
|
252
246
|
test_files: []
|
data/docker-compose.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
version: '3'
|
2
|
-
|
3
|
-
networks:
|
4
|
-
main-network:
|
5
|
-
|
6
|
-
services:
|
7
|
-
mssql:
|
8
|
-
image: mcr.microsoft.com/mssql/server:${MSSQL_VERSION:-2017}-latest
|
9
|
-
container_name: sqlserver
|
10
|
-
environment:
|
11
|
-
ACCEPT_EULA: Y
|
12
|
-
MSSQL_SA_PASSWORD: super01S3cUr3
|
13
|
-
ports:
|
14
|
-
- "1433:1433"
|
15
|
-
network_mode: "host"
|
16
|
-
|
17
|
-
toxiproxy:
|
18
|
-
image: shopify/toxiproxy
|
19
|
-
container_name: toxiproxy
|
20
|
-
command: '/toxiproxy -host=127.0.0.1'
|
21
|
-
network_mode: "host"
|
22
|
-
|
23
|
-
cimgruby:
|
24
|
-
image: "cimg/ruby:${RUBY_VERSION:-2.7}"
|
25
|
-
container_name: cimg_ruby
|
26
|
-
environment:
|
27
|
-
TESTOPTS: '-v'
|
28
|
-
TINYTDS_UNIT_HOST: '127.0.0.1'
|
29
|
-
SA_PASSWORD: super01S3cUr3
|
30
|
-
TOXIPROXY_HOST: '127.0.0.1'
|
31
|
-
command: tail -F anything
|
32
|
-
volumes:
|
33
|
-
- .:/home/circleci/project
|
34
|
-
network_mode: "host"
|
data/setup_cimgruby_dev.sh
DELETED
@@ -1,25 +0,0 @@
|
|
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
DELETED
@@ -1,21 +0,0 @@
|
|
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'"
|
data/test/bin/install-mssql.ps1
DELETED
@@ -1,42 +0,0 @@
|
|
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'
|
@@ -1,9 +0,0 @@
|
|
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
|
data/test/bin/install-openssl.sh
DELETED
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,10 +0,0 @@
|
|
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 .
|