tiny_tds 2.1.2 → 3.2.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.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +571 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +56 -1
- data/Gemfile +1 -8
- data/ISSUE_TEMPLATE.md +1 -1
- data/README.md +89 -89
- data/Rakefile +44 -30
- data/VERSION +1 -1
- data/docker-compose.yml +34 -0
- data/ext/tiny_tds/client.c +100 -59
- data/ext/tiny_tds/client.h +5 -3
- data/ext/tiny_tds/extconf.rb +173 -52
- data/ext/tiny_tds/extconsts.rb +4 -11
- data/ext/tiny_tds/result.c +52 -45
- data/ext/tiny_tds/tiny_tds_ext.c +4 -1
- data/lib/tiny_tds/bin.rb +12 -26
- data/lib/tiny_tds/client.rb +38 -42
- data/lib/tiny_tds/error.rb +0 -2
- data/lib/tiny_tds/gem.rb +5 -14
- data/lib/tiny_tds/result.rb +0 -2
- data/lib/tiny_tds/version.rb +1 -1
- data/lib/tiny_tds.rb +28 -47
- data/setup_cimgruby_dev.sh +25 -0
- data/start_dev.sh +21 -0
- data/tasks/native_gem.rake +12 -10
- data/tasks/package.rake +1 -3
- data/tasks/ports.rake +14 -77
- data/tasks/test.rake +3 -5
- data/test/bin/install-freetds.sh +2 -4
- data/test/bin/install-mssql.ps1 +42 -0
- data/test/bin/install-mssqltools.sh +9 -0
- data/test/bin/restore-from-native-gem.ps1 +10 -0
- data/test/bin/setup_tinytds_db.sh +7 -0
- data/test/bin/setup_volume_permissions.sh +10 -0
- data/test/client_test.rb +152 -116
- data/test/gem_test.rb +39 -118
- data/test/result_test.rb +285 -350
- data/test/schema_test.rb +369 -395
- data/test/sql/db-create.sql +18 -0
- data/test/sql/db-login.sql +38 -0
- data/test/test_helper.rb +112 -85
- data/test/thread_test.rb +22 -31
- data/tiny_tds.gemspec +28 -26
- metadata +85 -59
- data/.travis.yml +0 -24
- data/BACKERS.md +0 -32
- data/appveyor.yml +0 -51
- data/tasks/ports/freetds.rb +0 -37
- data/tasks/ports/libiconv.rb +0 -43
- data/tasks/ports/openssl.rb +0 -78
- data/tasks/ports/recipe.rb +0 -52
- data/test/appveyor/dbsetup.ps1 +0 -27
- data/test/appveyor/dbsetup.sql +0 -9
- data/test/benchmark/query.rb +0 -77
- data/test/benchmark/query_odbc.rb +0 -106
- data/test/benchmark/query_tinytds.rb +0 -126
- data/test/bin/setup.sh +0 -19
- data/test/schema/sqlserver_2000.sql +0 -140
- data/test/schema/sqlserver_2005.sql +0 -140
- data/test/schema/sqlserver_2014.sql +0 -140
- data/test/schema/sqlserver_2016.sql +0 -140
- data/test/schema/sybase_ase.sql +0 -138
- /data/test/schema/{sqlserver_2008.sql → sqlserver_2017.sql} +0 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
:ON ERROR EXIT
|
2
|
+
|
3
|
+
PRINT 'RUNNING DB-CREATE.SQL, CREATING TINYTDS TEST DATABASE';
|
4
|
+
IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = 'tinytdstest')
|
5
|
+
BEGIN
|
6
|
+
CREATE DATABASE [tinytdstest];
|
7
|
+
END
|
8
|
+
GO
|
9
|
+
|
10
|
+
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name LIKE 'tinytdstest')
|
11
|
+
BEGIN
|
12
|
+
PRINT 'TINY TDS TEST DB SUCCESSFULY CREATED';
|
13
|
+
END
|
14
|
+
ELSE
|
15
|
+
BEGIN
|
16
|
+
THROW 51000, 'TINY TDS TEST DB CREATION FAILED', 1;
|
17
|
+
END
|
18
|
+
GO
|
@@ -0,0 +1,38 @@
|
|
1
|
+
:ON ERROR EXIT
|
2
|
+
|
3
|
+
PRINT 'RUNNING DB-LOGIN.SQL';
|
4
|
+
|
5
|
+
PRINT 'CREATING TINYTDS TEST LOGIN';
|
6
|
+
IF NOT EXISTS (select name from sys.server_principals where name like 'tinytds')
|
7
|
+
BEGIN
|
8
|
+
CREATE LOGIN [tinytds] WITH PASSWORD = '', CHECK_POLICY = OFF, DEFAULT_DATABASE = [tinytdstest];
|
9
|
+
END
|
10
|
+
GO
|
11
|
+
|
12
|
+
IF EXISTS (select name from sys.server_principals where name like 'tinytds')
|
13
|
+
BEGIN
|
14
|
+
PRINT 'TINY TDS TEST LOGIN SUCCESSFULY CREATED';
|
15
|
+
END
|
16
|
+
ELSE
|
17
|
+
BEGIN
|
18
|
+
THROW 51000, 'TINY TDS TEST LOGIN CREATION FAILED', 1;
|
19
|
+
END
|
20
|
+
GO
|
21
|
+
|
22
|
+
USE [tinytdstest];
|
23
|
+
IF NOT EXISTS (select name from sys.database_principals where name LIKE 'tinytds')
|
24
|
+
BEGIN
|
25
|
+
CREATE USER [tinytds] FOR LOGIN [tinytds];
|
26
|
+
EXEC sp_addrolemember N'db_owner', N'tinytds';
|
27
|
+
END
|
28
|
+
GO
|
29
|
+
|
30
|
+
IF EXISTS (select name from sys.database_principals where name LIKE 'tinytds')
|
31
|
+
BEGIN
|
32
|
+
PRINT 'TINY TDS TEST USER SUCCESSFULY CREATED';
|
33
|
+
END
|
34
|
+
ELSE
|
35
|
+
BEGIN
|
36
|
+
THROW 51000, 'TINY TDS TEST USER CREATION FAILED', 1;
|
37
|
+
END
|
38
|
+
GO
|
data/test/test_helper.rb
CHANGED
@@ -1,29 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "bundler"
|
2
|
+
Bundler.require :development, :test
|
3
|
+
require "tiny_tds"
|
4
|
+
require "minitest/autorun"
|
5
|
+
require "toxiproxy"
|
5
6
|
|
6
|
-
|
7
|
+
require "minitest/reporters"
|
8
|
+
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new, Minitest::Reporters::JUnitReporter.new]
|
7
9
|
|
8
|
-
|
9
|
-
class TestCase < MiniTest::Spec
|
10
|
+
TINYTDS_SCHEMAS = ["sqlserver_2017", "sqlserver_azure"].freeze
|
10
11
|
|
12
|
+
module TinyTds
|
13
|
+
class TestCase < Minitest::Spec
|
11
14
|
class << self
|
12
|
-
|
13
15
|
def current_schema
|
14
|
-
ENV[
|
16
|
+
ENV["TINYTDS_SCHEMA"] || "sqlserver_2017"
|
15
17
|
end
|
16
18
|
|
17
19
|
TINYTDS_SCHEMAS.each do |schema|
|
18
|
-
define_method "#{schema}?" do
|
19
|
-
schema ==
|
20
|
+
define_method :"#{schema}?" do
|
21
|
+
schema == current_schema
|
20
22
|
end
|
21
23
|
end
|
22
|
-
|
23
|
-
def sqlserver?
|
24
|
-
current_schema =~ /sqlserver/
|
25
|
-
end
|
26
|
-
|
27
24
|
end
|
28
25
|
|
29
26
|
after { close_client }
|
@@ -31,7 +28,7 @@ module TinyTds
|
|
31
28
|
protected
|
32
29
|
|
33
30
|
TINYTDS_SCHEMAS.each do |schema|
|
34
|
-
define_method "#{schema}?" do
|
31
|
+
define_method :"#{schema}?" do
|
35
32
|
schema == self.class.current_schema
|
36
33
|
end
|
37
34
|
end
|
@@ -40,52 +37,44 @@ module TinyTds
|
|
40
37
|
self.class.current_schema
|
41
38
|
end
|
42
39
|
|
43
|
-
def
|
44
|
-
self.class.sqlserver?
|
45
|
-
end
|
46
|
-
|
47
|
-
def close_client(client=@client)
|
40
|
+
def close_client(client = @client)
|
48
41
|
client.close if defined?(client) && client.is_a?(TinyTds::Client)
|
49
42
|
end
|
50
43
|
|
51
|
-
def new_connection(options={})
|
44
|
+
def new_connection(options = {})
|
52
45
|
client = TinyTds::Client.new(connection_options(options))
|
53
|
-
if
|
54
|
-
client.execute("SET
|
55
|
-
|
56
|
-
|
57
|
-
client.execute(
|
58
|
-
client.execute(
|
59
|
-
client.execute(
|
60
|
-
client.execute(
|
61
|
-
client.execute('SET ANSI_PADDING ON').do
|
62
|
-
client.execute('SET QUOTED_IDENTIFIER ON').do
|
63
|
-
client.execute('SET ANSI_WARNINGS ON').do
|
46
|
+
if sqlserver_azure?
|
47
|
+
client.execute("SET ANSI_NULLS ON").do
|
48
|
+
client.execute("SET CURSOR_CLOSE_ON_COMMIT OFF").do
|
49
|
+
client.execute("SET ANSI_NULL_DFLT_ON ON").do
|
50
|
+
client.execute("SET IMPLICIT_TRANSACTIONS OFF").do
|
51
|
+
client.execute("SET ANSI_PADDING ON").do
|
52
|
+
client.execute("SET QUOTED_IDENTIFIER ON").do
|
53
|
+
client.execute("SET ANSI_WARNINGS ON").do
|
64
54
|
else
|
65
|
-
client.execute(
|
66
|
-
client.execute(
|
67
|
-
client.execute(
|
55
|
+
client.execute("SET ANSI_DEFAULTS ON").do
|
56
|
+
client.execute("SET CURSOR_CLOSE_ON_COMMIT OFF").do
|
57
|
+
client.execute("SET IMPLICIT_TRANSACTIONS OFF").do
|
68
58
|
end
|
69
|
-
client.execute(
|
70
|
-
client.execute(
|
59
|
+
client.execute("SET TEXTSIZE 2147483647").do
|
60
|
+
client.execute("SET CONCAT_NULL_YIELDS_NULL ON").do
|
71
61
|
client
|
72
62
|
end
|
73
63
|
|
74
|
-
def connection_options(options={})
|
75
|
-
username = (sqlserver_azure? ? ENV[
|
76
|
-
password = (sqlserver_azure? ? ENV[
|
77
|
-
{
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
}.merge(options)
|
64
|
+
def connection_options(options = {})
|
65
|
+
username = (sqlserver_azure? ? ENV["TINYTDS_UNIT_AZURE_USER"] : ENV["TINYTDS_UNIT_USER"]) || "tinytds"
|
66
|
+
password = (sqlserver_azure? ? ENV["TINYTDS_UNIT_AZURE_PASS"] : ENV["TINYTDS_UNIT_PASS"]) || ""
|
67
|
+
{dataserver: sqlserver_azure? ? nil : ENV["TINYTDS_UNIT_DATASERVER"],
|
68
|
+
host: ENV["TINYTDS_UNIT_HOST"] || "localhost",
|
69
|
+
port: ENV["TINYTDS_UNIT_PORT"] || "1433",
|
70
|
+
tds_version: ENV["TINYTDS_UNIT_VERSION"],
|
71
|
+
username: username,
|
72
|
+
password: password,
|
73
|
+
database: ENV["TINYTDS_UNIT_DATABASE"] || "tinytdstest",
|
74
|
+
appname: "TinyTds Dev",
|
75
|
+
login_timeout: 5,
|
76
|
+
timeout: connection_timeout,
|
77
|
+
azure: sqlserver_azure?}.merge(options)
|
89
78
|
end
|
90
79
|
|
91
80
|
def connection_timeout
|
@@ -93,7 +82,7 @@ module TinyTds
|
|
93
82
|
end
|
94
83
|
|
95
84
|
def assert_client_works(client)
|
96
|
-
client.execute("SELECT 'client_works' as [client_works]").each.must_equal [{
|
85
|
+
_(client.execute("SELECT 'client_works' as [client_works]").each).must_equal [{"client_works" => "client_works"}]
|
97
86
|
end
|
98
87
|
|
99
88
|
def assert_new_connections_work
|
@@ -110,28 +99,26 @@ module TinyTds
|
|
110
99
|
rescue TinyTds::Error => e
|
111
100
|
error_raised = true
|
112
101
|
end
|
113
|
-
assert error_raised,
|
102
|
+
assert error_raised, "expected a TinyTds::Error but none happened"
|
114
103
|
yield e
|
115
104
|
ensure
|
116
105
|
close_client(result)
|
117
106
|
end
|
118
107
|
|
119
108
|
def inspect_tinytds_exception
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
raise "TinyTds::Error - #{props.inspect}"
|
126
|
-
end
|
109
|
+
yield
|
110
|
+
rescue TinyTds::Error => e
|
111
|
+
props = {source: e.source, message: e.message, severity: e.severity,
|
112
|
+
db_error_number: e.db_error_number, os_error_number: e.os_error_number}
|
113
|
+
raise "TinyTds::Error - #{props.inspect}"
|
127
114
|
end
|
128
115
|
|
129
116
|
def assert_binary_encoding(value)
|
130
|
-
assert_equal Encoding.find(
|
117
|
+
assert_equal Encoding.find("BINARY"), value.encoding
|
131
118
|
end
|
132
119
|
|
133
120
|
def assert_utf8_encoding(value)
|
134
|
-
assert_equal Encoding.find(
|
121
|
+
assert_equal Encoding.find("UTF-8"), value.encoding
|
135
122
|
end
|
136
123
|
|
137
124
|
def rubyRbx?
|
@@ -139,38 +126,27 @@ module TinyTds
|
|
139
126
|
end
|
140
127
|
|
141
128
|
def ruby_windows?
|
142
|
-
RbConfig::CONFIG[
|
129
|
+
RbConfig::CONFIG["host_os"] =~ /ming/
|
143
130
|
end
|
144
131
|
|
145
132
|
def ruby_darwin?
|
146
|
-
RbConfig::CONFIG[
|
133
|
+
RbConfig::CONFIG["host_os"] =~ /darwin/
|
147
134
|
end
|
148
135
|
|
149
136
|
def load_current_schema
|
150
137
|
loader = new_connection
|
151
|
-
schema_file = File.expand_path File.join(File.dirname(__FILE__),
|
152
|
-
schema_sql = File.open(schema_file,"rb:UTF-8") { |f|f.read }
|
138
|
+
schema_file = File.expand_path File.join(File.dirname(__FILE__), "schema", "#{current_schema}.sql")
|
139
|
+
schema_sql = File.open(schema_file, "rb:UTF-8") { |f| f.read }
|
153
140
|
loader.execute(drop_sql).do
|
154
141
|
loader.execute(schema_sql).do
|
155
142
|
loader.execute(sp_sql).do
|
143
|
+
loader.execute(sp_error_sql).do
|
144
|
+
loader.execute(sp_several_prints_sql).do
|
156
145
|
loader.close
|
157
146
|
true
|
158
147
|
end
|
159
148
|
|
160
149
|
def drop_sql
|
161
|
-
sybase_ase? ? drop_sql_sybase : drop_sql_microsoft
|
162
|
-
end
|
163
|
-
|
164
|
-
def drop_sql_sybase
|
165
|
-
%|IF EXISTS(
|
166
|
-
SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'datatypes'
|
167
|
-
) DROP TABLE datatypes
|
168
|
-
IF EXISTS(
|
169
|
-
SELECT 1 FROM sysobjects WHERE type = 'P' AND name = 'tinytds_TestReturnCodes'
|
170
|
-
) DROP PROCEDURE tinytds_TestReturnCodes|
|
171
|
-
end
|
172
|
-
|
173
|
-
def drop_sql_microsoft
|
174
150
|
%|IF EXISTS (
|
175
151
|
SELECT TABLE_NAME
|
176
152
|
FROM INFORMATION_SCHEMA.TABLES
|
@@ -181,7 +157,15 @@ module TinyTds
|
|
181
157
|
IF EXISTS (
|
182
158
|
SELECT name FROM sysobjects
|
183
159
|
WHERE name = 'tinytds_TestReturnCodes' AND type = 'P'
|
184
|
-
) DROP PROCEDURE tinytds_TestReturnCodes
|
160
|
+
) DROP PROCEDURE tinytds_TestReturnCodes
|
161
|
+
IF EXISTS (
|
162
|
+
SELECT name FROM sysobjects
|
163
|
+
WHERE name = 'tinytds_TestPrintWithError' AND type = 'P'
|
164
|
+
) DROP PROCEDURE tinytds_TestPrintWithError
|
165
|
+
IF EXISTS (
|
166
|
+
SELECT name FROM sysobjects
|
167
|
+
WHERE name = 'tinytds_TestSeveralPrints' AND type = 'P'
|
168
|
+
) DROP PROCEDURE tinytds_TestSeveralPrints|
|
185
169
|
end
|
186
170
|
|
187
171
|
def sp_sql
|
@@ -191,7 +175,22 @@ module TinyTds
|
|
191
175
|
RETURN(420) |
|
192
176
|
end
|
193
177
|
|
194
|
-
def
|
178
|
+
def sp_error_sql
|
179
|
+
%|CREATE PROCEDURE tinytds_TestPrintWithError
|
180
|
+
AS
|
181
|
+
PRINT 'hello'
|
182
|
+
RAISERROR('Error following print', 16, 1)|
|
183
|
+
end
|
184
|
+
|
185
|
+
def sp_several_prints_sql
|
186
|
+
%(CREATE PROCEDURE tinytds_TestSeveralPrints
|
187
|
+
AS
|
188
|
+
PRINT 'hello 1'
|
189
|
+
PRINT 'hello 2'
|
190
|
+
PRINT 'hello 3')
|
191
|
+
end
|
192
|
+
|
193
|
+
def find_value(id, column, query_options = {})
|
195
194
|
query_options[:timezone] ||= :utc
|
196
195
|
sql = "SELECT [#{column}] FROM [datatypes] WHERE [id] = #{id}"
|
197
196
|
@client.execute(sql).each(query_options).first[column.to_s]
|
@@ -212,6 +211,34 @@ module TinyTds
|
|
212
211
|
client.execute("ROLLBACK TRANSACTION").do
|
213
212
|
end
|
214
213
|
|
214
|
+
def init_toxiproxy
|
215
|
+
# In order for toxiproxy to work for local docker instances of mssql, the containers must be on the same network
|
216
|
+
# and the host used below must match the mssql container name so toxiproxy knows where to proxy to.
|
217
|
+
# localhost from the perspective of toxiproxy's container is its own container an *not* the mssql container it needs to proxy to.
|
218
|
+
# docker-compose.yml handles this automatically for us. In instances where someone is using their own local mssql container they'll
|
219
|
+
# need to set up the networks manually and set TINYTDS_UNIT_HOST to their mssql container name
|
220
|
+
# For anything other than localhost just use the environment config
|
221
|
+
toxi_host = ENV["TOXIPROXY_HOST"] || "localhost"
|
222
|
+
toxi_api_port = 8474
|
223
|
+
toxi_test_port = 1234
|
224
|
+
Toxiproxy.host = "http://#{toxi_host}:#{toxi_api_port}"
|
225
|
+
|
226
|
+
toxi_upstream_host = ENV["TINYTDS_UNIT_HOST_TEST"] || ENV["TINYTDS_UNIT_HOST"] || "localhost"
|
227
|
+
toxi_upstream_port = ENV["TINYTDS_UNIT_PORT"] || 1433
|
228
|
+
|
229
|
+
puts "\n-------------------------"
|
230
|
+
puts "Toxiproxy api listener: #{toxi_host}:#{toxi_api_port}"
|
231
|
+
puts "Toxiproxy unit test listener: #{toxi_host}:#{toxi_test_port}"
|
232
|
+
puts "Toxiproxy upstream sqlserver: #{toxi_upstream_host}:#{toxi_upstream_port}"
|
233
|
+
puts "-------------------------"
|
234
|
+
|
235
|
+
Toxiproxy.populate([
|
236
|
+
{
|
237
|
+
name: "sqlserver_test",
|
238
|
+
listen: "#{toxi_host}:#{toxi_test_port}",
|
239
|
+
upstream: "#{toxi_upstream_host}:#{toxi_upstream_port}"
|
240
|
+
}
|
241
|
+
])
|
242
|
+
end
|
215
243
|
end
|
216
244
|
end
|
217
|
-
|
data/test/thread_test.rb
CHANGED
@@ -1,25 +1,23 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "test_helper"
|
2
|
+
require "logger"
|
3
|
+
require "benchmark"
|
4
4
|
|
5
5
|
class ThreadTest < TinyTds::TestCase
|
6
|
-
|
7
|
-
describe 'Threaded SELECT queries' do
|
8
|
-
|
6
|
+
describe "Threaded SELECT queries" do
|
9
7
|
before do
|
10
8
|
@logger = Logger.new $stdout
|
11
9
|
@logger.level = Logger::WARN
|
12
10
|
@poolsize = 4
|
13
11
|
@numthreads = 10
|
14
12
|
@query = "waitfor delay '00:00:01'"
|
15
|
-
@pool = ConnectionPool.new(:
|
13
|
+
@pool = ConnectionPool.new(size: @poolsize, timeout: 5) { new_connection }
|
16
14
|
end
|
17
15
|
|
18
16
|
after do
|
19
17
|
@pool.shutdown { |c| c.close }
|
20
18
|
end
|
21
19
|
|
22
|
-
it
|
20
|
+
it "should finish faster in parallel" do
|
23
21
|
skip if sqlserver_azure?
|
24
22
|
x = Benchmark.realtime do
|
25
23
|
threads = []
|
@@ -35,24 +33,22 @@ class ThreadTest < TinyTds::TestCase
|
|
35
33
|
threads.each { |t| t.join }
|
36
34
|
end
|
37
35
|
assert x < @numthreads, "#{x} is not faster than #{@numthreads} seconds"
|
38
|
-
mintime = (1.0
|
36
|
+
mintime = (1.0 * @numthreads / @poolsize).ceil
|
39
37
|
@logger.info "#{@numthreads} queries on #{@poolsize} threads: #{x} sec. Minimum time: #{mintime} sec."
|
40
38
|
assert x > mintime, "#{x} is not slower than #{mintime} seconds"
|
41
39
|
end
|
42
40
|
|
43
|
-
it
|
41
|
+
it "should not crash on error in parallel" do
|
44
42
|
skip if sqlserver_azure?
|
45
43
|
threads = []
|
46
44
|
@numthreads.times do |i|
|
47
45
|
threads << Thread.new do
|
48
46
|
@pool.with do |client|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
# segfault on errors thrown in threads
|
55
|
-
end
|
47
|
+
result = client.execute "select dbname()"
|
48
|
+
result.each { |r| puts r }
|
49
|
+
rescue => _e
|
50
|
+
# We are throwing an error on purpose here since 0.6.1 would
|
51
|
+
# segfault on errors thrown in threads
|
56
52
|
end
|
57
53
|
end
|
58
54
|
end
|
@@ -60,27 +56,25 @@ class ThreadTest < TinyTds::TestCase
|
|
60
56
|
assert true
|
61
57
|
end
|
62
58
|
|
63
|
-
it
|
59
|
+
it "should cancel when hitting timeout in thread" do
|
64
60
|
exception = false
|
65
61
|
|
66
62
|
thread = Thread.new do
|
67
63
|
@pool.with do |client|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
exception = true
|
75
|
-
end
|
64
|
+
delay = ("0" + (connection_timeout + 2).to_s)[-2, 2] # Two seconds longer than default.
|
65
|
+
result = client.execute "waitfor delay '00:00:#{delay}'; select db_name()"
|
66
|
+
result.each { |r| puts r }
|
67
|
+
rescue TinyTds::Error => e
|
68
|
+
if e.message == "Adaptive Server connection timed out"
|
69
|
+
exception = true
|
76
70
|
end
|
77
71
|
end
|
78
72
|
end
|
79
73
|
|
80
74
|
timer_thread = Thread.new do
|
81
75
|
# Sleep until after the timeout should have been reached
|
82
|
-
sleep(connection_timeout+2)
|
83
|
-
if
|
76
|
+
sleep(connection_timeout + 2)
|
77
|
+
if !exception
|
84
78
|
thread.kill
|
85
79
|
raise "Timeout passed without query timing out"
|
86
80
|
end
|
@@ -91,8 +85,5 @@ class ThreadTest < TinyTds::TestCase
|
|
91
85
|
|
92
86
|
assert exception
|
93
87
|
end
|
94
|
-
|
95
88
|
end
|
96
|
-
|
97
89
|
end
|
98
|
-
|
data/tiny_tds.gemspec
CHANGED
@@ -1,29 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'tiny_tds/version'
|
1
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "tiny_tds/version"
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
|
-
s.name
|
7
|
-
s.version
|
8
|
-
s.platform
|
9
|
-
s.authors
|
10
|
-
s.email
|
11
|
-
s.homepage
|
12
|
-
s.summary
|
13
|
-
s.description
|
14
|
-
s.files
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
s.
|
18
|
-
s.
|
19
|
-
s.
|
20
|
-
s.
|
21
|
-
s.
|
22
|
-
s.
|
23
|
-
s.add_development_dependency
|
24
|
-
s.add_development_dependency
|
25
|
-
s.add_development_dependency
|
26
|
-
s.add_development_dependency
|
27
|
-
s.add_development_dependency
|
28
|
-
s.add_development_dependency
|
5
|
+
s.name = "tiny_tds"
|
6
|
+
s.version = TinyTds::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Ken Collins", "Erik Bryn", "Will Bond"]
|
9
|
+
s.email = ["ken@metaskills.net", "will@wbond.net"]
|
10
|
+
s.homepage = "http://github.com/rails-sqlserver/tiny_tds"
|
11
|
+
s.summary = "TinyTDS - A modern, simple and fast FreeTDS library for Ruby using DB-Library."
|
12
|
+
s.description = "TinyTDS - A modern, simple and fast FreeTDS library for Ruby using DB-Library. Developed for the ActiveRecord SQL Server adapter."
|
13
|
+
s.files = `git ls-files`.split("\n") + Dir.glob("exe/*")
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
17
|
+
s.extensions = ["ext/tiny_tds/extconf.rb"]
|
18
|
+
s.license = "MIT"
|
19
|
+
s.required_ruby_version = ">= 2.7.0"
|
20
|
+
s.metadata["msys2_mingw_dependencies"] = "freetds"
|
21
|
+
s.add_dependency "bigdecimal", "~> 3"
|
22
|
+
s.add_development_dependency "mini_portile2", "~> 2.8.0"
|
23
|
+
s.add_development_dependency "rake", "~> 13.0.0"
|
24
|
+
s.add_development_dependency "rake-compiler", "~> 1.2"
|
25
|
+
s.add_development_dependency "rake-compiler-dock", "~> 1.9.1"
|
26
|
+
s.add_development_dependency "minitest", "~> 5.25"
|
27
|
+
s.add_development_dependency "minitest-reporters", "~> 1.6.1"
|
28
|
+
s.add_development_dependency "connection_pool", "~> 2.2.0"
|
29
|
+
s.add_development_dependency "toxiproxy", "~> 2.0.0"
|
30
|
+
s.add_development_dependency "standard", "~> 1.31.0"
|
29
31
|
end
|