tiny_tds 2.1.2-x64-mingw32 → 2.1.5-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -4
- data/CHANGELOG.md +20 -1
- data/README.md +31 -18
- data/VERSION +1 -1
- data/appveyor.yml +28 -7
- data/docker-compose.yml +22 -0
- data/ext/tiny_tds/client.c +90 -44
- data/ext/tiny_tds/client.h +5 -3
- data/ext/tiny_tds/extconf.rb +17 -13
- data/ext/tiny_tds/extconsts.rb +2 -2
- data/ext/tiny_tds/result.c +24 -10
- data/lib/tiny_tds/2.4/tiny_tds.so +0 -0
- data/lib/tiny_tds/2.5/tiny_tds.so +0 -0
- data/lib/tiny_tds/2.6/tiny_tds.so +0 -0
- data/lib/tiny_tds/2.7/tiny_tds.so +0 -0
- data/ports/x86_64-w64-mingw32/freetds/{1.00.27 → 1.1.24}/bin/bsqldb.exe +0 -0
- data/ports/x86_64-w64-mingw32/freetds/{1.00.27 → 1.1.24}/bin/datacopy.exe +0 -0
- data/ports/x86_64-w64-mingw32/freetds/{1.00.27 → 1.1.24}/bin/defncopy.exe +0 -0
- data/ports/x86_64-w64-mingw32/freetds/{1.00.27 → 1.1.24}/bin/freebcp.exe +0 -0
- data/ports/x86_64-w64-mingw32/freetds/1.1.24/bin/libct-4.dll +0 -0
- data/ports/x86_64-w64-mingw32/freetds/1.1.24/bin/libsybdb-5.dll +0 -0
- data/ports/x86_64-w64-mingw32/freetds/{1.00.27 → 1.1.24}/bin/osql +0 -0
- data/ports/x86_64-w64-mingw32/freetds/1.1.24/bin/tdspool.exe +0 -0
- data/ports/x86_64-w64-mingw32/freetds/1.1.24/bin/tsql.exe +0 -0
- data/ports/x86_64-w64-mingw32/freetds/{1.00.27 → 1.1.24}/lib/libct.dll.a +0 -0
- data/ports/x86_64-w64-mingw32/freetds/{1.00.27 → 1.1.24}/lib/libct.la +2 -2
- data/ports/x86_64-w64-mingw32/freetds/{1.00.27 → 1.1.24}/lib/libsybdb.dll.a +0 -0
- data/ports/x86_64-w64-mingw32/freetds/{1.00.27 → 1.1.24}/lib/libsybdb.la +2 -2
- data/ports/x86_64-w64-mingw32/libiconv/1.15/bin/iconv.exe +0 -0
- data/ports/x86_64-w64-mingw32/libiconv/1.15/bin/libcharset-1.dll +0 -0
- data/ports/x86_64-w64-mingw32/libiconv/1.15/bin/libiconv-2.dll +0 -0
- data/ports/x86_64-w64-mingw32/libiconv/1.15/lib/libcharset.dll.a +0 -0
- data/ports/x86_64-w64-mingw32/libiconv/1.15/lib/libcharset.la +2 -2
- data/ports/x86_64-w64-mingw32/libiconv/1.15/lib/libiconv.dll.a +0 -0
- data/ports/x86_64-w64-mingw32/libiconv/1.15/lib/libiconv.la +2 -2
- data/ports/x86_64-w64-mingw32/openssl/{1.1.0e → 1.1.1d}/bin/c_rehash +3 -3
- data/ports/x86_64-w64-mingw32/openssl/1.1.1d/bin/libcrypto-1_1-x64.dll +0 -0
- data/ports/x86_64-w64-mingw32/openssl/1.1.1d/bin/libssl-1_1-x64.dll +0 -0
- data/ports/x86_64-w64-mingw32/openssl/1.1.1d/bin/openssl.exe +0 -0
- data/ports/x86_64-w64-mingw32/openssl/1.1.1d/lib/libcrypto.a +0 -0
- data/ports/x86_64-w64-mingw32/openssl/{1.1.0e → 1.1.1d}/lib/libcrypto.dll.a +0 -0
- data/ports/x86_64-w64-mingw32/openssl/1.1.1d/lib/libssl.a +0 -0
- data/ports/x86_64-w64-mingw32/openssl/{1.1.0e → 1.1.1d}/lib/libssl.dll.a +0 -0
- data/tasks/native_gem.rake +1 -1
- data/tasks/ports/openssl.rb +2 -18
- data/tasks/ports.rake +5 -7
- data/test/client_test.rb +99 -54
- data/test/gem_test.rb +15 -15
- data/test/result_test.rb +83 -42
- data/test/schema_test.rb +12 -12
- data/test/test_helper.rb +58 -4
- data/test/thread_test.rb +1 -1
- data/tiny_tds.gemspec +3 -2
- metadata +47 -36
- data/BACKERS.md +0 -32
- data/lib/tiny_tds/2.0/tiny_tds.so +0 -0
- data/lib/tiny_tds/2.1/tiny_tds.so +0 -0
- data/lib/tiny_tds/2.2/tiny_tds.so +0 -0
- data/lib/tiny_tds/2.3/tiny_tds.so +0 -0
- data/ports/x86_64-w64-mingw32/freetds/1.00.27/bin/libct-4.dll +0 -0
- data/ports/x86_64-w64-mingw32/freetds/1.00.27/bin/libsybdb-5.dll +0 -0
- data/ports/x86_64-w64-mingw32/freetds/1.00.27/bin/tdspool.exe +0 -0
- data/ports/x86_64-w64-mingw32/freetds/1.00.27/bin/tsql.exe +0 -0
- data/ports/x86_64-w64-mingw32/openssl/1.1.0e/bin/libcrypto-1_1-x64.dll +0 -0
- data/ports/x86_64-w64-mingw32/openssl/1.1.0e/bin/libssl-1_1-x64.dll +0 -0
- data/ports/x86_64-w64-mingw32/openssl/1.1.0e/bin/openssl.exe +0 -0
- data/ports/x86_64-w64-mingw32/openssl/1.1.0e/lib/libcrypto.a +0 -0
- data/ports/x86_64-w64-mingw32/openssl/1.1.0e/lib/libssl.a +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67f523a732b6d4b9e39320e3331465de0f566cddec1049460c9b2bbb1d5fc8c8
|
4
|
+
data.tar.gz: f411a519c17e3a4ff53c187f84018ef3d0ebe516aaae2778ce18ef8fc6c21016
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46a60fddcfff07dbe8b7fe4c0a1aaf1520b9bcbeff5759dbcdade07b22b15cdf118fd8cf515f4750729c3e785a5d9a9fa7a463971a0b8229bfc030e1cea02650
|
7
|
+
data.tar.gz: 27cffc6e51817b4d8d828079f7495ad8c4b683fe272246aab792a48547866e7e183d9d3f1d14c85a3bfadf9ebea4fb8be8542e94c8518836ce3054a1a73b34d9
|
data/.travis.yml
CHANGED
@@ -8,14 +8,15 @@ env:
|
|
8
8
|
- TESTOPTS="-v"
|
9
9
|
- TINYTDS_UNIT_HOST=localhost
|
10
10
|
rvm:
|
11
|
-
- 2.
|
12
|
-
- 2.
|
13
|
-
- 2.
|
11
|
+
- 2.4.5
|
12
|
+
- 2.5.3
|
13
|
+
- 2.6.1
|
14
|
+
- 2.7.0
|
14
15
|
before_install:
|
15
16
|
- docker info
|
17
|
+
- docker-compose up -d
|
16
18
|
- sudo ./test/bin/install-openssl.sh
|
17
19
|
- sudo ./test/bin/install-freetds.sh
|
18
|
-
- sudo ./test/bin/setup.sh
|
19
20
|
install:
|
20
21
|
- gem install bundler
|
21
22
|
- bundle --version
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## (unreleased)
|
2
|
+
|
3
|
+
## 2.1.5
|
4
|
+
|
5
|
+
* Fix compilation errors for Amazon Linux 1. Fixes #495.
|
6
|
+
* Fix segfault for login timeouts
|
7
|
+
|
8
|
+
## 2.1.4
|
9
|
+
|
10
|
+
* Improve handling of network related timeouts
|
11
|
+
* Fix error reporting when preceded by info message
|
12
|
+
|
13
|
+
## 2.1.3
|
14
|
+
|
15
|
+
* Removed old/unused appveyor config
|
16
|
+
* Remove old Rubies from CI & cross compile list
|
17
|
+
* Add Ruby 2.6 and 2.7 to the cross compile list
|
18
|
+
|
1
19
|
## 2.1.2
|
2
20
|
|
3
21
|
* Use Kernel.BigDecimal vs BigDecimal.new. Fixes #409.
|
@@ -207,6 +225,8 @@ Use both dbsetversion() vs. dbsetlversion. Partially reverts #62.
|
|
207
225
|
state of the client and the need to use Result#cancel to stop processing active results. It is also
|
208
226
|
safe to call Result#cancel over and over again.
|
209
227
|
* Look for the syb headers only.
|
228
|
+
* Fix minitest global matchers warnings.
|
229
|
+
* Fix test warnings.
|
210
230
|
|
211
231
|
|
212
232
|
## 0.3.2
|
@@ -252,4 +272,3 @@ Use both dbsetversion() vs. dbsetlversion. Partially reverts #62.
|
|
252
272
|
|
253
273
|
|
254
274
|
## 0.1.0 Initial release!
|
255
|
-
|
data/README.md
CHANGED
@@ -3,13 +3,8 @@
|
|
3
3
|
* [![TravisCI](https://travis-ci.org/rails-sqlserver/tiny_tds.svg?branch=master)](https://travis-ci.org/rails-sqlserver/tiny_tds) - TravisCI
|
4
4
|
* [![Build Status](https://ci.appveyor.com/api/projects/status/g2bhhbsdkx0mal55/branch/master?svg=true)](https://ci.appveyor.com/project/rails-sqlserver/tiny-tds/branch/master) - Appveyor
|
5
5
|
* [![Gem Version](https://img.shields.io/gem/v/tiny_tds.svg)](https://rubygems.org/gems/tiny_tds) - Gem Version
|
6
|
-
* [![Dependency Status](https://dependencyci.com/github/rails-sqlserver/tiny_tds/badge)](https://dependencyci.com/github/rails-sqlserver/tiny_tds) - Dependency Status
|
7
6
|
* [![Gitter chat](https://img.shields.io/badge/%E2%8A%AA%20GITTER%20-JOIN%20CHAT%20%E2%86%92-brightgreen.svg?style=flat)](https://gitter.im/rails-sqlserver/activerecord-sqlserver-adapter) - Community
|
8
7
|
|
9
|
-
## Supporting TinyTDS/Adapter
|
10
|
-
|
11
|
-
Both TinyTDS and the Rails SQL Server Adapter are MIT-licensed open source projects. Its ongoing development is made possible thanks to the support by these awesome [backers](https://github.com/rails-sqlserver/tiny_tds/blob/master/BACKERS.md). If you'd like to join them, check out our [Patreon Campaign](https://www.patreon.com/metaskills).
|
12
|
-
|
13
8
|
|
14
9
|
## About TinyTDS
|
15
10
|
|
@@ -42,15 +37,15 @@ $ apt-get install wget
|
|
42
37
|
$ apt-get install build-essential
|
43
38
|
$ apt-get install libc6-dev
|
44
39
|
|
45
|
-
$ wget http://www.freetds.org/files/stable/freetds-1.
|
46
|
-
$ tar -xzf freetds-1.
|
47
|
-
$ cd freetds-1.
|
40
|
+
$ wget http://www.freetds.org/files/stable/freetds-1.1.24.tar.gz
|
41
|
+
$ tar -xzf freetds-1.1.24.tar.gz
|
42
|
+
$ cd freetds-1.1.24
|
48
43
|
$ ./configure --prefix=/usr/local --with-tdsver=7.3
|
49
44
|
$ make
|
50
45
|
$ make install
|
51
46
|
```
|
52
47
|
|
53
|
-
|
48
|
+
Please read the MiniPortile and/or Windows sections at the end of this file for advanced configuration options past the following:
|
54
49
|
|
55
50
|
```
|
56
51
|
--with-freetds-dir=DIR
|
@@ -73,11 +68,11 @@ TinyTDS is developed against FreeTDS 0.95, 0.99, and 1.0 current. Our default an
|
|
73
68
|
|
74
69
|
**NOTE:** Windows users of our pre-compiled native gems need not worry about installing FreeTDS and its dependencies.
|
75
70
|
|
76
|
-
* **Do I need to install FreeTDS?** Yes! Somehow, someway, you are going to need FreeTDS for TinyTDS to compile against.
|
71
|
+
* **Do I need to install FreeTDS?** Yes! Somehow, someway, you are going to need FreeTDS for TinyTDS to compile against.
|
77
72
|
|
78
73
|
* **OK, I am installing FreeTDS, how do I configure it?** Contrary to what most people think, you do not need to specially configure FreeTDS in any way for client libraries like TinyTDS to use it. About the only requirement is that you compile it with libiconv for proper encoding support. FreeTDS must also be compiled with OpenSSL (or the like) to use it with Azure. See the "Using TinyTDS with Azure" section below for more info.
|
79
74
|
|
80
|
-
* **Do I need to configure `--with-tdsver` equal to anything?** Most likely! Technically you should not have
|
75
|
+
* **Do I need to configure `--with-tdsver` equal to anything?** Most likely! Technically you should not have to. This is only a default for clients/configs that do not specify what TDS version they want to use. We are currently having issues with passing down a TDS version with the login bit. Till we get that fixed, if you are not using a freetds.conf or a TDSVER environment variable, then make sure to use 7.1.
|
81
76
|
|
82
77
|
* **But I want to use TDS version 7.2 for SQL Server 2005 and up!** TinyTDS uses TDS version 7.1 (previously named 8.0) and fully supports all the data types supported by FreeTDS, this includes `varchar(max)` and `nvarchar(max)`. Technically compiling and using TDS version 7.2 with FreeTDS is not supported. But this does not mean those data types will not work. I know, it's confusing If you want to learn more, read this thread. http://lists.ibiblio.org/pipermail/freetds/2011q3/027306.html
|
83
78
|
|
@@ -115,7 +110,7 @@ Creating a new client takes a hash of options. For valid iconv encoding options,
|
|
115
110
|
* :appname - Short string seen in SQL Servers process/activity window.
|
116
111
|
* :tds_version - TDS version. Defaults to "7.3".
|
117
112
|
* :login_timeout - Seconds to wait for login. Default to 60 seconds.
|
118
|
-
* :timeout - Seconds to wait for a response to a SQL command. Default 5 seconds. Prior to 1.0rc5, FreeTDS was unable to set the timeout on a per-client basis, permitting only a global timeout value. This means that if you're using an older version, the timeout values for all clients will be overwritten each time you instantiate a new `TinyTds::Client` object. If you are using 1.0rc5 or later, all clients will have an independent timeout setting as you'd expect.
|
113
|
+
* :timeout - Seconds to wait for a response to a SQL command. Default 5 seconds. Prior to 1.0rc5, FreeTDS was unable to set the timeout on a per-client basis, permitting only a global timeout value. This means that if you're using an older version, the timeout values for all clients will be overwritten each time you instantiate a new `TinyTds::Client` object. If you are using 1.0rc5 or later, all clients will have an independent timeout setting as you'd expect. Timeouts caused by network failure will raise a timeout error 1 second after the configured timeout limit is hit (see [#481](https://github.com/rails-sqlserver/tiny_tds/pull/481) for details).
|
119
114
|
* :encoding - Any valid iconv value like CP1251 or ISO-8859-1. Default UTF-8.
|
120
115
|
* :azure - Pass true to signal that you are connecting to azure.
|
121
116
|
* :contained - Pass true to signal that you are connecting with a contained database user.
|
@@ -327,9 +322,13 @@ By default row caching is turned on because the SQL Server adapter for ActiveRec
|
|
327
322
|
TinyTDS takes an opinionated stance on how we handle encoding errors. First, we treat errors differently on reads vs. writes. Our opinion is that if you are reading bad data due to your client's encoding option, you would rather just find `?` marks in your strings vs being blocked with exceptions. This is how things wold work via ODBC or SMS. On the other hand, writes will raise an exception. In this case we raise the SYBEICONVO/2402 error message which has a description of `Error converting characters into server's character set. Some character(s) could not be converted.`. Even though the severity of this message is only a `4` and TinyTDS will automatically strip/ignore unknown characters, we feel you should know that you are inserting bad encodings. In this way, a transaction can be rolled back, etc. Remember, any database write that has bad characters due to the client encoding will still be written to the database, but it is up to you rollback said write if needed. Most ORMs like ActiveRecord handle this scenario just fine.
|
328
323
|
|
329
324
|
|
325
|
+
## Timeout Error Handling
|
326
|
+
|
327
|
+
TinyTDS will raise a `TinyTDS::Error` when a timeout is reached based on the options supplied to the client. Depending on the reason for the timeout, the connection could be dead or alive. When db processing is the cause for the timeout, the connection should still be usable after the error is raised. When network failure is the cause of the timeout, the connection will be dead. If you attempt to execute another command batch on a dead connection you will see a `DBPROCESS is dead or not enabled` error. Therefore, it is recommended to check for a `dead?` connection before trying to execute another command batch.
|
328
|
+
|
330
329
|
## Binstubs
|
331
330
|
|
332
|
-
The TinyTDS gem uses binstub wrappers which mirror compiled [FreeTDS Utilities](
|
331
|
+
The TinyTDS gem uses binstub wrappers which mirror compiled [FreeTDS Utilities](https://www.freetds.org/userguide/usefreetds.html) binaries. These native executables are usually installed at the system level when installing FreeTDS. However, when using MiniPortile to install TinyTDS as we do with Windows binaries, these binstubs will find and prefer local gem `exe` directory executables. These are the following binstubs we wrap.
|
333
332
|
|
334
333
|
* tsql - Used to test connections and debug compile time settings.
|
335
334
|
* defncopy - Used to dump schema structures.
|
@@ -405,7 +404,7 @@ The default is true and since FreeTDS v1.0 would do this as well.
|
|
405
404
|
|
406
405
|
## Compiling Gems for Windows
|
407
406
|
|
408
|
-
For the convenience of Windows users, TinyTDS ships pre-compiled gems for
|
407
|
+
For the convenience of Windows users, TinyTDS ships pre-compiled gems for supported versions of Ruby on Windows. In order to generate these gems, [rake-compiler-dock](https://github.com/rake-compiler/rake-compiler-dock) is used. This project provides several [Docker images](https://registry.hub.docker.com/u/larskanis/) with rvm, cross-compilers and a number of different target versions of Ruby.
|
409
408
|
|
410
409
|
Run the following rake task to compile the gems for Windows. This will check the availability of [Docker](https://www.docker.com/) (and boot2docker on Windows or OS-X) and will give some advice for download and installation. When docker is running, it will download the docker image (once-only) and start the build:
|
411
410
|
|
@@ -424,17 +423,20 @@ First, clone the repo using the command line or your Git GUI of choice.
|
|
424
423
|
$ git clone git@github.com:rails-sqlserver/tiny_tds.git
|
425
424
|
```
|
426
425
|
|
427
|
-
After that, the quickest way to get setup for development is to use [Docker](https://www.docker.com/). Assuming you have [downloaded docker](https://www.docker.com/products/docker) for your platform
|
426
|
+
After that, the quickest way to get setup for development is to use [Docker](https://www.docker.com/). Assuming you have [downloaded docker](https://www.docker.com/products/docker) for your platform, you can use [docker-compose](https://docs.docker.com/compose/install/) to run the necessary containers for testing.
|
428
427
|
|
429
428
|
```shell
|
430
|
-
$
|
429
|
+
$ docker-compose up -d
|
431
430
|
```
|
432
431
|
|
433
|
-
This will download our SQL Server for Linux Docker image based from [microsoft/mssql-server-linux/](https://hub.docker.com/r/microsoft/mssql-server-linux/). Our image already has the `[tinytdstest]` DB and `tinytds` users created. Basically, it does the following.
|
432
|
+
This will download our SQL Server for Linux Docker image based from [microsoft/mssql-server-linux/](https://hub.docker.com/r/microsoft/mssql-server-linux/). Our image already has the `[tinytdstest]` DB and `tinytds` users created. This will also download a [toxiproxy](https://github.com/shopify/toxiproxy) Docker image which we can use to simulate network failures for tests. Basically, it does the following.
|
434
433
|
|
435
434
|
```shell
|
435
|
+
$ docker network create main-network
|
436
436
|
$ docker pull metaskills/mssql-server-linux-tinytds
|
437
|
-
$ docker run -p 1433:1433 -d metaskills/mssql-server-linux-tinytds
|
437
|
+
$ docker run -p 1433:1433 -d --name sqlserver --network main-network metaskills/mssql-server-linux-tinytds
|
438
|
+
$ docker pull shopify/toxiproxy
|
439
|
+
$ docker run -p 8474:8474 -p 1234:1234 -d --name toxiproxy --network main-network shopify/toxiproxy
|
438
440
|
```
|
439
441
|
|
440
442
|
If you are using your own database. Make sure to run these SQL commands as SA to get the test database and user installed.
|
@@ -466,6 +468,17 @@ $ rake TINYTDS_UNIT_HOST=mydb.host.net TINYTDS_SCHEMA=sqlserver_azure
|
|
466
468
|
$ rake TINYTDS_UNIT_HOST=mydb.host.net TINYTDS_UNIT_PORT=5000 TINYTDS_SCHEMA=sybase_ase
|
467
469
|
```
|
468
470
|
|
471
|
+
## Docker Builds
|
472
|
+
|
473
|
+
If you use a [multi stage](https://docs.docker.com/develop/develop-images/multistage-build/) Docker build to assemble your gems in one phase and then copy your app and gems
|
474
|
+
into another, lighter, container without build tools you will need to make sure you tell the OS how to find dependencies for TinyTDS.
|
475
|
+
|
476
|
+
After you have built and installed FreeTDS it will normally place library files in `/usr/local/lib`. When TinyTDS builds native extensions,
|
477
|
+
it [already knows to look here](https://github.com/rails-sqlserver/tiny_tds/blob/master/ext/tiny_tds/extconf.rb#L31) but if you copy your app to a new container that link will be broken.
|
478
|
+
|
479
|
+
Set the LD_LIBRARY_PATH environment variable `export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}` and run `ldconfig`. If you run `ldd tiny_tds.so` you should not see any broken links. Make
|
480
|
+
sure you also copied in the library dependencies from your build container with a command like `COPY --from=builder /usr/local/lib /usr/local/lib`.
|
481
|
+
|
469
482
|
## Help & Support
|
470
483
|
|
471
484
|
* Github Source: http://github.com/rails-sqlserver/tiny_tds
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.5
|
data/appveyor.yml
CHANGED
@@ -1,21 +1,41 @@
|
|
1
1
|
init:
|
2
2
|
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
3
|
-
- SET PATH=C:\MinGW\msys\1.0\bin;%PATH%
|
4
3
|
- SET RAKEOPT=-rdevkit
|
5
4
|
- SET TESTOPTS='-v'
|
6
|
-
- SET MAKE=make V=1
|
5
|
+
- SET MAKE=make V=1 -j2
|
7
6
|
clone_depth: 5
|
8
7
|
skip_tags: true
|
9
8
|
skip_branch_with_pr: true
|
10
9
|
matrix:
|
11
|
-
fast_finish:
|
10
|
+
fast_finish: false
|
12
11
|
install:
|
13
12
|
# Output debugging info
|
14
13
|
- ps: Update-AppveyorBuild -Version "$(Get-Content $env:appveyor_build_folder\VERSION).$env:appveyor_build_number"
|
14
|
+
- ps: |
|
15
|
+
if ($env:ruby_version -like "*head*") {
|
16
|
+
$(new-object net.webclient).DownloadFile("https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-$env:ruby_version.exe", "$pwd/ruby-setup.exe")
|
17
|
+
cmd /c ruby-setup.exe /verysilent /dir=C:/Ruby$env:ruby_version
|
18
|
+
}
|
15
19
|
- perl --version
|
16
20
|
- ruby --version
|
17
21
|
- gem --version
|
18
|
-
|
22
|
+
# Update keyring according to https://www.msys2.org/news/#2020-06-29-new-packagers
|
23
|
+
- C:\msys64\usr\bin\curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz
|
24
|
+
- C:\msys64\usr\bin\curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig
|
25
|
+
- ridk exec bash -c "pacman-key --verify msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig"
|
26
|
+
- ridk exec bash -c "pacman -U --noconfirm --config <(echo) msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz"
|
27
|
+
# Update zstd and pacman first https://github.com/msys2/MSYS2-packages/issues/2300
|
28
|
+
- C:\msys64\usr\bin\pacman --noconfirm --upgrade https://repo.msys2.org/msys/x86_64/zstd-1.4.7-1-x86_64.pkg.tar.xz # Must come First, or else pacman will install 1.4.8
|
29
|
+
- C:\msys64\usr\bin\pacman --noconfirm --upgrade https://repo.msys2.org/msys/x86_64/pacman-5.2.2-5-x86_64.pkg.tar.xz
|
30
|
+
# update packages
|
31
|
+
- C:\msys64\usr\bin\pacman --noconfirm --ask 20 --sync --refresh --refresh --sysupgrade --sysupgrade
|
32
|
+
# Kill all running msys2 binaries to avoid error "size of shared memory region changed".
|
33
|
+
# See https://github.com/msys2/MSYS2-packages/issues/258
|
34
|
+
- powershell -Command "Get-Process | Where-Object {$_.path -like 'C:\msys64*'} | Stop-Process"
|
35
|
+
# refresh the package list to avoid "error: failed to prepare transaction (could not find database)"
|
36
|
+
- ridk exec bash -c "pacman --noconfirm -Sy"
|
37
|
+
# prevent freetds to link to wrong ws2_32 lib on i686-w64-mingw32
|
38
|
+
- c:/msys64/usr/bin/rm /usr/lib/w32api/libws2_32.a
|
19
39
|
# Set up project prerequisits
|
20
40
|
- bundle install
|
21
41
|
- bundle exec rake ports
|
@@ -43,9 +63,10 @@ environment:
|
|
43
63
|
TINYTDS_UNIT_AZURE_PASS:
|
44
64
|
secure: fYKSKV4v+36OFQp2nZdX4DfUpgmy5cm0wuR73cgdmEk=
|
45
65
|
matrix:
|
46
|
-
- ruby_version: "24-x64"
|
47
66
|
- ruby_version: "24"
|
48
|
-
- ruby_version: "
|
49
|
-
- ruby_version: "
|
67
|
+
- ruby_version: "25-x64"
|
68
|
+
- ruby_version: "26"
|
69
|
+
- ruby_version: "head-x64"
|
50
70
|
on_failure:
|
71
|
+
- find -name config.log | xargs cat
|
51
72
|
- find -name compile.log | xargs cat
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
version: '3'
|
2
|
+
|
3
|
+
networks:
|
4
|
+
main-network:
|
5
|
+
|
6
|
+
services:
|
7
|
+
mssql:
|
8
|
+
image: metaskills/mssql-server-linux-tinytds:2017-GA
|
9
|
+
container_name: sqlserver
|
10
|
+
ports:
|
11
|
+
- "1433:1433"
|
12
|
+
networks:
|
13
|
+
- main-network
|
14
|
+
|
15
|
+
toxiproxy:
|
16
|
+
image: shopify/toxiproxy
|
17
|
+
container_name: toxiproxy
|
18
|
+
ports:
|
19
|
+
- "8474:8474"
|
20
|
+
- "1234:1234"
|
21
|
+
networks:
|
22
|
+
- main-network
|
data/ext/tiny_tds/client.c
CHANGED
@@ -24,25 +24,25 @@ VALUE opt_escape_regex, opt_escape_dblquote;
|
|
24
24
|
|
25
25
|
// Lib Backend (Helpers)
|
26
26
|
|
27
|
-
VALUE rb_tinytds_raise_error(DBPROCESS *dbproc,
|
27
|
+
VALUE rb_tinytds_raise_error(DBPROCESS *dbproc, tinytds_errordata error) {
|
28
28
|
VALUE e;
|
29
29
|
GET_CLIENT_USERDATA(dbproc);
|
30
|
-
if (cancel && !dbdead(dbproc) && userdata && !userdata->closed) {
|
30
|
+
if (error.cancel && !dbdead(dbproc) && userdata && !userdata->closed) {
|
31
31
|
userdata->dbsqlok_sent = 1;
|
32
32
|
dbsqlok(dbproc);
|
33
33
|
userdata->dbcancel_sent = 1;
|
34
34
|
dbcancel(dbproc);
|
35
35
|
}
|
36
|
-
e = rb_exc_new2(cTinyTdsError, error);
|
37
|
-
rb_funcall(e, intern_source_eql, 1, rb_str_new2(source));
|
38
|
-
if (severity)
|
39
|
-
rb_funcall(e, intern_severity_eql, 1, INT2FIX(severity));
|
40
|
-
if (dberr)
|
41
|
-
rb_funcall(e, intern_db_error_number_eql, 1, INT2FIX(dberr));
|
42
|
-
if (oserr)
|
43
|
-
rb_funcall(e, intern_os_error_number_eql, 1, INT2FIX(oserr));
|
44
|
-
|
45
|
-
if (severity <= 10 && is_message) {
|
36
|
+
e = rb_exc_new2(cTinyTdsError, error.error);
|
37
|
+
rb_funcall(e, intern_source_eql, 1, rb_str_new2(error.source));
|
38
|
+
if (error.severity)
|
39
|
+
rb_funcall(e, intern_severity_eql, 1, INT2FIX(error.severity));
|
40
|
+
if (error.dberr)
|
41
|
+
rb_funcall(e, intern_db_error_number_eql, 1, INT2FIX(error.dberr));
|
42
|
+
if (error.oserr)
|
43
|
+
rb_funcall(e, intern_os_error_number_eql, 1, INT2FIX(error.oserr));
|
44
|
+
|
45
|
+
if (error.severity <= 10 && error.is_message) {
|
46
46
|
VALUE message_handler = userdata && userdata->message_handler ? userdata->message_handler : Qnil;
|
47
47
|
if (message_handler && message_handler != Qnil && rb_respond_to(message_handler, intern_call) != 0) {
|
48
48
|
rb_funcall(message_handler, intern_call, 1, e);
|
@@ -57,6 +57,16 @@ VALUE rb_tinytds_raise_error(DBPROCESS *dbproc, int is_message, int cancel, cons
|
|
57
57
|
|
58
58
|
|
59
59
|
// Lib Backend (Memory Management & Handlers)
|
60
|
+
static void push_userdata_error(tinytds_client_userdata *userdata, tinytds_errordata error) {
|
61
|
+
// reallocate memory for the array as needed
|
62
|
+
if (userdata->nonblocking_errors_size == userdata->nonblocking_errors_length) {
|
63
|
+
userdata->nonblocking_errors_size *= 2;
|
64
|
+
userdata->nonblocking_errors = realloc(userdata->nonblocking_errors, userdata->nonblocking_errors_size * sizeof(tinytds_errordata));
|
65
|
+
}
|
66
|
+
|
67
|
+
userdata->nonblocking_errors[userdata->nonblocking_errors_length] = error;
|
68
|
+
userdata->nonblocking_errors_length++;
|
69
|
+
}
|
60
70
|
|
61
71
|
int tinytds_err_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) {
|
62
72
|
static const char *source = "error";
|
@@ -86,6 +96,13 @@ int tinytds_err_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, c
|
|
86
96
|
but we don't ever want to automatically retry. Instead have the app
|
87
97
|
decide what to do.
|
88
98
|
*/
|
99
|
+
if (userdata && userdata->timing_out) {
|
100
|
+
return INT_CANCEL;
|
101
|
+
}
|
102
|
+
// userdata will not be set if hitting timeout during login so check for it first
|
103
|
+
if (userdata) {
|
104
|
+
userdata->timing_out = 1;
|
105
|
+
}
|
89
106
|
return_value = INT_TIMEOUT;
|
90
107
|
cancel = 1;
|
91
108
|
break;
|
@@ -99,6 +116,16 @@ int tinytds_err_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, c
|
|
99
116
|
break;
|
100
117
|
}
|
101
118
|
|
119
|
+
tinytds_errordata error_data = {
|
120
|
+
.is_message = 0,
|
121
|
+
.cancel = cancel,
|
122
|
+
.severity = severity,
|
123
|
+
.dberr = dberr,
|
124
|
+
.oserr = oserr
|
125
|
+
};
|
126
|
+
strncpy(error_data.error, dberrstr, ERROR_MSG_SIZE);
|
127
|
+
strncpy(error_data.source, source, ERROR_MSG_SIZE);
|
128
|
+
|
102
129
|
/*
|
103
130
|
When in non-blocking mode we need to store the exception data to throw it
|
104
131
|
once the blocking call returns, otherwise we will segfault ruby since part
|
@@ -110,27 +137,9 @@ int tinytds_err_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, c
|
|
110
137
|
dbcancel(dbproc);
|
111
138
|
userdata->dbcancel_sent = 1;
|
112
139
|
}
|
113
|
-
|
114
|
-
/*
|
115
|
-
If we've already captured an error message, don't overwrite it. This is
|
116
|
-
here because FreeTDS sends a generic "General SQL Server error" message
|
117
|
-
that will overwrite the real message. This is not normally a problem
|
118
|
-
because a ruby exception is normally thrown and we bail before the
|
119
|
-
generic message can be sent.
|
120
|
-
*/
|
121
|
-
if (!userdata->nonblocking_error.is_set) {
|
122
|
-
userdata->nonblocking_error.is_message = 0;
|
123
|
-
userdata->nonblocking_error.cancel = cancel;
|
124
|
-
strncpy(userdata->nonblocking_error.error, dberrstr, ERROR_MSG_SIZE);
|
125
|
-
strncpy(userdata->nonblocking_error.source, source, ERROR_MSG_SIZE);
|
126
|
-
userdata->nonblocking_error.severity = severity;
|
127
|
-
userdata->nonblocking_error.dberr = dberr;
|
128
|
-
userdata->nonblocking_error.oserr = oserr;
|
129
|
-
userdata->nonblocking_error.is_set = 1;
|
130
|
-
}
|
131
|
-
|
140
|
+
push_userdata_error(userdata, error_data);
|
132
141
|
} else {
|
133
|
-
rb_tinytds_raise_error(dbproc,
|
142
|
+
rb_tinytds_raise_error(dbproc, error_data);
|
134
143
|
}
|
135
144
|
|
136
145
|
return return_value;
|
@@ -142,36 +151,72 @@ int tinytds_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severi
|
|
142
151
|
|
143
152
|
int is_message_an_error = severity > 10 ? 1 : 0;
|
144
153
|
|
154
|
+
tinytds_errordata error_data = {
|
155
|
+
.is_message = !is_message_an_error,
|
156
|
+
.cancel = is_message_an_error,
|
157
|
+
.severity = severity,
|
158
|
+
.dberr = msgno,
|
159
|
+
.oserr = msgstate
|
160
|
+
};
|
161
|
+
strncpy(error_data.error, msgtext, ERROR_MSG_SIZE);
|
162
|
+
strncpy(error_data.source, source, ERROR_MSG_SIZE);
|
163
|
+
|
145
164
|
// See tinytds_err_handler() for info about why we do this
|
146
165
|
if (userdata && userdata->nonblocking) {
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
userdata->nonblocking_error.dberr = msgno;
|
154
|
-
userdata->nonblocking_error.oserr = msgstate;
|
155
|
-
userdata->nonblocking_error.is_set = 1;
|
156
|
-
}
|
166
|
+
/*
|
167
|
+
In the case of non-blocking command batch execution we can receive multiple messages
|
168
|
+
(including errors). We keep track of those here so they can be processed once the
|
169
|
+
non-blocking call returns.
|
170
|
+
*/
|
171
|
+
push_userdata_error(userdata, error_data);
|
157
172
|
|
158
173
|
if (is_message_an_error && !dbdead(dbproc) && !userdata->closed) {
|
159
174
|
dbcancel(dbproc);
|
160
175
|
userdata->dbcancel_sent = 1;
|
161
176
|
}
|
162
177
|
} else {
|
163
|
-
rb_tinytds_raise_error(dbproc,
|
178
|
+
rb_tinytds_raise_error(dbproc, error_data);
|
164
179
|
}
|
165
180
|
return 0;
|
166
181
|
}
|
167
182
|
|
183
|
+
/*
|
184
|
+
Used by dbsetinterrupt -
|
185
|
+
This gets called periodically while waiting on a read from the server
|
186
|
+
Right now, we only care about cases where a read from the server is
|
187
|
+
taking longer than the specified timeout and dbcancel is not working.
|
188
|
+
In these cases we decide that we actually want to handle the interrupt
|
189
|
+
*/
|
190
|
+
static int check_interrupt(void *ptr) {
|
191
|
+
GET_CLIENT_USERDATA((DBPROCESS *)ptr);
|
192
|
+
return userdata->timing_out;
|
193
|
+
}
|
194
|
+
|
195
|
+
/*
|
196
|
+
Used by dbsetinterrupt -
|
197
|
+
This gets called if check_interrupt returns TRUE.
|
198
|
+
Right now, this is only used in cases where a read from the server is
|
199
|
+
taking longer than the specified timeout and dbcancel is not working.
|
200
|
+
Return INT_CANCEL to abort the current command batch.
|
201
|
+
*/
|
202
|
+
static int handle_interrupt(void *ptr) {
|
203
|
+
GET_CLIENT_USERDATA((DBPROCESS *)ptr);
|
204
|
+
if (userdata->timing_out) {
|
205
|
+
return INT_CANCEL;
|
206
|
+
}
|
207
|
+
return INT_CONTINUE;
|
208
|
+
}
|
209
|
+
|
168
210
|
static void rb_tinytds_client_reset_userdata(tinytds_client_userdata *userdata) {
|
169
211
|
userdata->timing_out = 0;
|
170
212
|
userdata->dbsql_sent = 0;
|
171
213
|
userdata->dbsqlok_sent = 0;
|
172
214
|
userdata->dbcancel_sent = 0;
|
173
215
|
userdata->nonblocking = 0;
|
174
|
-
|
216
|
+
// the following is mainly done for consistency since the values are reset accordingly in nogvl_setup/cleanup.
|
217
|
+
// the nonblocking_errors array does not need to be freed here. That is done as part of nogvl_cleanup.
|
218
|
+
userdata->nonblocking_errors_length = 0;
|
219
|
+
userdata->nonblocking_errors_size = 0;
|
175
220
|
}
|
176
221
|
|
177
222
|
static void rb_tinytds_client_mark(void *ptr) {
|
@@ -381,6 +426,7 @@ static VALUE rb_tinytds_connect(VALUE self, VALUE opts) {
|
|
381
426
|
}
|
382
427
|
}
|
383
428
|
dbsetuserdata(cwrap->client, (BYTE*)cwrap->userdata);
|
429
|
+
dbsetinterrupt(cwrap->client, check_interrupt, handle_interrupt);
|
384
430
|
cwrap->userdata->closed = 0;
|
385
431
|
if (!NIL_P(database) && (azure != Qtrue)) {
|
386
432
|
dbuse(cwrap->client, StringValueCStr(database));
|
data/ext/tiny_tds/client.h
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
void init_tinytds_client();
|
6
6
|
|
7
7
|
#define ERROR_MSG_SIZE 1024
|
8
|
+
#define ERRORS_STACK_INIT_SIZE 2
|
8
9
|
|
9
10
|
typedef struct {
|
10
|
-
short int is_set;
|
11
11
|
int is_message;
|
12
12
|
int cancel;
|
13
13
|
char error[ERROR_MSG_SIZE];
|
@@ -25,7 +25,9 @@ typedef struct {
|
|
25
25
|
RETCODE dbsqlok_retcode;
|
26
26
|
short int dbcancel_sent;
|
27
27
|
short int nonblocking;
|
28
|
-
|
28
|
+
short int nonblocking_errors_length;
|
29
|
+
short int nonblocking_errors_size;
|
30
|
+
tinytds_errordata *nonblocking_errors;
|
29
31
|
VALUE message_handler;
|
30
32
|
} tinytds_client_userdata;
|
31
33
|
|
@@ -40,7 +42,7 @@ typedef struct {
|
|
40
42
|
rb_encoding *encoding;
|
41
43
|
} tinytds_client_wrapper;
|
42
44
|
|
43
|
-
VALUE rb_tinytds_raise_error(DBPROCESS *dbproc,
|
45
|
+
VALUE rb_tinytds_raise_error(DBPROCESS *dbproc, tinytds_errordata error);
|
44
46
|
|
45
47
|
// Lib Macros
|
46
48
|
|
data/ext/tiny_tds/extconf.rb
CHANGED
@@ -22,35 +22,39 @@ do_help if arg_config('--help')
|
|
22
22
|
|
23
23
|
# Make sure to check the ports path for the configured host
|
24
24
|
host = RbConfig::CONFIG['host']
|
25
|
-
project_dir = File.
|
25
|
+
project_dir = File.expand_path("../../..", __FILE__)
|
26
26
|
freetds_ports_dir = File.join(project_dir, 'ports', host, 'freetds', FREETDS_VERSION)
|
27
27
|
freetds_ports_dir = File.expand_path(freetds_ports_dir)
|
28
28
|
|
29
29
|
# Add all the special path searching from the original tiny_tds build
|
30
|
-
# order is important here! First in,
|
30
|
+
# order is important here! First in, first searched.
|
31
31
|
DIRS = %w(
|
32
|
-
/usr/local
|
33
32
|
/opt/local
|
33
|
+
/usr/local
|
34
34
|
)
|
35
35
|
|
36
|
+
# Add the ports directory if it exists for local developer builds
|
37
|
+
DIRS.unshift(freetds_ports_dir) if File.directory?(freetds_ports_dir)
|
38
|
+
|
36
39
|
# Grab freetds environment variable for use by people on services like
|
37
40
|
# Heroku who they can't easily use bundler config to set directories
|
38
|
-
DIRS.
|
39
|
-
|
40
|
-
# Add the ports directory if it exists for local developer builds
|
41
|
-
DIRS.push(freetds_ports_dir) if File.directory?(freetds_ports_dir)
|
41
|
+
DIRS.unshift(ENV['FREETDS_DIR']) if ENV.has_key?('FREETDS_DIR')
|
42
42
|
|
43
43
|
# Add the search paths for freetds configured above
|
44
|
-
DIRS.
|
45
|
-
idir = "#{path}/include"
|
44
|
+
ldirs = DIRS.flat_map do |path|
|
46
45
|
ldir = "#{path}/lib"
|
46
|
+
[ldir, "#{ldir}/freetds"]
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
)
|
49
|
+
idirs = DIRS.flat_map do |path|
|
50
|
+
idir = "#{path}/include"
|
51
|
+
[idir, "#{idir}/freetds"]
|
52
52
|
end
|
53
53
|
|
54
|
+
puts "looking for freetds headers in the following directories:\n#{idirs.map{|a| " - #{a}\n"}.join}"
|
55
|
+
puts "looking for freetds library in the following directories:\n#{ldirs.map{|a| " - #{a}\n"}.join}"
|
56
|
+
dir_config('freetds', idirs, ldirs)
|
57
|
+
|
54
58
|
have_dependencies = [
|
55
59
|
find_header('sybfront.h'),
|
56
60
|
find_header('sybdb.h'),
|
data/ext/tiny_tds/extconsts.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
ICONV_VERSION = ENV['TINYTDS_ICONV_VERSION'] || "1.15"
|
3
3
|
ICONV_SOURCE_URI = "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-#{ICONV_VERSION}.tar.gz"
|
4
4
|
|
5
|
-
OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.1.
|
5
|
+
OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.1.1d'
|
6
6
|
OPENSSL_SOURCE_URI = "https://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz"
|
7
7
|
|
8
|
-
FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "1.
|
8
|
+
FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "1.1.24"
|
9
9
|
FREETDS_VERSION_INFO = Hash.new { |h,k|
|
10
10
|
h[k] = {files: "http://www.freetds.org/files/stable/freetds-#{k}.tar.bz2"}
|
11
11
|
}
|
data/ext/tiny_tds/result.c
CHANGED
@@ -86,26 +86,40 @@ static void dbcancel_ubf(DBPROCESS *client) {
|
|
86
86
|
static void nogvl_setup(DBPROCESS *client) {
|
87
87
|
GET_CLIENT_USERDATA(client);
|
88
88
|
userdata->nonblocking = 1;
|
89
|
+
userdata->nonblocking_errors_length = 0;
|
90
|
+
userdata->nonblocking_errors = malloc(ERRORS_STACK_INIT_SIZE * sizeof(tinytds_errordata));
|
91
|
+
userdata->nonblocking_errors_size = ERRORS_STACK_INIT_SIZE;
|
89
92
|
}
|
90
93
|
|
91
94
|
static void nogvl_cleanup(DBPROCESS *client) {
|
92
95
|
GET_CLIENT_USERDATA(client);
|
93
96
|
userdata->nonblocking = 0;
|
97
|
+
userdata->timing_out = 0;
|
94
98
|
/*
|
95
99
|
Now that the blocking operation is done, we can finally throw any
|
96
100
|
exceptions based on errors from SQL Server.
|
97
101
|
*/
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
userdata->
|
106
|
-
|
107
|
-
|
102
|
+
short int i;
|
103
|
+
for (i = 0; i < userdata->nonblocking_errors_length; i++) {
|
104
|
+
tinytds_errordata error = userdata->nonblocking_errors[i];
|
105
|
+
|
106
|
+
// lookahead to drain any info messages ahead of raising error
|
107
|
+
if (!error.is_message) {
|
108
|
+
short int j;
|
109
|
+
for (j = i; j < userdata->nonblocking_errors_length; j++) {
|
110
|
+
tinytds_errordata msg_error = userdata->nonblocking_errors[j];
|
111
|
+
if (msg_error.is_message) {
|
112
|
+
rb_tinytds_raise_error(client, msg_error);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
rb_tinytds_raise_error(client, error);
|
108
118
|
}
|
119
|
+
|
120
|
+
free(userdata->nonblocking_errors);
|
121
|
+
userdata->nonblocking_errors_length = 0;
|
122
|
+
userdata->nonblocking_errors_size = 0;
|
109
123
|
}
|
110
124
|
|
111
125
|
static RETCODE nogvl_dbsqlok(DBPROCESS *client) {
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|