tiny_tds 2.1.6-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +407 -0
- data/.codeclimate.yml +20 -0
- data/.gitattributes +1 -0
- data/.gitignore +22 -0
- data/.rubocop.yml +31 -0
- data/CHANGELOG.md +280 -0
- data/CODE_OF_CONDUCT.md +31 -0
- data/Gemfile +2 -0
- data/ISSUE_TEMPLATE.md +38 -0
- data/MIT-LICENSE +23 -0
- data/README.md +504 -0
- data/Rakefile +62 -0
- data/VERSION +1 -0
- data/bin/defncopy-ttds +3 -0
- data/bin/tsql-ttds +3 -0
- data/docker-compose.yml +34 -0
- data/exe/.keep +0 -0
- data/ext/tiny_tds/client.c +499 -0
- data/ext/tiny_tds/client.h +53 -0
- data/ext/tiny_tds/extconf.rb +92 -0
- data/ext/tiny_tds/extconsts.rb +15 -0
- data/ext/tiny_tds/result.c +634 -0
- data/ext/tiny_tds/result.h +32 -0
- data/ext/tiny_tds/tiny_tds_ext.c +12 -0
- data/ext/tiny_tds/tiny_tds_ext.h +17 -0
- data/lib/tiny_tds/3.1/tiny_tds.so +0 -0
- data/lib/tiny_tds/3.2/tiny_tds.so +0 -0
- data/lib/tiny_tds/bin.rb +104 -0
- data/lib/tiny_tds/client.rb +136 -0
- data/lib/tiny_tds/error.rb +14 -0
- data/lib/tiny_tds/gem.rb +27 -0
- data/lib/tiny_tds/result.rb +7 -0
- data/lib/tiny_tds/version.rb +3 -0
- data/lib/tiny_tds.rb +61 -0
- data/patches/freetds/1.00.27/0001-mingw_missing_inet_pton.diff +34 -0
- data/patches/freetds/1.00.27/0002-Don-t-use-MSYS2-file-libws2_32.diff +28 -0
- data/patches/libiconv/1.14/1-avoid-gets-error.patch +17 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/bin/bsqldb.exe +0 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/bin/datacopy.exe +0 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/bin/defncopy.exe +0 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/bin/freebcp.exe +0 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/bin/libct-4.dll +0 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/bin/libsybdb-5.dll +0 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/bin/osql +388 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/bin/tdspool.exe +0 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/bin/tsql.exe +0 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/lib/libct.dll.a +0 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/lib/libct.la +41 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/lib/libsybdb.dll.a +0 -0
- data/ports/x64-mingw-ucrt/freetds/1.1.24/lib/libsybdb.la +41 -0
- data/ports/x64-mingw-ucrt/libiconv/1.15/bin/iconv.exe +0 -0
- data/ports/x64-mingw-ucrt/libiconv/1.15/bin/libcharset-1.dll +0 -0
- data/ports/x64-mingw-ucrt/libiconv/1.15/bin/libiconv-2.dll +0 -0
- data/ports/x64-mingw-ucrt/libiconv/1.15/lib/charset.alias +4 -0
- data/ports/x64-mingw-ucrt/libiconv/1.15/lib/libcharset.dll.a +0 -0
- data/ports/x64-mingw-ucrt/libiconv/1.15/lib/libcharset.la +41 -0
- data/ports/x64-mingw-ucrt/libiconv/1.15/lib/libiconv.dll.a +0 -0
- data/ports/x64-mingw-ucrt/libiconv/1.15/lib/libiconv.la +41 -0
- data/ports/x64-mingw-ucrt/openssl/1.1.1s/bin/c_rehash +251 -0
- data/ports/x64-mingw-ucrt/openssl/1.1.1s/bin/libcrypto-1_1-x64.dll +0 -0
- data/ports/x64-mingw-ucrt/openssl/1.1.1s/bin/libssl-1_1-x64.dll +0 -0
- data/ports/x64-mingw-ucrt/openssl/1.1.1s/bin/openssl.exe +0 -0
- data/ports/x64-mingw-ucrt/openssl/1.1.1s/lib/libcrypto.a +0 -0
- data/ports/x64-mingw-ucrt/openssl/1.1.1s/lib/libcrypto.dll.a +0 -0
- data/ports/x64-mingw-ucrt/openssl/1.1.1s/lib/libssl.a +0 -0
- data/ports/x64-mingw-ucrt/openssl/1.1.1s/lib/libssl.dll.a +0 -0
- data/setup_cimgruby_dev.sh +25 -0
- data/start_dev.sh +21 -0
- data/tasks/native_gem.rake +23 -0
- data/tasks/package.rake +8 -0
- data/tasks/ports/freetds.rb +37 -0
- data/tasks/ports/libiconv.rb +26 -0
- data/tasks/ports/openssl.rb +62 -0
- data/tasks/ports/recipe.rb +64 -0
- data/tasks/ports.rake +108 -0
- data/tasks/test.rake +9 -0
- data/test/benchmark/query.rb +77 -0
- data/test/benchmark/query_odbc.rb +106 -0
- data/test/benchmark/query_tinytds.rb +126 -0
- data/test/bin/install-freetds.sh +20 -0
- data/test/bin/install-mssql.ps1 +31 -0
- data/test/bin/install-mssqltools.sh +9 -0
- data/test/bin/install-openssl.sh +18 -0
- data/test/bin/setup_tinytds_db.sh +7 -0
- data/test/bin/setup_volume_permissions.sh +10 -0
- data/test/client_test.rb +275 -0
- data/test/gem_test.rb +177 -0
- data/test/result_test.rb +814 -0
- data/test/schema/1px.gif +0 -0
- data/test/schema/sqlserver_2000.sql +140 -0
- data/test/schema/sqlserver_2005.sql +140 -0
- data/test/schema/sqlserver_2008.sql +140 -0
- data/test/schema/sqlserver_2014.sql +140 -0
- data/test/schema/sqlserver_2016.sql +140 -0
- data/test/schema/sqlserver_azure.sql +140 -0
- data/test/schema/sybase_ase.sql +138 -0
- data/test/schema_test.rb +443 -0
- data/test/sql/db-create.sql +18 -0
- data/test/sql/db-login.sql +38 -0
- data/test/test_helper.rb +280 -0
- data/test/thread_test.rb +98 -0
- data/tiny_tds.gemspec +31 -0
- metadata +267 -0
data/test/test_helper.rb
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'bundler' ; Bundler.require :development, :test
|
3
|
+
require 'tiny_tds'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'toxiproxy'
|
6
|
+
|
7
|
+
TINYTDS_SCHEMAS = ['sqlserver_2000', 'sqlserver_2005', 'sqlserver_2008', 'sqlserver_2014', 'sqlserver_azure', 'sybase_ase'].freeze
|
8
|
+
|
9
|
+
module TinyTds
|
10
|
+
class TestCase < MiniTest::Spec
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def current_schema
|
15
|
+
ENV['TINYTDS_SCHEMA'] || 'sqlserver_2014'
|
16
|
+
end
|
17
|
+
|
18
|
+
TINYTDS_SCHEMAS.each do |schema|
|
19
|
+
define_method "#{schema}?" do
|
20
|
+
schema == self.current_schema
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def sqlserver?
|
25
|
+
current_schema =~ /sqlserver/
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
after { close_client }
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
TINYTDS_SCHEMAS.each do |schema|
|
35
|
+
define_method "#{schema}?" do
|
36
|
+
schema == self.class.current_schema
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def current_schema
|
41
|
+
self.class.current_schema
|
42
|
+
end
|
43
|
+
|
44
|
+
def sqlserver?
|
45
|
+
self.class.sqlserver?
|
46
|
+
end
|
47
|
+
|
48
|
+
def close_client(client=@client)
|
49
|
+
client.close if defined?(client) && client.is_a?(TinyTds::Client)
|
50
|
+
end
|
51
|
+
|
52
|
+
def new_connection(options={})
|
53
|
+
client = TinyTds::Client.new(connection_options(options))
|
54
|
+
if sybase_ase?
|
55
|
+
client.execute("SET ANSINULL ON").do
|
56
|
+
return client
|
57
|
+
elsif sqlserver_azure?
|
58
|
+
client.execute('SET ANSI_NULLS ON').do
|
59
|
+
client.execute('SET CURSOR_CLOSE_ON_COMMIT OFF').do
|
60
|
+
client.execute('SET ANSI_NULL_DFLT_ON ON').do
|
61
|
+
client.execute('SET IMPLICIT_TRANSACTIONS OFF').do
|
62
|
+
client.execute('SET ANSI_PADDING ON').do
|
63
|
+
client.execute('SET QUOTED_IDENTIFIER ON').do
|
64
|
+
client.execute('SET ANSI_WARNINGS ON').do
|
65
|
+
else
|
66
|
+
client.execute('SET ANSI_DEFAULTS ON').do
|
67
|
+
client.execute('SET CURSOR_CLOSE_ON_COMMIT OFF').do
|
68
|
+
client.execute('SET IMPLICIT_TRANSACTIONS OFF').do
|
69
|
+
end
|
70
|
+
client.execute('SET TEXTSIZE 2147483647').do
|
71
|
+
client.execute('SET CONCAT_NULL_YIELDS_NULL ON').do
|
72
|
+
client
|
73
|
+
end
|
74
|
+
|
75
|
+
def connection_options(options={})
|
76
|
+
username = (sqlserver_azure? ? ENV['TINYTDS_UNIT_AZURE_USER'] : ENV['TINYTDS_UNIT_USER']) || 'tinytds'
|
77
|
+
password = (sqlserver_azure? ? ENV['TINYTDS_UNIT_AZURE_PASS'] : ENV['TINYTDS_UNIT_PASS']) || ''
|
78
|
+
{ :dataserver => sqlserver_azure? ? nil : ENV['TINYTDS_UNIT_DATASERVER'],
|
79
|
+
:host => ENV['TINYTDS_UNIT_HOST'] || 'localhost',
|
80
|
+
:port => ENV['TINYTDS_UNIT_PORT'] || '1433',
|
81
|
+
:tds_version => ENV['TINYTDS_UNIT_VERSION'],
|
82
|
+
:username => username,
|
83
|
+
:password => password,
|
84
|
+
:database => ENV['TINYTDS_UNIT_DATABASE'] || 'tinytdstest',
|
85
|
+
:appname => 'TinyTds Dev',
|
86
|
+
:login_timeout => 5,
|
87
|
+
:timeout => connection_timeout,
|
88
|
+
:azure => sqlserver_azure?
|
89
|
+
}.merge(options)
|
90
|
+
end
|
91
|
+
|
92
|
+
def connection_timeout
|
93
|
+
sqlserver_azure? ? 20 : 8
|
94
|
+
end
|
95
|
+
|
96
|
+
def assert_client_works(client)
|
97
|
+
_(client.execute("SELECT 'client_works' as [client_works]").each).must_equal [{'client_works' => 'client_works'}]
|
98
|
+
end
|
99
|
+
|
100
|
+
def assert_new_connections_work
|
101
|
+
client = new_connection
|
102
|
+
client.execute("SELECT 'new_connections_work' as [new_connections_work]").each
|
103
|
+
client.close
|
104
|
+
end
|
105
|
+
|
106
|
+
def assert_raise_tinytds_error(action)
|
107
|
+
result = nil
|
108
|
+
error_raised = false
|
109
|
+
begin
|
110
|
+
result = action.call
|
111
|
+
rescue TinyTds::Error => e
|
112
|
+
error_raised = true
|
113
|
+
end
|
114
|
+
assert error_raised, 'expected a TinyTds::Error but none happened'
|
115
|
+
yield e
|
116
|
+
ensure
|
117
|
+
close_client(result)
|
118
|
+
end
|
119
|
+
|
120
|
+
def inspect_tinytds_exception
|
121
|
+
begin
|
122
|
+
yield
|
123
|
+
rescue TinyTds::Error => e
|
124
|
+
props = { :source => e.source, :message => e.message, :severity => e.severity,
|
125
|
+
:db_error_number => e.db_error_number, :os_error_number => e.os_error_number }
|
126
|
+
raise "TinyTds::Error - #{props.inspect}"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def assert_binary_encoding(value)
|
131
|
+
assert_equal Encoding.find('BINARY'), value.encoding
|
132
|
+
end
|
133
|
+
|
134
|
+
def assert_utf8_encoding(value)
|
135
|
+
assert_equal Encoding.find('UTF-8'), value.encoding
|
136
|
+
end
|
137
|
+
|
138
|
+
def rubyRbx?
|
139
|
+
RUBY_DESCRIPTION =~ /rubinius/i
|
140
|
+
end
|
141
|
+
|
142
|
+
def ruby_windows?
|
143
|
+
RbConfig::CONFIG['host_os'] =~ /ming/
|
144
|
+
end
|
145
|
+
|
146
|
+
def ruby_darwin?
|
147
|
+
RbConfig::CONFIG['host_os'] =~ /darwin/
|
148
|
+
end
|
149
|
+
|
150
|
+
def load_current_schema
|
151
|
+
loader = new_connection
|
152
|
+
schema_file = File.expand_path File.join(File.dirname(__FILE__), 'schema', "#{current_schema}.sql")
|
153
|
+
schema_sql = File.open(schema_file,"rb:UTF-8") { |f|f.read }
|
154
|
+
loader.execute(drop_sql).do
|
155
|
+
loader.execute(schema_sql).do
|
156
|
+
loader.execute(sp_sql).do
|
157
|
+
loader.execute(sp_error_sql).do
|
158
|
+
loader.execute(sp_several_prints_sql).do
|
159
|
+
loader.close
|
160
|
+
true
|
161
|
+
end
|
162
|
+
|
163
|
+
def drop_sql
|
164
|
+
sybase_ase? ? drop_sql_sybase : drop_sql_microsoft
|
165
|
+
end
|
166
|
+
|
167
|
+
def drop_sql_sybase
|
168
|
+
%|IF EXISTS(
|
169
|
+
SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'datatypes'
|
170
|
+
) DROP TABLE datatypes
|
171
|
+
IF EXISTS(
|
172
|
+
SELECT 1 FROM sysobjects WHERE type = 'P' AND name = 'tinytds_TestReturnCodes'
|
173
|
+
) DROP PROCEDURE tinytds_TestReturnCodes
|
174
|
+
IF EXISTS(
|
175
|
+
SELECT 1 FROM sysobjects WHERE type = 'P' AND name = 'tinytds_TestPrintWithError'
|
176
|
+
) DROP PROCEDURE tinytds_TestPrintWithError
|
177
|
+
IF EXISTS(
|
178
|
+
SELECT 1 FROM sysobjects WHERE type = 'P' AND name = 'tinytds_TestPrintWithError'
|
179
|
+
) DROP PROCEDURE tinytds_TestPrintWithError
|
180
|
+
IF EXISTS(
|
181
|
+
SELECT 1 FROM sysobjects WHERE type = 'P' AND name = 'tinytds_TestSeveralPrints'
|
182
|
+
) DROP PROCEDURE tinytds_TestSeveralPrints|
|
183
|
+
end
|
184
|
+
|
185
|
+
def drop_sql_microsoft
|
186
|
+
%|IF EXISTS (
|
187
|
+
SELECT TABLE_NAME
|
188
|
+
FROM INFORMATION_SCHEMA.TABLES
|
189
|
+
WHERE TABLE_CATALOG = 'tinytdstest'
|
190
|
+
AND TABLE_TYPE = 'BASE TABLE'
|
191
|
+
AND TABLE_NAME = 'datatypes'
|
192
|
+
) DROP TABLE [datatypes]
|
193
|
+
IF EXISTS (
|
194
|
+
SELECT name FROM sysobjects
|
195
|
+
WHERE name = 'tinytds_TestReturnCodes' AND type = 'P'
|
196
|
+
) DROP PROCEDURE tinytds_TestReturnCodes
|
197
|
+
IF EXISTS (
|
198
|
+
SELECT name FROM sysobjects
|
199
|
+
WHERE name = 'tinytds_TestPrintWithError' AND type = 'P'
|
200
|
+
) DROP PROCEDURE tinytds_TestPrintWithError
|
201
|
+
IF EXISTS (
|
202
|
+
SELECT name FROM sysobjects
|
203
|
+
WHERE name = 'tinytds_TestSeveralPrints' AND type = 'P'
|
204
|
+
) DROP PROCEDURE tinytds_TestSeveralPrints|
|
205
|
+
end
|
206
|
+
|
207
|
+
def sp_sql
|
208
|
+
%|CREATE PROCEDURE tinytds_TestReturnCodes
|
209
|
+
AS
|
210
|
+
SELECT 1 as [one]
|
211
|
+
RETURN(420) |
|
212
|
+
end
|
213
|
+
|
214
|
+
def sp_error_sql
|
215
|
+
%|CREATE PROCEDURE tinytds_TestPrintWithError
|
216
|
+
AS
|
217
|
+
PRINT 'hello'
|
218
|
+
RAISERROR('Error following print', 16, 1)|
|
219
|
+
end
|
220
|
+
|
221
|
+
def sp_several_prints_sql
|
222
|
+
%|CREATE PROCEDURE tinytds_TestSeveralPrints
|
223
|
+
AS
|
224
|
+
PRINT 'hello 1'
|
225
|
+
PRINT 'hello 2'
|
226
|
+
PRINT 'hello 3'|
|
227
|
+
end
|
228
|
+
|
229
|
+
def find_value(id, column, query_options={})
|
230
|
+
query_options[:timezone] ||= :utc
|
231
|
+
sql = "SELECT [#{column}] FROM [datatypes] WHERE [id] = #{id}"
|
232
|
+
@client.execute(sql).each(query_options).first[column.to_s]
|
233
|
+
end
|
234
|
+
|
235
|
+
def local_offset
|
236
|
+
TinyTds::Client.local_offset
|
237
|
+
end
|
238
|
+
|
239
|
+
def utc_offset
|
240
|
+
::Time.local(2010).utc_offset
|
241
|
+
end
|
242
|
+
|
243
|
+
def rollback_transaction(client)
|
244
|
+
client.execute("BEGIN TRANSACTION").do
|
245
|
+
yield
|
246
|
+
ensure
|
247
|
+
client.execute("ROLLBACK TRANSACTION").do
|
248
|
+
end
|
249
|
+
|
250
|
+
def init_toxiproxy
|
251
|
+
# In order for toxiproxy to work for local docker instances of mssql, the containers must be on the same network
|
252
|
+
# and the host used below must match the mssql container name so toxiproxy knows where to proxy to.
|
253
|
+
# localhost from the perspective of toxiproxy's container is its own container an *not* the mssql container it needs to proxy to.
|
254
|
+
# docker-compose.yml handles this automatically for us. In instances where someone is using their own local mssql container they'll
|
255
|
+
# need to set up the networks manually and set TINYTDS_UNIT_HOST to their mssql container name
|
256
|
+
# For anything other than localhost just use the environment config
|
257
|
+
toxi_host = ENV['TOXIPROXY_HOST'] || 'localhost'
|
258
|
+
toxi_api_port = 8474
|
259
|
+
toxi_test_port = 1234
|
260
|
+
Toxiproxy.host = "http://#{toxi_host}:#{toxi_api_port}"
|
261
|
+
|
262
|
+
toxi_upstream_host = ENV['TINYTDS_UNIT_HOST_TEST'] || ENV['TINYTDS_UNIT_HOST'] || 'localhost'
|
263
|
+
toxi_upstream_port = ENV['TINYTDS_UNIT_PORT'] || 1433
|
264
|
+
|
265
|
+
puts "\n-------------------------"
|
266
|
+
puts "Toxiproxy api listener: #{toxi_host}:#{toxi_api_port}"
|
267
|
+
puts "Toxiproxy unit test listener: #{toxi_host}:#{toxi_test_port}"
|
268
|
+
puts "Toxiproxy upstream sqlserver: #{toxi_upstream_host}:#{toxi_upstream_port}"
|
269
|
+
puts '-------------------------'
|
270
|
+
|
271
|
+
Toxiproxy.populate([
|
272
|
+
{
|
273
|
+
name: "sqlserver_test",
|
274
|
+
listen: "#{toxi_host}:#{toxi_test_port}",
|
275
|
+
upstream: "#{toxi_upstream_host}:#{toxi_upstream_port}"
|
276
|
+
}
|
277
|
+
])
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
data/test/thread_test.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'logger'
|
3
|
+
require 'benchmark'
|
4
|
+
|
5
|
+
class ThreadTest < TinyTds::TestCase
|
6
|
+
|
7
|
+
describe 'Threaded SELECT queries' do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@logger = Logger.new $stdout
|
11
|
+
@logger.level = Logger::WARN
|
12
|
+
@poolsize = 4
|
13
|
+
@numthreads = 10
|
14
|
+
@query = "waitfor delay '00:00:01'"
|
15
|
+
@pool = ConnectionPool.new(:size => @poolsize, :timeout => 5) { new_connection }
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
@pool.shutdown { |c| c.close }
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should finish faster in parallel' do
|
23
|
+
skip if sqlserver_azure?
|
24
|
+
x = Benchmark.realtime do
|
25
|
+
threads = []
|
26
|
+
@numthreads.times do |i|
|
27
|
+
start = Time.new
|
28
|
+
threads << Thread.new do
|
29
|
+
ts = Time.new
|
30
|
+
@pool.with { |c| c.execute(@query).do }
|
31
|
+
te = Time.new
|
32
|
+
@logger.info "Thread #{i} finished in #{te - ts} thread seconds, #{te - start} real seconds"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
threads.each { |t| t.join }
|
36
|
+
end
|
37
|
+
assert x < @numthreads, "#{x} is not faster than #{@numthreads} seconds"
|
38
|
+
mintime = (1.0*@numthreads/@poolsize).ceil
|
39
|
+
@logger.info "#{@numthreads} queries on #{@poolsize} threads: #{x} sec. Minimum time: #{mintime} sec."
|
40
|
+
assert x > mintime, "#{x} is not slower than #{mintime} seconds"
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should not crash on error in parallel' do
|
44
|
+
skip if sqlserver_azure?
|
45
|
+
threads = []
|
46
|
+
@numthreads.times do |i|
|
47
|
+
threads << Thread.new do
|
48
|
+
@pool.with do |client|
|
49
|
+
begin
|
50
|
+
result = client.execute "select dbname()"
|
51
|
+
result.each { |r| puts r }
|
52
|
+
rescue Exception => _e
|
53
|
+
# We are throwing an error on purpose here since 0.6.1 would
|
54
|
+
# segfault on errors thrown in threads
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
threads.each { |t| t.join }
|
60
|
+
assert true
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should cancel when hitting timeout in thread' do
|
64
|
+
exception = false
|
65
|
+
|
66
|
+
thread = Thread.new do
|
67
|
+
@pool.with do |client|
|
68
|
+
begin
|
69
|
+
delay = ('0' + (connection_timeout + 2).to_s)[-2,2] # Two seconds longer than default.
|
70
|
+
result = client.execute "waitfor delay '00:00:#{delay}'; select db_name()"
|
71
|
+
result.each { |r| puts r }
|
72
|
+
rescue TinyTds::Error => e
|
73
|
+
if e.message == 'Adaptive Server connection timed out'
|
74
|
+
exception = true
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
timer_thread = Thread.new do
|
81
|
+
# Sleep until after the timeout should have been reached
|
82
|
+
sleep(connection_timeout+2)
|
83
|
+
if not exception
|
84
|
+
thread.kill
|
85
|
+
raise "Timeout passed without query timing out"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
thread.join
|
90
|
+
timer_thread.join
|
91
|
+
|
92
|
+
assert exception
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
data/tiny_tds.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'tiny_tds/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'tiny_tds'
|
7
|
+
s.version = TinyTds::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Ken Collins', 'Erik Bryn', 'Will Bond']
|
10
|
+
s.email = ['ken@metaskills.net', 'will@wbond.net']
|
11
|
+
s.homepage = 'http://github.com/rails-sqlserver/tiny_tds'
|
12
|
+
s.summary = 'TinyTDS - A modern, simple and fast FreeTDS library for Ruby using DB-Library.'
|
13
|
+
s.description = 'TinyTDS - A modern, simple and fast FreeTDS library for Ruby using DB-Library. Developed for the ActiveRecord SQL Server adapter.'
|
14
|
+
s.files = `git ls-files`.split("\n") + Dir.glob('exe/*')
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
s.rdoc_options = ['--charset=UTF-8']
|
19
|
+
s.extensions = ['ext/tiny_tds/extconf.rb']
|
20
|
+
s.license = 'MIT'
|
21
|
+
s.required_ruby_version = '>= 2.0.0'
|
22
|
+
s.metadata['msys2_mingw_dependencies'] = 'freetds'
|
23
|
+
s.add_development_dependency 'mini_portile2', '~> 2.5.0'
|
24
|
+
s.add_development_dependency 'rake', '~> 13.0.0'
|
25
|
+
s.add_development_dependency 'rake-compiler', '~> 1.2'
|
26
|
+
s.add_development_dependency 'rake-compiler-dock', '~> 1.3.0'
|
27
|
+
s.add_development_dependency 'minitest', '~> 5.14.0'
|
28
|
+
s.add_development_dependency 'minitest-ci', '~> 3.4.0'
|
29
|
+
s.add_development_dependency 'connection_pool', '~> 2.2.0'
|
30
|
+
s.add_development_dependency 'toxiproxy', '~> 2.0.0'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,267 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tiny_tds
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.1.6
|
5
|
+
platform: x64-mingw-ucrt
|
6
|
+
authors:
|
7
|
+
- Ken Collins
|
8
|
+
- Erik Bryn
|
9
|
+
- Will Bond
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2023-12-04 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mini_portile2
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.5.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 2.5.0
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 13.0.0
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 13.0.0
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rake-compiler
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.2'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.2'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rake-compiler-dock
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.3.0
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.3.0
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: minitest
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 5.14.0
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 5.14.0
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: minitest-ci
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 3.4.0
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 3.4.0
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: connection_pool
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 2.2.0
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.2.0
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: toxiproxy
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 2.0.0
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - "~>"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 2.0.0
|
127
|
+
description: TinyTDS - A modern, simple and fast FreeTDS library for Ruby using DB-Library.
|
128
|
+
Developed for the ActiveRecord SQL Server adapter.
|
129
|
+
email:
|
130
|
+
- ken@metaskills.net
|
131
|
+
- will@wbond.net
|
132
|
+
executables:
|
133
|
+
- defncopy-ttds
|
134
|
+
- tsql-ttds
|
135
|
+
extensions: []
|
136
|
+
extra_rdoc_files: []
|
137
|
+
files:
|
138
|
+
- ".circleci/config.yml"
|
139
|
+
- ".codeclimate.yml"
|
140
|
+
- ".gitattributes"
|
141
|
+
- ".gitignore"
|
142
|
+
- ".rubocop.yml"
|
143
|
+
- CHANGELOG.md
|
144
|
+
- CODE_OF_CONDUCT.md
|
145
|
+
- Gemfile
|
146
|
+
- ISSUE_TEMPLATE.md
|
147
|
+
- MIT-LICENSE
|
148
|
+
- README.md
|
149
|
+
- Rakefile
|
150
|
+
- VERSION
|
151
|
+
- bin/defncopy-ttds
|
152
|
+
- bin/tsql-ttds
|
153
|
+
- docker-compose.yml
|
154
|
+
- exe/.keep
|
155
|
+
- ext/tiny_tds/client.c
|
156
|
+
- ext/tiny_tds/client.h
|
157
|
+
- ext/tiny_tds/extconf.rb
|
158
|
+
- ext/tiny_tds/extconsts.rb
|
159
|
+
- ext/tiny_tds/result.c
|
160
|
+
- ext/tiny_tds/result.h
|
161
|
+
- ext/tiny_tds/tiny_tds_ext.c
|
162
|
+
- ext/tiny_tds/tiny_tds_ext.h
|
163
|
+
- lib/tiny_tds.rb
|
164
|
+
- lib/tiny_tds/3.1/tiny_tds.so
|
165
|
+
- lib/tiny_tds/3.2/tiny_tds.so
|
166
|
+
- lib/tiny_tds/bin.rb
|
167
|
+
- lib/tiny_tds/client.rb
|
168
|
+
- lib/tiny_tds/error.rb
|
169
|
+
- lib/tiny_tds/gem.rb
|
170
|
+
- lib/tiny_tds/result.rb
|
171
|
+
- lib/tiny_tds/version.rb
|
172
|
+
- patches/freetds/1.00.27/0001-mingw_missing_inet_pton.diff
|
173
|
+
- patches/freetds/1.00.27/0002-Don-t-use-MSYS2-file-libws2_32.diff
|
174
|
+
- patches/libiconv/1.14/1-avoid-gets-error.patch
|
175
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/bin/bsqldb.exe
|
176
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/bin/datacopy.exe
|
177
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/bin/defncopy.exe
|
178
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/bin/freebcp.exe
|
179
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/bin/libct-4.dll
|
180
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/bin/libsybdb-5.dll
|
181
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/bin/osql
|
182
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/bin/tdspool.exe
|
183
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/bin/tsql.exe
|
184
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/lib/libct.dll.a
|
185
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/lib/libct.la
|
186
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/lib/libsybdb.dll.a
|
187
|
+
- ports/x64-mingw-ucrt/freetds/1.1.24/lib/libsybdb.la
|
188
|
+
- ports/x64-mingw-ucrt/libiconv/1.15/bin/iconv.exe
|
189
|
+
- ports/x64-mingw-ucrt/libiconv/1.15/bin/libcharset-1.dll
|
190
|
+
- ports/x64-mingw-ucrt/libiconv/1.15/bin/libiconv-2.dll
|
191
|
+
- ports/x64-mingw-ucrt/libiconv/1.15/lib/charset.alias
|
192
|
+
- ports/x64-mingw-ucrt/libiconv/1.15/lib/libcharset.dll.a
|
193
|
+
- ports/x64-mingw-ucrt/libiconv/1.15/lib/libcharset.la
|
194
|
+
- ports/x64-mingw-ucrt/libiconv/1.15/lib/libiconv.dll.a
|
195
|
+
- ports/x64-mingw-ucrt/libiconv/1.15/lib/libiconv.la
|
196
|
+
- ports/x64-mingw-ucrt/openssl/1.1.1s/bin/c_rehash
|
197
|
+
- ports/x64-mingw-ucrt/openssl/1.1.1s/bin/libcrypto-1_1-x64.dll
|
198
|
+
- ports/x64-mingw-ucrt/openssl/1.1.1s/bin/libssl-1_1-x64.dll
|
199
|
+
- ports/x64-mingw-ucrt/openssl/1.1.1s/bin/openssl.exe
|
200
|
+
- ports/x64-mingw-ucrt/openssl/1.1.1s/lib/libcrypto.a
|
201
|
+
- ports/x64-mingw-ucrt/openssl/1.1.1s/lib/libcrypto.dll.a
|
202
|
+
- ports/x64-mingw-ucrt/openssl/1.1.1s/lib/libssl.a
|
203
|
+
- ports/x64-mingw-ucrt/openssl/1.1.1s/lib/libssl.dll.a
|
204
|
+
- setup_cimgruby_dev.sh
|
205
|
+
- start_dev.sh
|
206
|
+
- tasks/native_gem.rake
|
207
|
+
- tasks/package.rake
|
208
|
+
- tasks/ports.rake
|
209
|
+
- tasks/ports/freetds.rb
|
210
|
+
- tasks/ports/libiconv.rb
|
211
|
+
- tasks/ports/openssl.rb
|
212
|
+
- tasks/ports/recipe.rb
|
213
|
+
- tasks/test.rake
|
214
|
+
- test/benchmark/query.rb
|
215
|
+
- test/benchmark/query_odbc.rb
|
216
|
+
- test/benchmark/query_tinytds.rb
|
217
|
+
- test/bin/install-freetds.sh
|
218
|
+
- test/bin/install-mssql.ps1
|
219
|
+
- test/bin/install-mssqltools.sh
|
220
|
+
- test/bin/install-openssl.sh
|
221
|
+
- test/bin/setup_tinytds_db.sh
|
222
|
+
- test/bin/setup_volume_permissions.sh
|
223
|
+
- test/client_test.rb
|
224
|
+
- test/gem_test.rb
|
225
|
+
- test/result_test.rb
|
226
|
+
- test/schema/1px.gif
|
227
|
+
- test/schema/sqlserver_2000.sql
|
228
|
+
- test/schema/sqlserver_2005.sql
|
229
|
+
- test/schema/sqlserver_2008.sql
|
230
|
+
- test/schema/sqlserver_2014.sql
|
231
|
+
- test/schema/sqlserver_2016.sql
|
232
|
+
- test/schema/sqlserver_azure.sql
|
233
|
+
- test/schema/sybase_ase.sql
|
234
|
+
- test/schema_test.rb
|
235
|
+
- test/sql/db-create.sql
|
236
|
+
- test/sql/db-login.sql
|
237
|
+
- test/test_helper.rb
|
238
|
+
- test/thread_test.rb
|
239
|
+
- tiny_tds.gemspec
|
240
|
+
homepage: http://github.com/rails-sqlserver/tiny_tds
|
241
|
+
licenses:
|
242
|
+
- MIT
|
243
|
+
metadata: {}
|
244
|
+
post_install_message:
|
245
|
+
rdoc_options:
|
246
|
+
- "--charset=UTF-8"
|
247
|
+
require_paths:
|
248
|
+
- lib
|
249
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
250
|
+
requirements:
|
251
|
+
- - ">="
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: '3.1'
|
254
|
+
- - "<"
|
255
|
+
- !ruby/object:Gem::Version
|
256
|
+
version: 3.3.dev
|
257
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
|
+
requirements:
|
259
|
+
- - ">="
|
260
|
+
- !ruby/object:Gem::Version
|
261
|
+
version: '0'
|
262
|
+
requirements: []
|
263
|
+
rubygems_version: 3.3.26
|
264
|
+
signing_key:
|
265
|
+
specification_version: 4
|
266
|
+
summary: TinyTDS - A modern, simple and fast FreeTDS library for Ruby using DB-Library.
|
267
|
+
test_files: []
|