diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a93cea8..634a249 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,13 +20,32 @@ jobs: build: name: Build runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + goos: + - windows + - linux + - darwin + goarch: + - amd64 + - '386' + - arm + - arm64 steps: - uses: actions/setup-go@v3 + if: ${{ !(matrix.goos == 'darwin' && (matrix.goarch == '386' || matrix.goarch == 'arm')) }} with: go-version: ${{ env.GO_VERSION }} - uses: actions/checkout@v3 + if: ${{ !(matrix.goos == 'darwin' && (matrix.goarch == '386' || matrix.goarch == 'arm')) }} - run: go mod download + if: ${{ !(matrix.goos == 'darwin' && (matrix.goarch == '386' || matrix.goarch == 'arm')) }} - run: go build -v . + if: ${{ !(matrix.goos == 'darwin' && (matrix.goarch == '386' || matrix.goarch == 'arm')) }} + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} generate: runs-on: ubuntu-latest @@ -68,6 +87,6 @@ jobs: TF_MSSQL_IMG_TAG: ${{ matrix.mssql }} TF_AZURE_SUBSCRIPTION_ID: fbf513eb-321c-40b8-8dbb-bb939ea1fe5a TF_AZURE_RESOURCE_GROUP: terraform-mssql-tests - AZURE_CLIENT_ID: 874f61a5-e5c1-4811-b6bf-e6a1135bea5a - AZURE_TENANT_ID: b3e5a293-6975-4239-9637-c963e8d90b7a + AZURE_CLIENT_ID: 139df37c-3e72-4283-80c1-7be62f3d8e64 + AZURE_TENANT_ID: 7029fc72-c85c-4ecd-86f6-1ab9852b576f AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index 91e4935..99aa95e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -18,8 +18,6 @@ builds: ignore: - goos: darwin goarch: '386' - - goos: windows - goarch: arm binary: '{{ .ProjectName }}_v{{ .Version }}' archives: diff --git a/deps/go-mssqldb/.github/workflows/pr-validation.yml b/deps/go-mssqldb/.github/workflows/pr-validation.yml deleted file mode 100644 index 8c3a92c..0000000 --- a/deps/go-mssqldb/.github/workflows/pr-validation.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: pr-validation - -on: - pull_request: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - go: ['1.16','1.17', '1.18'] - sqlImage: ['2017-latest','2019-latest'] - steps: - - uses: actions/checkout@v2 - - name: Setup go - uses: actions/setup-go@v2 - with: - go-version: '${{ matrix.go }}' - - name: Run tests against Linux SQL - run: | - go version - go get -d - export SQLCMDPASSWORD=$(date +%s|sha256sum|base64|head -c 32) - export SQLCMDUSER=sa - export SQLUSER=sa - export SQLPASSWORD=$SQLCMDPASSWORD - export DATABASE=test - docker run -m 2GB -e ACCEPT_EULA=1 -d --name sqlserver -p:1433:1433 -e SA_PASSWORD=$SQLCMDPASSWORD mcr.microsoft.com/mssql/server:${{ matrix.sqlImage }} - sleep 10 - sqlcmd -Q "CREATE DATABASE test" - go test -race -cpu 4 ./... diff --git a/deps/go-mssqldb/CONTRIBUTING.md b/deps/go-mssqldb/CONTRIBUTING.md deleted file mode 100644 index c282e9a..0000000 --- a/deps/go-mssqldb/CONTRIBUTING.md +++ /dev/null @@ -1,14 +0,0 @@ -# Contributing - -This project welcomes contributions and suggestions. Most contributions require you to -agree to a Contributor License Agreement (CLA) declaring that you have the right to, -and actually do, grant us the rights to use your contribution. For details, visit -https://cla.microsoft.com. - -When you submit a pull request, a CLA-bot will automatically determine whether you need -to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the -instructions provided by the bot. You will only need to do this once across all repositories using our CLA. - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. \ No newline at end of file diff --git a/deps/go-mssqldb/LICENSE.txt b/deps/go-mssqldb/LICENSE.txt index 700e114..7448756 100644 --- a/deps/go-mssqldb/LICENSE.txt +++ b/deps/go-mssqldb/LICENSE.txt @@ -1,5 +1,4 @@ Copyright (c) 2012 The Go Authors. All rights reserved. -Copyright (c) Microsoft Corporation. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are diff --git a/deps/go-mssqldb/README.md b/deps/go-mssqldb/README.md index 7f1b6b3..9a2a9bb 100644 --- a/deps/go-mssqldb/README.md +++ b/deps/go-mssqldb/README.md @@ -1,14 +1,14 @@ # A pure Go MSSQL driver for Go's database/sql package -[![Go Reference](https://pkg.go.dev/badge/github.com/microsoft/go-mssqldb.svg)](https://pkg.go.dev/github.com/microsoft/go-mssqldb) -[![Build status](https://ci.appveyor.com/api/projects/status/jrln8cs62wj9i0a2?svg=true)](https://ci.appveyor.com/project/microsoft/go-mssqldb) -[![codecov](https://codecov.io/gh/microsoft/go-mssqldb/branch/master/graph/badge.svg)](https://codecov.io/gh/microsoft/go-mssqldb) +[![Go Reference](https://pkg.go.dev/badge/github.com/denisenkom/go-mssqldb.svg)](https://pkg.go.dev/github.com/denisenkom/go-mssqldb) +[![Build status](https://ci.appveyor.com/api/projects/status/jrln8cs62wj9i0a2?svg=true)](https://ci.appveyor.com/project/denisenkom/go-mssqldb) +[![codecov](https://codecov.io/gh/denisenkom/go-mssqldb/branch/master/graph/badge.svg)](https://codecov.io/gh/denisenkom/go-mssqldb) ## Install Requires Go 1.8 or above. -Install with `go get github.com/microsoft/go-mssqldb` . +Install with `go get github.com/denisenkom/go-mssqldb` . ## Connection Parameters and DSN @@ -32,7 +32,7 @@ Other supported formats are listed below. ### Connection parameters for ODBC and ADO style connection strings * `server` - host or host\instance (default localhost) -* `port` - specifies the host\instance port (default 1433). If instance name is provided but no port, the driver will use SQL Server Browser to discover the port. +* `port` - used only when there is no instance in server (default 1433) ### Less common parameters @@ -130,7 +130,6 @@ The credential type is determined by the new `fedauth` connection string paramet * `fedauth=ActiveDirectoryDefault` - authenticates using a chained set of credentials. The chain is built from EnvironmentCredential -> ManagedIdentityCredential->AzureCLICredential. See [DefaultAzureCredential docs](https://github.com/Azure/azure-sdk-for-go/wiki/Set-up-Your-Environment-for-Authentication#configure-defaultazurecredential) for instructions on setting up your host environment to use it. Using this option allows you to have the same connection string in a service deployment as on your interactive development machine. * `fedauth=ActiveDirectoryManagedIdentity` or `fedauth=ActiveDirectoryMSI` - authenticates using a system-assigned or user-assigned Azure Managed Identity. * `user id=` - optional id of user-assigned managed identity. If empty, system-assigned managed identity is used. - * `resource id=` - optional resource id of user-assigned managed identity. If empty, system-assigned managed identity or user id are used (if both user id and resource id are provided, resource id will be used) * `fedauth=ActiveDirectoryInteractive` - authenticates using credentials acquired from an external web browser. Only suitable for use with human interaction. * `applicationclientid=` - This guid identifies an Azure Active Directory enterprise application that the AAD admin has approved for accessing Azure SQL database resources in the tenant. This driver does not have an associated application id of its own. @@ -141,7 +140,7 @@ import ( "net/url" // Import the Azure AD driver module (also imports the regular driver package) - "github.com/microsoft/go-mssqldb/azuread" + "github.com/denisenkom/go-mssqldb/azuread" ) func ConnectWithMSI() (*sql.DB, error) { @@ -281,19 +280,6 @@ are supported: * "github.com/golang-sql/civil".Time -> time * mssql.TVP -> Table Value Parameter (TDS version dependent) -Using an `int` parameter will send a 4 byte value (int) from a 32bit app and an 8 byte value (bigint) from a 64bit app. -To make sure your integer parameter matches the size of the SQL parameter, use the appropriate sized type like `int32` or `int8`. - -```go -// If this is passed directly as a parameter, -// the SQL parameter generated would be nvarchar -name := "Bob" -// If the user_name is defined as varchar, -// it needs to be converted like this: -db.QueryContext(ctx, `select * from t2 where user_name = @p1;`, mssql.VarChar(name)) -// Note: Mismatched data types on table and parameter may cause long running queries -``` - ## Important Notes * [LastInsertId](https://golang.org/pkg/database/sql/#Result.LastInsertId) should @@ -302,9 +288,9 @@ db.QueryContext(ctx, `select * from t2 where user_name = @p1;`, mssql.VarChar(na or add a `select ID = convert(bigint, SCOPE_IDENTITY());` to the end of your query (ref [SCOPE_IDENTITY](https://docs.microsoft.com/en-us/sql/t-sql/functions/scope-identity-transact-sql)). This will ensure you are getting the correct ID and will prevent a network round trip. -* [NewConnector](https://godoc.org/github.com/microsoft/go-mssqldb#NewConnector) +* [NewConnector](https://godoc.org/github.com/denisenkom/go-mssqldb#NewConnector) may be used with [OpenDB](https://golang.org/pkg/database/sql/#OpenDB). -* [Connector.SessionInitSQL](https://godoc.org/github.com/microsoft/go-mssqldb#Connector.SessionInitSQL) +* [Connector.SessionInitSQL](https://godoc.org/github.com/denisenkom/go-mssqldb#Connector.SessionInitSQL) may be set to set any driver specific session settings after the session has been reset. If empty the session will still be reset but use the database defaults in Go1.10+. @@ -360,20 +346,3 @@ Use the native "@Name" parameters instead with the "sqlserver" driver name. To fix SQL Server 2008 R2 issue, install SQL Server 2008 R2 Service Pack 2. To fix SQL Server 2008 issue, install Microsoft SQL Server 2008 Service Pack 3 and Cumulative update package 3 for SQL Server 2008 SP3. More information: - - -# Contributing -This project is a fork of [https://github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb) and welcomes new and previous contributors. For more informaton on contributing to this project, please see [Contributing](./CONTRIBUTING.md). - -For more information on the roadmap for go-mssqldb, [project plans](https://github.com/microsoft/go-mssqldb/projects) are available for viewing and discussion. - - -# Microsoft Open Source Code of Conduct - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). - -Resources: - -- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) -- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns diff --git a/deps/go-mssqldb/SECURITY.md b/deps/go-mssqldb/SECURITY.md deleted file mode 100644 index f7b8998..0000000 --- a/deps/go-mssqldb/SECURITY.md +++ /dev/null @@ -1,41 +0,0 @@ - - -## Security - -Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). - -If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. - -## Reporting Security Issues - -**Please do not report security vulnerabilities through public GitHub issues.** - -Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). - -If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). - -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). - -Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: - - * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) - * Full paths of source file(s) related to the manifestation of the issue - * The location of the affected source code (tag/branch/commit or direct URL) - * Any special configuration required to reproduce the issue - * Step-by-step instructions to reproduce the issue - * Proof-of-concept or exploit code (if possible) - * Impact of the issue, including how an attacker might exploit the issue - -This information will help us triage your report more quickly. - -If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. - -## Preferred Languages - -We prefer all communications to be in English. - -## Policy - -Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). - - \ No newline at end of file diff --git a/deps/go-mssqldb/appveyor.yml b/deps/go-mssqldb/appveyor.yml index cc26a8d..c03f375 100644 --- a/deps/go-mssqldb/appveyor.yml +++ b/deps/go-mssqldb/appveyor.yml @@ -3,7 +3,7 @@ version: 1.0.{build} image: - Visual Studio 2015 -clone_folder: c:\gopath\src\github.com\microsoft\go-mssqldb +clone_folder: c:\gopath\src\github.com\denisenkom\go-mssqldb environment: GOPATH: c:\gopath @@ -13,6 +13,8 @@ environment: DATABASE: test GOVERSION: 113 matrix: + - GOVERSION: 18 + SQLINSTANCE: SQL2017 - GOVERSION: 19 SQLINSTANCE: SQL2017 - GOVERSION: 110 @@ -48,7 +50,7 @@ install: - go env - go get -u github.com/golang-sql/civil - go get -u github.com/golang-sql/sqlexp - + build_script: - go build diff --git a/deps/go-mssqldb/azuread/azuread_test.go b/deps/go-mssqldb/azuread/azuread_test.go index 18bd276..9e3ad95 100644 --- a/deps/go-mssqldb/azuread/azuread_test.go +++ b/deps/go-mssqldb/azuread/azuread_test.go @@ -7,7 +7,7 @@ import ( "os" "testing" - mssql "github.com/microsoft/go-mssqldb" + mssql "github.com/denisenkom/go-mssqldb" ) func TestAzureSqlAuth(t *testing.T) { diff --git a/deps/go-mssqldb/azuread/configuration.go b/deps/go-mssqldb/azuread/configuration.go index 5166385..c007751 100644 --- a/deps/go-mssqldb/azuread/configuration.go +++ b/deps/go-mssqldb/azuread/configuration.go @@ -10,8 +10,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - mssql "github.com/microsoft/go-mssqldb" - "github.com/microsoft/go-mssqldb/msdsn" + mssql "github.com/denisenkom/go-mssqldb" + "github.com/denisenkom/go-mssqldb/msdsn" ) const ( @@ -39,7 +39,6 @@ type azureFedAuthConfig struct { tenantID string clientSecret string certificatePath string - resourceID string // AD password/managed identity/interactive user string @@ -94,7 +93,6 @@ func (p *azureFedAuthConfig) validateParameters(params map[string]string) error // When using MSI, to request a specific client ID or user-assigned identity, // provide the ID in the "user id" parameter p.adalWorkflow = mssql.FedAuthADALWorkflowMSI - p.resourceID, _ = params["resource id"] p.clientID, _ = splitTenantAndClientID(params["user id"]) case strings.EqualFold(fedAuthWorkflow, ActiveDirectoryApplication) || strings.EqualFold(fedAuthWorkflow, ActiveDirectoryServicePrincipal): p.adalWorkflow = mssql.FedAuthADALWorkflowPassword @@ -167,26 +165,24 @@ func (p *azureFedAuthConfig) provideActiveDirectoryToken(ctx context.Context, se case ActiveDirectoryServicePrincipal, ActiveDirectoryApplication: switch { case p.certificatePath != "": - certData, err := os.ReadFile(p.certificatePath) - if err != nil { - certs, key, err := azidentity.ParseCertificates(certData, []byte(p.clientSecret)) - if err != nil { - cred, err = azidentity.NewClientCertificateCredential(tenant, p.clientID, certs, key, nil) - } + certFile, inErr := os.ReadFile(p.certificatePath) + if inErr != nil { + err = inErr + break } + certs, key, inErr := azidentity.ParseCertificates(certFile, ([]byte)(p.clientSecret)) + if inErr != nil { + err = inErr + break + } + cred, err = azidentity.NewClientCertificateCredential(tenant, p.clientID, certs, key, nil) default: cred, err = azidentity.NewClientSecretCredential(tenant, p.clientID, p.clientSecret, nil) } case ActiveDirectoryPassword: cred, err = azidentity.NewUsernamePasswordCredential(tenant, p.applicationClientID, p.user, p.password, nil) case ActiveDirectoryMSI, ActiveDirectoryManagedIdentity: - if p.resourceID != "" { - cred, err = azidentity.NewManagedIdentityCredential(&azidentity.ManagedIdentityCredentialOptions{ID: azidentity.ResourceID(p.resourceID)}) - } else if p.clientID != "" { - cred, err = azidentity.NewManagedIdentityCredential(&azidentity.ManagedIdentityCredentialOptions{ID: azidentity.ClientID(p.clientID)}) - } else { - cred, err = azidentity.NewManagedIdentityCredential(nil) - } + cred, err = azidentity.NewManagedIdentityCredential(&azidentity.ManagedIdentityCredentialOptions{ID: azidentity.ClientID(p.clientID)}) case ActiveDirectoryInteractive: cred, err = azidentity.NewInteractiveBrowserCredential(&azidentity.InteractiveBrowserCredentialOptions{TenantID: tenant, ClientID: p.applicationClientID}) diff --git a/deps/go-mssqldb/azuread/configuration_test.go b/deps/go-mssqldb/azuread/configuration_test.go index cb9ecbd..5094e5f 100644 --- a/deps/go-mssqldb/azuread/configuration_test.go +++ b/deps/go-mssqldb/azuread/configuration_test.go @@ -3,8 +3,8 @@ package azuread import ( "testing" - mssql "github.com/microsoft/go-mssqldb" - "github.com/microsoft/go-mssqldb/msdsn" + mssql "github.com/denisenkom/go-mssqldb" + "github.com/denisenkom/go-mssqldb/msdsn" ) func TestValidateParameters(t *testing.T) { @@ -84,17 +84,8 @@ func TestValidateParameters(t *testing.T) { dsn: "server=someserver.database.windows.net;fedauth=ActiveDirectoryManagedIdentity;user id=identity-client-id", expected: &azureFedAuthConfig{ adalWorkflow: mssql.FedAuthADALWorkflowMSI, - clientID: "identity-client-id", - fedAuthWorkflow: ActiveDirectoryManagedIdentity, - }, - }, - { - name: "managed identity with resource id", - dsn: "server=someserver.database.windows.net;fedauth=ActiveDirectoryManagedIdentity;resource id=/subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}", - expected: &azureFedAuthConfig{ - adalWorkflow: mssql.FedAuthADALWorkflowMSI, - resourceID: "/subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}", - fedAuthWorkflow: ActiveDirectoryManagedIdentity, + clientID: "identity-client-id", + fedAuthWorkflow: ActiveDirectoryManagedIdentity, }, }, } diff --git a/deps/go-mssqldb/azuread/driver.go b/deps/go-mssqldb/azuread/driver.go index 03a5934..cbae24f 100644 --- a/deps/go-mssqldb/azuread/driver.go +++ b/deps/go-mssqldb/azuread/driver.go @@ -5,7 +5,7 @@ import ( "database/sql" "database/sql/driver" - mssql "github.com/microsoft/go-mssqldb" + mssql "github.com/denisenkom/go-mssqldb" ) // DriverName is the name used to register the driver diff --git a/deps/go-mssqldb/bad_server_test.go b/deps/go-mssqldb/bad_server_test.go index ff0e57d..46b4be5 100644 --- a/deps/go-mssqldb/bad_server_test.go +++ b/deps/go-mssqldb/bad_server_test.go @@ -10,7 +10,7 @@ import ( // tests simulating bad server -func testConnectionBad(t *testing.T, connStr string) (err error) { +func testConnectionBad(t *testing.T, connStr string) { conn, err := sql.Open("mssql", connStr) if err != nil { // should not fail here @@ -24,8 +24,6 @@ func testConnectionBad(t *testing.T, connStr string) (err error) { if err == nil { t.Fatal("Scan should fail but it succeeded") } - - return } func testBadServer(t *testing.T, handler func(net.Conn)) { diff --git a/deps/go-mssqldb/buf.go b/deps/go-mssqldb/buf.go index 6866342..051d7ba 100644 --- a/deps/go-mssqldb/buf.go +++ b/deps/go-mssqldb/buf.go @@ -4,7 +4,6 @@ import ( "encoding/binary" "errors" "io" - "sync" ) type packetType uint8 @@ -18,16 +17,6 @@ type header struct { Pad uint8 } -// bufpool provides buffers which are used for reading and writing in the tdsBuffer instances -var bufpool = sync.Pool{ - New: func() interface{} { - b := make([]byte, 1<<16) - // If the return value is not a pointer, any conversion from interface{} will - // involve an allocation. - return &b - }, -} - // tdsBuffer reads and writes TDS packets of data to the transport. // The write and read buffers are separate to make sending attn signals // possible without locks. Currently attn signals are only sent during @@ -37,9 +26,6 @@ type tdsBuffer struct { packetSize int - // bufClose is responsible for returning the buffer back to the pool - bufClose func() - // Write fields. wbuf []byte wpos int @@ -60,15 +46,10 @@ type tdsBuffer struct { } func newTdsBuffer(bufsize uint16, transport io.ReadWriteCloser) *tdsBuffer { - - // pull an existing buf if one is available or get and add a new buf to the bufpool - buf := bufpool.Get().(*[]byte) - return &tdsBuffer{ packetSize: int(bufsize), - wbuf: (*buf)[:1<<15], - rbuf: (*buf)[1<<15:], - bufClose: func() { bufpool.Put(buf) }, + wbuf: make([]byte, bufsize), + rbuf: make([]byte, bufsize), rpos: 8, transport: transport, } @@ -220,27 +201,16 @@ func (r *tdsBuffer) byte() byte { } func (r *tdsBuffer) ReadFull(buf []byte) { - _, err := io.ReadFull(r, buf) + _, err := io.ReadFull(r, buf[:]) if err != nil { badStreamPanic(err) } } func (r *tdsBuffer) uint64() uint64 { - // have we got enough room in the buffer to read 8 bytes, if not, do a ReadFull, else read directly from r.rbuf - if r.rpos+7 >= r.rsize { - var buf [8]byte - r.ReadFull(buf[:]) - - return uint64(buf[0]) | uint64(buf[1])<<8 | uint64(buf[2])<<16 | uint64(buf[3])<<24 | - uint64(buf[4])<<32 | uint64(buf[5])<<40 | uint64(buf[6])<<48 | uint64(buf[7])<<56 - } - - res := uint64(r.rbuf[r.rpos]) | uint64(r.rbuf[r.rpos+1])<<8 | uint64(r.rbuf[r.rpos+2])<<16 | uint64(r.rbuf[r.rpos+3])<<24 | - uint64(r.rbuf[r.rpos+4])<<32 | uint64(r.rbuf[r.rpos+5])<<40 | uint64(r.rbuf[r.rpos+6])<<48 | uint64(r.rbuf[r.rpos+7])<<56 - - r.rpos += 8 - return res + var buf [8]byte + r.ReadFull(buf[:]) + return binary.LittleEndian.Uint64(buf[:]) } func (r *tdsBuffer) int32() int32 { @@ -248,29 +218,15 @@ func (r *tdsBuffer) int32() int32 { } func (r *tdsBuffer) uint32() uint32 { - // have we got enough room in the buffer to read 4 bytes, if not, do a ReadFull, else read directly from r.rbuf - if r.rpos+3 >= r.rsize { - var buf [4]byte - r.ReadFull(buf[:]) - return uint32(buf[0]) | uint32(buf[1])<<8 | uint32(buf[2])<<16 | uint32(buf[3])<<24 - } - - res := uint32(r.rbuf[r.rpos]) | uint32(r.rbuf[r.rpos+1])<<8 | uint32(r.rbuf[r.rpos+2])<<16 | uint32(r.rbuf[r.rpos+3])<<24 - r.rpos += 4 - return res + var buf [4]byte + r.ReadFull(buf[:]) + return binary.LittleEndian.Uint32(buf[:]) } func (r *tdsBuffer) uint16() uint16 { - // have we got enough room in the buffer to read 2 bytes, if not, do a ReadFull, else read directly from r.rbuf - if r.rpos+1 >= r.rsize { - var buf [2]byte - r.ReadFull(buf[:]) - return uint16(buf[0]) | uint16(buf[1])<<8 - } - - res := uint16(r.rbuf[r.rpos]) | uint16(r.rbuf[r.rpos+1])<<8 - r.rpos += 2 - return res + var buf [2]byte + r.ReadFull(buf[:]) + return binary.LittleEndian.Uint16(buf[:]) } func (r *tdsBuffer) BVarChar() string { diff --git a/deps/go-mssqldb/buf_test.go b/deps/go-mssqldb/buf_test.go index 61577c7..5b3b1ec 100644 --- a/deps/go-mssqldb/buf_test.go +++ b/deps/go-mssqldb/buf_test.go @@ -2,10 +2,8 @@ package mssql import ( "bytes" - "encoding/binary" "errors" "testing" - "unicode/utf16" ) type closableBuffer struct { @@ -120,165 +118,6 @@ func TestBeginReadSucceeds(t *testing.T) { } } -func makeLargeDataBuffer() []byte { - data := make([]byte, 1<<15) - - for i := 0; i < len(data); i += 4 { - data[i] = 0xFE - data[i+1] = 0xDC - data[i+2] = 0xBA - data[i+3] = 0x89 - } - - return data -} - -func TestReadUint16Succeeds(t *testing.T) { - - data := makeLargeDataBuffer() - size := 0x9 + (1 << 14) - buffer := makeBuf(uint16(size), append([]byte{0x01 /*id*/, 0xFF /*status*/, byte((size >> 8) & 0xFF), byte(size & 0xFF) /*size*/, 0xff, 0xff, 0xff, 0xff, 0xff /* byte pattern data to follow */}, data...)) - - id, err := buffer.BeginRead() - if err != nil { - t.Fatal("BeginRead failed:", err.Error()) - } - if id != 1 { - t.Fatalf("Expected id to be 1 but it is %d", id) - } - - buffer.byte() - - iterations := 0 - - defer func() { - - if iterations != (1<<14)/4 { - t.Fatalf("Expected to read all data, but only read %v", iterations*4) - } - - v := recover() - if v == nil { - t.Fatalf("Expected EOF but got nil") - } - - if err, ok := v.(error); ok { - if err.Error() != "Invalid TDS stream: EOF" { - t.Fatalf("Expected EOF but got %v", err) - } - } else { - t.Fatalf("Expected EOF but got %v", v) - } - }() - - for { - - a := buffer.uint16() - if a != 0xdcfe { - t.Fatalf("Expected read uint16 to be 0xfedc but it is %d", a) - } - - b := buffer.uint16() - if b != 0x89ba { - t.Fatalf("Expected read uint16 to be 0x89ba but it is %d", a) - } - - iterations++ - } - -} - -func TestReadUint32Succeeds(t *testing.T) { - - data := makeLargeDataBuffer() - size := 0x9 + (1 << 14) - buffer := makeBuf(uint16(size), append([]byte{0x01 /*id*/, 0xFF /*status*/, byte((size >> 8) & 0xFF), byte(size & 0xFF) /*size*/, 0xff, 0xff, 0xff, 0xff, 0xff /* byte pattern data to follow */}, data...)) - - id, err := buffer.BeginRead() - if err != nil { - t.Fatal("BeginRead failed:", err.Error()) - } - if id != 1 { - t.Fatalf("Expected id to be 1 but it is %d", id) - } - - buffer.byte() - - iterations := 0 - defer func() { - if iterations != (1<<14)/4 { - t.Fatalf("Expected to read all data, but only read %v", iterations*4) - } - - v := recover() - if v == nil { - t.Fatalf("Expected EOF but got nil") - } - - if err, ok := v.(error); ok { - if err.Error() != "Invalid TDS stream: EOF" { - t.Fatalf("Expected EOF but got %v", err) - } - } else { - t.Fatalf("Expected EOF but got %v", v) - } - }() - for { - a := buffer.uint32() - if a != 0x89badcfe { - t.Fatalf("Expected read uint16 to be 0x89badcfe but it is %d", a) - } - - iterations++ - } -} - -func TestReadUint64Succeeds(t *testing.T) { - - data := makeLargeDataBuffer() - size := 0x9 + (1 << 14) - buffer := makeBuf(uint16(size), append([]byte{0x01 /*id*/, 0xFF /*status*/, byte((size >> 8) & 0xFF), byte(size & 0xFF) /*size*/, 0xff, 0xff, 0xff, 0xff, 0xff /* byte pattern data to follow */}, data...)) - - id, err := buffer.BeginRead() - if err != nil { - t.Fatal("BeginRead failed:", err.Error()) - } - if id != 1 { - t.Fatalf("Expected id to be 1 but it is %d", id) - } - - buffer.byte() - - iterations := 0 - defer func() { - if iterations != (1<<14)/8 { - t.Fatalf("Expected to read all data, but only read %v", iterations*4) - } - - v := recover() - if v == nil { - t.Fatalf("Expected EOF but got nil") - } - - if err, ok := v.(error); ok { - if err.Error() != "Invalid TDS stream: EOF" { - t.Fatalf("Expected EOF but got %v", err) - } - } else { - t.Fatalf("Expected EOF but got %v", v) - } - }() - - for { - a := buffer.uint64() - if a != 0x89badcfe89badcfe { - t.Fatalf("Expected read uint16 to be 0x89badcfe89badcfe but it is %d", a) - } - - iterations++ - } -} - func TestReadByteFailsOnSecondPacket(t *testing.T) { buffer := makeBuf(9, []byte{ 0x01 /*id*/, 0x0 /*not final*/, 0x0, 0x9 /*size*/, 0xff, 0xff, 0xff, 0xff, 0x02, /*test byte*/ @@ -460,88 +299,6 @@ func TestReadUsVarCharOrPanic(t *testing.T) { t.Fatal("UsVarChar() should panic, but it didn't") } -func TestReadUsVarCharOrPanicWideChars(t *testing.T) { - str := "百度一下,你就知道" - runes := utf16.Encode([]rune(str)) - encodedBytes := make([]byte, len(runes)*2) - - for i := 0; i < len(runes); i++ { - binary.LittleEndian.PutUint16(encodedBytes[i*2:], runes[i]) - } - - memBuf := bytes.NewBuffer(append([]byte{byte(len(runes)), 0}, encodedBytes...)) - - s := readUsVarCharOrPanic(memBuf) - if s != str { - t.Errorf("UsVarChar expected to return %s but it returned %s", str, s) - } -} - -func TestReadBVarCharOrPanicWideChars(t *testing.T) { - str := "百度一下,你就知道" - runes := utf16.Encode([]rune(str)) - encodedBytes := make([]byte, len(runes)*2) - - for i := 0; i < len(runes); i++ { - binary.LittleEndian.PutUint16(encodedBytes[i*2:], runes[i]) - } - - memBuf := bytes.NewBuffer(append([]byte{byte(len(runes))}, encodedBytes...)) - - s := readBVarCharOrPanic(memBuf) - if s != str { - t.Errorf("UsVarChar expected to return %s but it returned %s", str, s) - } -} - -var sideeffectstring string - -func BenchmarkReadBVarCharOrPanicWideChars(b *testing.B) { - str := "百度一下,你就知道" - - runes := utf16.Encode([]rune(str)) - encodedBytes := make([]byte, len(runes)*2) - - for i := 0; i < len(runes); i++ { - binary.LittleEndian.PutUint16(encodedBytes[i*2:], runes[i]) - } - - encodedBytes = append([]byte{byte(len(runes))}, encodedBytes...) - - memBuf := bytes.NewReader(encodedBytes) - - for n := 0; n < b.N; n++ { - - s := readBVarCharOrPanic(memBuf) - sideeffectstring = s - - memBuf.Reset(encodedBytes) - } -} - -func BenchmarkReadBVarCharOrPanicOnly1WideChar(b *testing.B) { - str := "abcdefghijklmno百p" - - runes := utf16.Encode([]rune(str)) - encodedBytes := make([]byte, len(runes)*2) - - for i := 0; i < len(runes); i++ { - binary.LittleEndian.PutUint16(encodedBytes[i*2:], runes[i]) - } - - encodedBytes = append([]byte{byte(len(runes))}, encodedBytes...) - - memBuf := bytes.NewReader(encodedBytes) - - for n := 0; n < b.N; n++ { - - s := readBVarCharOrPanic(memBuf) - sideeffectstring = s - - memBuf.Reset(encodedBytes) - } -} - func TestReadBVarCharOrPanic(t *testing.T) { memBuf := bytes.NewBuffer([]byte{3, 0x31, 0, 0x32, 0, 0x33, 0}) s := readBVarCharOrPanic(memBuf) diff --git a/deps/go-mssqldb/bulkcopy.go b/deps/go-mssqldb/bulkcopy.go index 97edb7b..f6cf97a 100644 --- a/deps/go-mssqldb/bulkcopy.go +++ b/deps/go-mssqldb/bulkcopy.go @@ -11,8 +11,8 @@ import ( "strings" "time" - "github.com/microsoft/go-mssqldb/internal/decimal" - "github.com/microsoft/go-mssqldb/msdsn" + "github.com/denisenkom/go-mssqldb/internal/decimal" + "github.com/denisenkom/go-mssqldb/msdsn" ) type Bulk struct { @@ -381,14 +381,6 @@ func (b *Bulk) makeParam(val DataValue, col columnStruct) (res param, err error) res.buffer = str2ucs2(val) case int64: res.buffer = []byte(strconv.FormatInt(val, 10)) - case int: - res.buffer = []byte(strconv.FormatInt(int64(val), 10)) - case int8: - res.buffer = []byte(strconv.FormatInt(int64(val), 10)) - case int32: - res.buffer = []byte(strconv.FormatInt(int64(val), 10)) - case int16: - res.buffer = []byte(strconv.FormatInt(int64(val), 10)) case []byte: res.buffer = val default: @@ -403,14 +395,6 @@ func (b *Bulk) makeParam(val DataValue, col columnStruct) (res param, err error) res.buffer = []byte(val) case []byte: res.buffer = val - case int: - res.buffer = []byte(strconv.FormatInt(int64(val), 10)) - case int8: - res.buffer = []byte(strconv.FormatInt(int64(val), 10)) - case int16: - res.buffer = []byte(strconv.FormatInt(int64(val), 10)) - case int32: - res.buffer = []byte(strconv.FormatInt(int64(val), 10)) case int64: res.buffer = []byte(strconv.FormatInt(val, 10)) default: diff --git a/deps/go-mssqldb/bulkcopy_test.go b/deps/go-mssqldb/bulkcopy_test.go index 1380add..6a63ae2 100644 --- a/deps/go-mssqldb/bulkcopy_test.go +++ b/deps/go-mssqldb/bulkcopy_test.go @@ -1,4 +1,3 @@ -//go:build go1.9 // +build go1.9 package mssql @@ -82,10 +81,6 @@ func TestBulkcopy(t *testing.T) { {"test_binary", []byte("1"), nil}, {"test_binary_16", bin, nil}, {"test_intvarchar", 1234, "1234"}, - {"test_int64nvarchar", int64(123456), "123456"}, - {"test_int32nvarchar", int32(12345), "12345"}, - {"test_int16nvarchar", int16(1234), "1234"}, - {"test_int8nvarchar", int8(12), "12"}, {"test_intnvarchar", 1234, "1234"}, } @@ -283,10 +278,6 @@ func setupTable(ctx context.Context, t *testing.T, conn *sql.Conn, tableName str [test_binary] BINARY NOT NULL, [test_binary_16] BINARY(16) NOT NULL, [test_intvarchar] [varchar](4) NULL, - [test_int64nvarchar] [varchar](6) NULL, - [test_int32nvarchar] [varchar](5) NULL, - [test_int16nvarchar] [varchar](4) NULL, - [test_int8nvarchar] [varchar](3) NULL, [test_intnvarchar] [varchar](4) NULL, CONSTRAINT [PK_` + tableName + `_id] PRIMARY KEY CLUSTERED ( diff --git a/deps/go-mssqldb/bulkimport_example_test.go b/deps/go-mssqldb/bulkimport_example_test.go index 5046c35..4fafbc9 100644 --- a/deps/go-mssqldb/bulkimport_example_test.go +++ b/deps/go-mssqldb/bulkimport_example_test.go @@ -9,7 +9,7 @@ import ( "strings" "unicode/utf8" - mssql "github.com/microsoft/go-mssqldb" + mssql "github.com/denisenkom/go-mssqldb" ) const ( diff --git a/deps/go-mssqldb/datetimeoffset_example_test.go b/deps/go-mssqldb/datetimeoffset_example_test.go index 8267b6d..ad419c4 100644 --- a/deps/go-mssqldb/datetimeoffset_example_test.go +++ b/deps/go-mssqldb/datetimeoffset_example_test.go @@ -9,8 +9,8 @@ import ( "log" "time" + mssql "github.com/denisenkom/go-mssqldb" "github.com/golang-sql/civil" - mssql "github.com/microsoft/go-mssqldb" ) // This example shows how to insert and retrieve date and time types data diff --git a/deps/go-mssqldb/doc/how-to-perform-bulk-imports.md b/deps/go-mssqldb/doc/how-to-perform-bulk-imports.md index 7094e48..34f570c 100644 --- a/deps/go-mssqldb/doc/how-to-perform-bulk-imports.md +++ b/deps/go-mssqldb/doc/how-to-perform-bulk-imports.md @@ -5,7 +5,7 @@ To use the bulk imports feature in go-mssqldb, you need to import the sql and go ``` import ( "database/sql" - "github.com/microsoft/go-mssqldb" + "github.com/denisenkom/go-mssqldb" ) ``` diff --git a/deps/go-mssqldb/doc/how-to-use-newconnector.md b/deps/go-mssqldb/doc/how-to-use-newconnector.md index cd89414..0273d89 100644 --- a/deps/go-mssqldb/doc/how-to-use-newconnector.md +++ b/deps/go-mssqldb/doc/how-to-use-newconnector.md @@ -7,7 +7,7 @@ To use the Connector type, first you need to import the sql and go-mssqldb packa ``` import ( "database/sql" - "github.com/microsoft/go-mssqldb" + "github.com/denisenkom/go-mssqldb" ) ``` diff --git a/deps/go-mssqldb/examples/azuread-accesstoken/go.mod b/deps/go-mssqldb/examples/azuread-accesstoken/go.mod index cee1784..eb113f3 100644 --- a/deps/go-mssqldb/examples/azuread-accesstoken/go.mod +++ b/deps/go-mssqldb/examples/azuread-accesstoken/go.mod @@ -1,8 +1,8 @@ -module github.com/microsoft/go-mssqldb/examples/azure-ad-accesstoken +module github.com/denisenkom/go-mssqldb/examples/azure-ad-accesstoken go 1.13 require ( github.com/Azure/go-autorest/autorest/adal v0.8.1 - github.com/microsoft/go-mssqldb v0.12.0 + github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73 ) diff --git a/deps/go-mssqldb/examples/azuread-accesstoken/go.sum b/deps/go-mssqldb/examples/azuread-accesstoken/go.sum index 432407e..17148ff 100644 --- a/deps/go-mssqldb/examples/azuread-accesstoken/go.sum +++ b/deps/go-mssqldb/examples/azuread-accesstoken/go.sum @@ -14,8 +14,8 @@ github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= -github.com/microsoft/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73 h1:OGNva6WhsKst5OZf7eZOklDztV3hwtTHovdrLHV+MsA= -github.com/microsoft/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73 h1:OGNva6WhsKst5OZf7eZOklDztV3hwtTHovdrLHV+MsA= +github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= diff --git a/deps/go-mssqldb/examples/azuread-accesstoken/managed_identity.go b/deps/go-mssqldb/examples/azuread-accesstoken/managed_identity.go index 6ff3617..0adf99c 100644 --- a/deps/go-mssqldb/examples/azuread-accesstoken/managed_identity.go +++ b/deps/go-mssqldb/examples/azuread-accesstoken/managed_identity.go @@ -7,7 +7,7 @@ import ( "log" "github.com/Azure/go-autorest/autorest/adal" - mssql "github.com/microsoft/go-mssqldb" + mssql "github.com/denisenkom/go-mssqldb" ) var ( diff --git a/deps/go-mssqldb/examples/azuread-service-principal-authtoken/service_principal_authtoken.go b/deps/go-mssqldb/examples/azuread-service-principal-authtoken/service_principal_authtoken.go deleted file mode 100644 index 5e57119..0000000 --- a/deps/go-mssqldb/examples/azuread-service-principal-authtoken/service_principal_authtoken.go +++ /dev/null @@ -1,65 +0,0 @@ -package main - -import ( - "context" - "database/sql" - "flag" - "fmt" - "log" - - mssql "github.com/microsoft/go-mssqldb" -) - -var ( - debug = flag.Bool("debug", true, "enable debugging") - password = flag.String("password", "", "the client secret for the app/client ID") - port *int = flag.Int("port", 1433, "the database port") - server = flag.String("server", "", "the database server") - database = flag.String("database", "", "the database name") -) - -func main() { - flag.Parse() - - if *debug { - fmt.Printf(" password:%s\n", *password) - fmt.Printf(" port:%d\n", *port) - fmt.Printf(" server:%s\n", *server) - fmt.Printf(" database:%s\n", *database) - } - - connString := fmt.Sprintf("server=%s;password=%s;port=%d;database=%s;fedauth=ActiveDirectoryServicePrincipalAccessToken;", *server, *password, *port, *database) - if *debug { - fmt.Printf(" connString:%s\n", connString) - } - - tokenProviderWithCtx := func(ctx context.Context) (string, error) { - return "access_token", nil - } - - connector, err := mssql.NewConnectorWithAccessTokenProvider(connString, tokenProviderWithCtx) - conn := sql.OpenDB(connector) - - if err != nil { - log.Fatal("Open connection failed:", err.Error()) - } - defer conn.Close() - - stmt, err := conn.Prepare("select 1, 'abc'") - if err != nil { - log.Fatal("Prepare failed:", err.Error()) - } - defer stmt.Close() - - row := stmt.QueryRow() - var somenumber int64 - var somechars string - err = row.Scan(&somenumber, &somechars) - if err != nil { - log.Fatal("Scan failed:", err.Error()) - } - fmt.Printf("somenumber:%d\n", somenumber) - fmt.Printf("somechars:%s\n", somechars) - - fmt.Printf("bye\n") -} diff --git a/deps/go-mssqldb/examples/azuread-service-principal/service_principal.go b/deps/go-mssqldb/examples/azuread-service-principal/service_principal.go deleted file mode 100644 index 8d74ab8..0000000 --- a/deps/go-mssqldb/examples/azuread-service-principal/service_principal.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "database/sql" - "flag" - "fmt" - "log" - - "github.com/microsoft/go-mssqldb/azuread" -) - -var ( - debug = flag.Bool("debug", true, "Enable debugging") - password = flag.String("password", "", "The client secret for the app/client ID") - port *int = flag.Int("port", 1433, "The database port") - server = flag.String("server", "", "The database server") - user = flag.String("user", "", "The app ID of the service principal. "+ - "Format: @. tenant_id is optional if the app and database are in the same tenant.") - database = flag.String("database", "", "The database name") -) - -func main() { - flag.Parse() - - if *debug { - fmt.Printf(" password:%s\n", *password) - fmt.Printf(" port:%d\n", *port) - fmt.Printf(" server:%s\n", *server) - fmt.Printf(" user:%s\n", *user) - fmt.Printf(" database:%s\n", *database) - } - - connString := fmt.Sprintf("server=%s;user id=%s;password=%s;port=%d;database=%s;fedauth=ActiveDirectoryServicePrincipal;", *server, *user, *password, *port, *database) - if *debug { - fmt.Printf(" connString:%s\n", connString) - } - conn, err := sql.Open(azuread.DriverName, connString) - if err != nil { - log.Fatal("Open connection failed:", err.Error()) - } - defer conn.Close() - - stmt, err := conn.Prepare("select 1, 'abc'") - if err != nil { - log.Fatal("Prepare failed:", err.Error()) - } - defer stmt.Close() - - row := stmt.QueryRow() - var somenumber int64 - var somechars string - err = row.Scan(&somenumber, &somechars) - if err != nil { - log.Fatal("Scan failed:", err.Error()) - } - fmt.Printf("somenumber:%d\n", somenumber) - fmt.Printf("somechars:%s\n", somechars) - - fmt.Printf("bye\n") -} diff --git a/deps/go-mssqldb/examples/bulk/bulk.go b/deps/go-mssqldb/examples/bulk/bulk.go index bcd6e99..8ce1238 100644 --- a/deps/go-mssqldb/examples/bulk/bulk.go +++ b/deps/go-mssqldb/examples/bulk/bulk.go @@ -6,7 +6,7 @@ import ( "fmt" "log" - mssql "github.com/microsoft/go-mssqldb" + "github.com/denisenkom/go-mssqldb" ) var ( diff --git a/deps/go-mssqldb/examples/routine/routine.go b/deps/go-mssqldb/examples/routine/routine.go index 42f6513..3c9cf74 100644 --- a/deps/go-mssqldb/examples/routine/routine.go +++ b/deps/go-mssqldb/examples/routine/routine.go @@ -8,7 +8,7 @@ import ( "strconv" "sync" - _ "github.com/microsoft/go-mssqldb" + _ "github.com/denisenkom/go-mssqldb" ) var ( diff --git a/deps/go-mssqldb/examples/simple/simple.go b/deps/go-mssqldb/examples/simple/simple.go index 7cb5cfc..67f88aa 100644 --- a/deps/go-mssqldb/examples/simple/simple.go +++ b/deps/go-mssqldb/examples/simple/simple.go @@ -6,7 +6,7 @@ import ( "fmt" "log" - _ "github.com/microsoft/go-mssqldb" + _ "github.com/denisenkom/go-mssqldb" ) var ( diff --git a/deps/go-mssqldb/examples/tsql/tsql.go b/deps/go-mssqldb/examples/tsql/tsql.go index 69dc8d4..f90cf46 100644 --- a/deps/go-mssqldb/examples/tsql/tsql.go +++ b/deps/go-mssqldb/examples/tsql/tsql.go @@ -9,7 +9,7 @@ import ( "os" "time" - _ "github.com/microsoft/go-mssqldb" + _ "github.com/denisenkom/go-mssqldb" ) func main() { diff --git a/deps/go-mssqldb/examples/tvp/tvp.go b/deps/go-mssqldb/examples/tvp/tvp.go index 061b7f3..a07bb65 100644 --- a/deps/go-mssqldb/examples/tvp/tvp.go +++ b/deps/go-mssqldb/examples/tvp/tvp.go @@ -4,9 +4,8 @@ import ( "database/sql" "flag" "fmt" + "github.com/denisenkom/go-mssqldb" "log" - - mssql "github.com/microsoft/go-mssqldb" ) var ( diff --git a/deps/go-mssqldb/fedauth.go b/deps/go-mssqldb/fedauth.go index 27ff3fc..cd74cb5 100644 --- a/deps/go-mssqldb/fedauth.go +++ b/deps/go-mssqldb/fedauth.go @@ -4,7 +4,7 @@ import ( "context" "errors" - "github.com/microsoft/go-mssqldb/msdsn" + "github.com/denisenkom/go-mssqldb/msdsn" ) // Federated authentication library affects the login data structure and message sequence. diff --git a/deps/go-mssqldb/go.mod b/deps/go-mssqldb/go.mod index c4f602f..ff10de3 100644 --- a/deps/go-mssqldb/go.mod +++ b/deps/go-mssqldb/go.mod @@ -1,16 +1,11 @@ -module github.com/microsoft/go-mssqldb +module github.com/denisenkom/go-mssqldb go 1.13 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 - github.com/dnaeon/go-vcr v1.2.0 // indirect - github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe github.com/golang-sql/sqlexp v0.1.0 - github.com/google/uuid v1.3.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 - golang.org/x/sys v0.0.0-20220224120231-95c6836cb0e7 // indirect + golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 ) diff --git a/deps/go-mssqldb/go.sum b/deps/go-mssqldb/go.sum index aae032c..f4f14f6 100644 --- a/deps/go-mssqldb/go.sum +++ b/deps/go-mssqldb/go.sum @@ -1,92 +1,45 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1 h1:qoVeMsc9/fh/yhxVaA0obYjVH/oI/ihrOoMwsLS9KSA= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.1 h1:RxemzI2cHD0A8WyMqHu/UnDjfpGES/cmjtPbQoktWqs= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.1/go.mod h1:+nVKciyKD2J9TyVcEQ82Bo9b+3F92PiQfHrIE/zqLqM= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 h1:sLZ/Y+P/5RRtsXWylBjB5lkgixYfm0MQPiwrSX//JSo= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 h1:lhSJz9RMbJcTgxifR1hUNJnn6CNYtbgEDtQV22/9RBA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0 h1:OYa9vmRX2XC5GXRAzeggG12sF/z5D9Ahtdm9EJ00WN4= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0 h1:v9p9TfTbf7AwNb5NYQt7hI41IfPoLFiFkLtb+bmGjT0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= -github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= -github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= +github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188 h1:+eHOFJl1BaXrQxKX+T06f78590z4qA2ZzBTqahsKSE4= +github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188/go.mod h1:vXjM/+wXQnTPR4KqTKDgJukSZ6amVRtWMPEjE6sQoK8= github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220224120231-95c6836cb0e7 h1:BXxu8t6QN0G1uff4bzZzSkpsax8+ALqTGUtz08QrV00= -golang.org/x/sys v0.0.0-20220224120231-95c6836cb0e7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/deps/go-mssqldb/log.go b/deps/go-mssqldb/log.go index 8ccb403..8d99bd5 100644 --- a/deps/go-mssqldb/log.go +++ b/deps/go-mssqldb/log.go @@ -3,7 +3,7 @@ package mssql import ( "context" - "github.com/microsoft/go-mssqldb/msdsn" + "github.com/denisenkom/go-mssqldb/msdsn" ) const ( diff --git a/deps/go-mssqldb/log_test.go b/deps/go-mssqldb/log_test.go index 529e283..9ac86d7 100644 --- a/deps/go-mssqldb/log_test.go +++ b/deps/go-mssqldb/log_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/microsoft/go-mssqldb/msdsn" + "github.com/denisenkom/go-mssqldb/msdsn" ) // bufLogger implements the Logger interface for testing purposes. diff --git a/deps/go-mssqldb/messages_example_test.go b/deps/go-mssqldb/messages_example_test.go index 99faf3f..37dc0e8 100644 --- a/deps/go-mssqldb/messages_example_test.go +++ b/deps/go-mssqldb/messages_example_test.go @@ -9,8 +9,8 @@ import ( "fmt" "log" + mssql "github.com/denisenkom/go-mssqldb" "github.com/golang-sql/sqlexp" - mssql "github.com/microsoft/go-mssqldb" ) const ( diff --git a/deps/go-mssqldb/msdsn/conn_str.go b/deps/go-mssqldb/msdsn/conn_str.go index d85f086..40bedb0 100644 --- a/deps/go-mssqldb/msdsn/conn_str.go +++ b/deps/go-mssqldb/msdsn/conn_str.go @@ -80,7 +80,7 @@ func SetupTLS(certificate string, insecureSkipVerify bool, hostInCertificate str ServerName: hostInCertificate, InsecureSkipVerify: insecureSkipVerify, - // fix for https://github.com/microsoft/go-mssqldb/issues/166 + // fix for https://github.com/denisenkom/go-mssqldb/issues/166 // Go implementation of TLS payload size heuristic algorithm splits single TDS package to multiple TCP segments, // while SQL Server seems to expect one TCP segment per encrypted TDS package. // Setting DynamicRecordSizingDisabled to true disables that algorithm and uses 16384 bytes per TLS package diff --git a/deps/go-mssqldb/mssql.go b/deps/go-mssqldb/mssql.go index f0cba5a..fbd44d1 100644 --- a/deps/go-mssqldb/mssql.go +++ b/deps/go-mssqldb/mssql.go @@ -9,16 +9,15 @@ import ( "fmt" "io" "math" - "math/bits" "net" "reflect" "strings" "time" "unicode" + "github.com/denisenkom/go-mssqldb/internal/querytext" + "github.com/denisenkom/go-mssqldb/msdsn" "github.com/golang-sql/sqlexp" - "github.com/microsoft/go-mssqldb/internal/querytext" - "github.com/microsoft/go-mssqldb/msdsn" ) // ReturnStatus may be used to return the return value from a proc. @@ -126,20 +125,6 @@ func NewConnector(dsn string) (*Connector, error) { return c, nil } -// NewConnectorWithAccessTokenProvider creates a new connector from a DSN using the given -// access token provider. The returned connector may be used with sql.OpenDB. -func NewConnectorWithAccessTokenProvider(dsn string, tokenProvider func(ctx context.Context) (string, error)) (*Connector, error) { - params, _, err := msdsn.Parse(dsn) - if err != nil { - return nil, err - } - - return NewSecurityTokenConnector( - params, - tokenProvider, - ) -} - // NewConnectorConfig creates a new Connector for a DSN Config struct. // The returned connector may be used with sql.OpenDB. func NewConnectorConfig(config msdsn.Config) *Connector { @@ -428,7 +413,6 @@ func (d *Driver) connect(ctx context.Context, c *Connector, params msdsn.Config) } func (c *Conn) Close() error { - c.sess.buf.bufClose() return c.sess.buf.transport.Close() } @@ -922,34 +906,6 @@ func (s *Stmt) makeParam(val driver.Value) (res param, err error) { return } switch val := val.(type) { - case int: - res.ti.TypeId = typeIntN - // Rather than guess if the caller intends to pass a 32bit int from a 64bit app based on the - // value of the int, we'll just match the runtime size of int. - // Apps that want a 32bit int should use int32 - if bits.UintSize == 32 { - res.buffer = make([]byte, 4) - res.ti.Size = 4 - binary.LittleEndian.PutUint32(res.buffer, uint32(val)) - } else { - res.buffer = make([]byte, 8) - res.ti.Size = 8 - binary.LittleEndian.PutUint64(res.buffer, uint64(val)) - } - case int8: - res.ti.TypeId = typeIntN - res.buffer = []byte{byte(val)} - res.ti.Size = 1 - case int16: - res.ti.TypeId = typeIntN - res.buffer = make([]byte, 2) - res.ti.Size = 2 - binary.LittleEndian.PutUint16(res.buffer, uint16(val)) - case int32: - res.ti.TypeId = typeIntN - res.buffer = make([]byte, 4) - res.ti.Size = 4 - binary.LittleEndian.PutUint32(res.buffer, uint32(val)) case int64: res.ti.TypeId = typeIntN res.buffer = make([]byte, 8) @@ -1118,6 +1074,7 @@ type Rowsq struct { stmt *Stmt cols []columnStruct reader *tokenProcessor + nextCols []columnStruct cancel func() requestDone bool inResultSet bool @@ -1145,11 +1102,8 @@ func (rc *Rowsq) Close() error { } } -// ProcessSingleResponse queues MsgNext for every columns token. -// data/sql calls Columns during the app's call to Next. +// data/sql calls Columns during the app's call to Next func (rc *Rowsq) Columns() (res []string) { - // r.cols is nil if the first query in a batch is a SELECT or similar query that returns a rowset. - // if will be non-nil for subsequent queries where NextResultSet() has populated it if rc.cols == nil { scan: for { @@ -1191,10 +1145,6 @@ func (rc *Rowsq) Next(dest []driver.Value) error { if tok == nil { return io.EOF } else { - switch tokdata := tok.(type) { - case doneInProcStruct: - tok = (doneStruct)(tokdata) - } switch tokdata := tok.(type) { case []interface{}: for i := range dest { @@ -1222,11 +1172,9 @@ func (rc *Rowsq) Next(dest []driver.Value) error { if rc.reader.outs.returnStatus != nil { *rc.reader.outs.returnStatus = tokdata } - case ServerError: - rc.requestDone = true - return tokdata } } + } else { return rc.stmt.c.checkBadConn(rc.reader.ctx, err, false) } @@ -1239,7 +1187,7 @@ func (rc *Rowsq) HasNextResultSet() bool { return !rc.requestDone } -// Scans to the end of the current statement being processed +// Scans to the next set of columns in the stream // Note that the caller may not have read all the rows in the prior set func (rc *Rowsq) NextResultSet() error { if rc.requestDone { @@ -1247,6 +1195,7 @@ func (rc *Rowsq) NextResultSet() error { } scan: for { + // we should have a columns token in the channel if we aren't at the end tok, err := rc.reader.nextToken() if rc.reader.sess.logFlags&logDebug != 0 { rc.reader.sess.logger.Log(rc.reader.ctx, msdsn.LogDebug, fmt.Sprintf("NextResultSet() token type:%v", reflect.TypeOf(tok))) @@ -1259,42 +1208,23 @@ scan: return io.EOF } switch tokdata := tok.(type) { - case doneInProcStruct: - tok = (doneStruct)(tokdata) - } - // ProcessSingleResponse queues a MsgNextResult for every "done" and "server error" token - // The only tokens to consume after a "done" should be "done", "server error", or "columns" - switch tokdata := tok.(type) { case []columnStruct: - rc.cols = tokdata + rc.nextCols = tokdata rc.inResultSet = true break scan case doneStruct: if tokdata.Status&doneMore == 0 { + rc.nextCols = nil rc.requestDone = true + break scan } - if tokdata.isError() { - e := rc.stmt.c.checkBadConn(rc.reader.ctx, tokdata.getError(), false) - switch e.(type) { - case Error: - // Ignore non-fatal server errors. Fatal errors are of type ServerError - default: - return e - } - } - rc.inResultSet = false - rc.cols = nil - break scan - case ReturnStatus: - if rc.reader.outs.returnStatus != nil { - *rc.reader.outs.returnStatus = tokdata - } - case ServerError: - rc.requestDone = true - return tokdata } } - + rc.cols = rc.nextCols + rc.nextCols = nil + if rc.cols == nil { + return io.EOF + } return nil } diff --git a/deps/go-mssqldb/mssql_go110_perf_test.go b/deps/go-mssqldb/mssql_go110_perf_test.go deleted file mode 100644 index b9ebd29..0000000 --- a/deps/go-mssqldb/mssql_go110_perf_test.go +++ /dev/null @@ -1,62 +0,0 @@ -//go:build go1.10 -// +build go1.10 - -package mssql - -import ( - "database/sql" - "testing" -) - -// The default value converter promotes every int type to bigint. -// This benchmark forces that mismatch for comparing the query performance with the -// fixed version of the driver that doesn't perform such promotion. -// It may not show much of a time difference. Look for the actual query via plan or xevents -// while the benchmark runs to make sure it's passing the correct int type. -func BenchmarkSelectWithTypeMismatch(b *testing.B) { - connector, err := NewConnector(makeConnStr(b).String()) - if err != nil { - b.Fatal("Open connection failed:", err.Error()) - } - conn := sql.OpenDB(connector) - defer conn.Close() - conn.SetMaxOpenConns(1) - conn.SetMaxIdleConns(1) - rows, err := conn.Query("select 'prime the pump'") - if err != nil { - b.Fatal("Unable to query") - } - rows.Close() - if rows.Err() != nil { - b.Fatal("Rows error:", rows.Err()) - } - b.Run("PromoteToBigInt", func(b *testing.B) { - for i := 0; i < b.N; i++ { - rows, err := conn.Query(`SELECT Count(*) from sys.all_objects where object_id > @obid`, sql.Named("obid", int64(-605853368))) - if err != nil { - b.Fatal("Query failed:", err.Error()) - } - defer rows.Close() - for rows.Next() { - } - if rows.Err() != nil { - b.Fatal("Rows error:", rows.Err()) - } - } - }) - b.Run("NoIntPromotion", func(b *testing.B) { - for i := 0; i < b.N; i++ { - rows, err := conn.Query(`SELECT Count(*) from sys.all_objects where object_id > @obid`, sql.Named("obid", int32(-605853368))) - if err != nil { - b.Fatal("Query failed:", err.Error()) - } - defer rows.Close() - for rows.Next() { - } - if rows.Err() != nil { - b.Fatal("Rows error:", rows.Err()) - } - } - }) - -} diff --git a/deps/go-mssqldb/mssql_go19.go b/deps/go-mssqldb/mssql_go19.go index 688b5c5..508b03a 100644 --- a/deps/go-mssqldb/mssql_go19.go +++ b/deps/go-mssqldb/mssql_go19.go @@ -1,4 +1,3 @@ -//go:build go1.9 // +build go1.9 package mssql @@ -43,8 +42,6 @@ type DateTimeOffset time.Time func convertInputParameter(val interface{}) (interface{}, error) { switch v := val.(type) { - case int, int16, int32, int64, int8: - return val, nil case VarChar: return val, nil case NVarCharMax: diff --git a/deps/go-mssqldb/mssql_test.go b/deps/go-mssqldb/mssql_test.go index 9c50b83..d1bab1b 100644 --- a/deps/go-mssqldb/mssql_test.go +++ b/deps/go-mssqldb/mssql_test.go @@ -10,7 +10,7 @@ import ( "reflect" "testing" - "github.com/microsoft/go-mssqldb/msdsn" + "github.com/denisenkom/go-mssqldb/msdsn" ) func TestBadOpen(t *testing.T) { diff --git a/deps/go-mssqldb/newconnector_example_test.go b/deps/go-mssqldb/newconnector_example_test.go index 28bfd5a..8dc74ba 100644 --- a/deps/go-mssqldb/newconnector_example_test.go +++ b/deps/go-mssqldb/newconnector_example_test.go @@ -12,7 +12,7 @@ import ( "net/url" "strconv" - mssql "github.com/microsoft/go-mssqldb" + mssql "github.com/denisenkom/go-mssqldb" ) var ( diff --git a/deps/go-mssqldb/queries_go19_test.go b/deps/go-mssqldb/queries_go19_test.go index 84ab00c..c1fabeb 100644 --- a/deps/go-mssqldb/queries_go19_test.go +++ b/deps/go-mssqldb/queries_go19_test.go @@ -1127,19 +1127,17 @@ func TestMessageQueue(t *testing.T) { msgs := []interface{}{ sqlexp.MsgNotice{Message: Error{Message: "msg1"}}, - sqlexp.MsgNextResultSet{}, sqlexp.MsgNext{}, sqlexp.MsgRowsAffected{Count: 1}, - sqlexp.MsgNextResultSet{}, sqlexp.MsgNotice{Message: Error{Message: "msg2"}}, sqlexp.MsgNextResultSet{}, - sqlexp.MsgNextResultSet{}, } i := 0 + rsCount := 0 for active { msg := retmsg.Message(ctx) if i >= len(msgs) { - t.Fatalf("Got extra message:%+v", reflect.TypeOf(msg)) + t.Fatalf("Got extra message:%+v", msg) } t.Log(reflect.TypeOf(msg)) if reflect.TypeOf(msgs[i]) != reflect.TypeOf(msg) { @@ -1150,6 +1148,10 @@ func TestMessageQueue(t *testing.T) { t.Log(m.Message) case sqlexp.MsgNextResultSet: active = rows.NextResultSet() + if active { + t.Fatal("NextResultSet returned true") + } + rsCount++ case sqlexp.MsgNext: if !rows.Next() { t.Fatal("rows.Next() returned false") @@ -1236,8 +1238,7 @@ select getdate() PRINT N'This is a message' select 199 RAISERROR (N'Testing!' , 11, 1) -declare @d int = 300 -select @d +select 300 ` func testMixedQuery(conn *sql.DB, b testing.TB) (msgs, errs, results, rowcounts int) { @@ -1368,135 +1369,3 @@ func TestCancelWithNoResults(t *testing.T) { t.Fatalf("Unexpected error: %v", r.Err()) } } - -const DropSprocWithCursor = `IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TestSqlCmd]') AND type in (N'P', N'PC')) -DROP PROCEDURE [dbo].[TestSqlCmd] -` - -// This query generates half a dozen tokenDoneInProc tokens which fill the channel if the app isn't scanning Rowsq -const CreateSprocWithCursor = ` -CREATE PROCEDURE [dbo].[TestSqlCmd] -AS -BEGIN - DECLARE @tmp int; - DECLARE Server_Cursor CURSOR FOR - SELECT 1 UNION SELECT 2 - OPEN Server_Cursor; - FETCH NEXT FROM Server_Cursor INTO @tmp; - WHILE @@FETCH_STATUS = 0 - BEGIN - PRINT @tmp - FETCH NEXT FROM Server_Cursor INTO @tmp; - END; - CLOSE Server_Cursor; - DEALLOCATE Server_Cursor; -END -` - -func TestSprocWithCursorNoResult(t *testing.T) { - conn, logger := open(t) - defer conn.Close() - defer logger.StopLogging() - - _, e := conn.Exec(DropSprocWithCursor) - if e != nil { - t.Fatalf("Unable to drop test sproc: %v", e) - } - _, e = conn.Exec(CreateSprocWithCursor) - if e != nil { - t.Fatalf("Unable to create test sproc: %v", e) - } - defer conn.Exec(DropSprocWithCursor) - latency, _ := getLatency(t) - ctx, cancel := context.WithTimeout(context.Background(), latency+500*time.Millisecond) - defer cancel() - retmsg := &sqlexp.ReturnMessage{} - // Use a sproc instead of the cursor loop directly to cover the different code path in token.go - r, err := conn.QueryContext(ctx, `exec [dbo].[TestSqlCmd]`, retmsg) - if err != nil { - t.Fatal(err.Error()) - } - defer r.Close() - active := true - rsCount := 0 - msgCount := 0 - for active { - msg := retmsg.Message(ctx) - t.Logf("Got a message: %v", reflect.TypeOf(msg)) - switch m := msg.(type) { - case sqlexp.MsgNext: - t.Fatalf("Got a MsgNext from a query with no rows") - case sqlexp.MsgError: - t.Fatalf("Got an error: %s", m.Error.Error()) - case sqlexp.MsgNotice: - msgCount++ - case sqlexp.MsgNextResultSet: - if active = r.NextResultSet(); active { - rsCount++ - } - } - } - if r.Err() != nil { - t.Fatalf("Got an error: %v", r.Err()) - } - if rsCount != 13 { - t.Fatalf("Unexpected record set count: %v", rsCount) - } - if msgCount != 2 { - t.Fatalf("Unexpected message count: %v", msgCount) - } -} - -func TestErrorAsLastResult(t *testing.T) { - conn, logger := open(t) - defer conn.Close() - defer logger.StopLogging() - latency, _ := getLatency(t) - ctx, cancel := context.WithTimeout(context.Background(), latency+5000*time.Millisecond) - defer cancel() - retmsg := &sqlexp.ReturnMessage{} - // Use a sproc instead of the cursor loop directly to cover the different code path in token.go - r, err := conn.QueryContext(ctx, - ` - Print N'message' - select 1 - raiserror(N'Error!', 16, 1)`, - retmsg) - if err != nil { - t.Fatal(err.Error()) - } - defer r.Close() - active := true - d := 0 - err = nil - for active { - msg := retmsg.Message(ctx) - t.Logf("Got a message: %s", reflect.TypeOf(msg)) - switch m := msg.(type) { - case sqlexp.MsgNext: - if !r.Next() { - t.Fatalf("Next returned false") - } - r.Scan(&d) - if r.Next() { - t.Fatal("Second Next returned true") - } - case sqlexp.MsgError: - err = m.Error - case sqlexp.MsgNextResultSet: - active = r.NextResultSet() - } - } - if err == nil { - t.Fatal("Should have gotten an error message") - } else { - switch e := err.(type) { - case Error: - if e.Message != "Error!" || e.Class != 16 { - t.Fatalf("Got the wrong mssql error %v", e) - } - default: - t.Fatalf("Got an unexpected error %v", e) - } - } -} diff --git a/deps/go-mssqldb/queries_test.go b/deps/go-mssqldb/queries_test.go index 8e0c776..2b1125d 100644 --- a/deps/go-mssqldb/queries_test.go +++ b/deps/go-mssqldb/queries_test.go @@ -16,7 +16,7 @@ import ( "testing" "time" - "github.com/microsoft/go-mssqldb/msdsn" + "github.com/denisenkom/go-mssqldb/msdsn" ) func driverWithProcess(t *testing.T, tl Logger) *Driver { @@ -488,10 +488,6 @@ func TestParams(t *testing.T) { } values := []interface{}{ int64(5), - int32(10), - int16(20), - int8(40), - int(10000), "hello", "", []byte{1, 2, 3}, @@ -529,19 +525,6 @@ func TestParams(t *testing.T) { } case time.Time: same = decodedval.UTC() == val - case int64: - switch intVal := val.(type) { - case int16: - same = decodedval == int64(intVal) - case int32: - same = decodedval == int64(intVal) - case int8: - same = decodedval == int64(intVal) - case int: - same = decodedval == int64(intVal) - default: - same = retval == val - } default: same = retval == val } @@ -1606,10 +1589,10 @@ func TestColumnTypeIntrospection(t *testing.T) { {"cast('abc' as varbinary(max))", "VARBINARY", reflect.TypeOf([]byte{}), true, 2147483645, false, 0, 0}, {"cast(1 as datetime)", "DATETIME", reflect.TypeOf(time.Time{}), false, 0, false, 0, 0}, {"cast(1 as smalldatetime)", "SMALLDATETIME", reflect.TypeOf(time.Time{}), false, 0, false, 0, 0}, - {"cast(getdate() as datetime2(7))", "DATETIME2", reflect.TypeOf(time.Time{}), false, 0, true, 0, 7}, - {"cast(getdate() as datetimeoffset(7))", "DATETIMEOFFSET", reflect.TypeOf(time.Time{}), false, 0, true, 0, 7}, + {"cast(getdate() as datetime2(7))", "DATETIME2", reflect.TypeOf(time.Time{}), false, 0, false, 0, 0}, + {"cast(getdate() as datetimeoffset(7))", "DATETIMEOFFSET", reflect.TypeOf(time.Time{}), false, 0, false, 0, 0}, {"cast(getdate() as date)", "DATE", reflect.TypeOf(time.Time{}), false, 0, false, 0, 0}, - {"cast(getdate() as time)", "TIME", reflect.TypeOf(time.Time{}), false, 0, true, 0, 7}, + {"cast(getdate() as time)", "TIME", reflect.TypeOf(time.Time{}), false, 0, false, 0, 0}, {"'abc'", "VARCHAR", reflect.TypeOf(""), true, 3, false, 0, 0}, {"cast('abc' as varchar(max))", "VARCHAR", reflect.TypeOf(""), true, 2147483645, false, 0, 0}, {"N'abc'", "NVARCHAR", reflect.TypeOf(""), true, 3, false, 0, 0}, diff --git a/deps/go-mssqldb/tds.go b/deps/go-mssqldb/tds.go index dfc65c3..dbe9527 100644 --- a/deps/go-mssqldb/tds.go +++ b/deps/go-mssqldb/tds.go @@ -9,16 +9,14 @@ import ( "io" "io/ioutil" "net" - "reflect" "sort" "strconv" "strings" "time" "unicode/utf16" "unicode/utf8" - "unsafe" - "github.com/microsoft/go-mssqldb/msdsn" + "github.com/denisenkom/go-mssqldb/msdsn" ) func parseInstances(msg []byte) map[string]map[string]string { @@ -470,150 +468,15 @@ func str2ucs2(s string) []byte { return ucs2 } -const ( - mask64 uint64 = 0xFF80FF80FF80FF80 - mask32 uint32 = 0xFF80FF80 - mask16 uint16 = 0xFF80 -) - func ucs22str(s []byte) (string, error) { if len(s)%2 != 0 { return "", fmt.Errorf("illegal UCS2 string length: %d", len(s)) } - - // allocate a buffer which we will attempt to copy ascii into, optimistically, as we validate - buf := make([]byte, len(s)/2) - useFastPath := true - - // how many 8 byte chunks are in the input buffer - nlen8 := len(s) & 0xFFFFFFF8 - // our read and write offsets into the buffers - var ( - readIndex int - writeIndex int - ) - - // step through in 8 byte chunks. - for readIndex = 0; readIndex < nlen8; readIndex += 8 { - - // dereference directly into the array as uint64s - ui64 := *(*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(&s[0])) + uintptr(readIndex))) - - // mask the entire 64 bit region and check for - // 1) even bytes > 0 - // 2) odd bytes with their high bit set - // the mask for this is FF80.... - if ui64&mask64 > 0 { - // if we find a value once masked, we have to take the slow path as this is not an ascii string - useFastPath = false - break - } - - // we are ok to read out the 4 odd bytes and remove the empty even bytes - var ui32 uint32 = 0 - ui32 |= uint32(byte(ui64)) - ui64 = ui64 >> 8 - - ui32 |= uint32(uint16(ui64)) - ui64 = ui64 >> 8 - - ui32 |= uint32(ui64 & 0xFF0000) - ui64 = ui64 >> 8 - ui32 |= uint32(ui64 & 0xFF000000) - - // write the new 32 bit value to the destination buffer - ptrui32 := ((*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&buf[0])) + uintptr(writeIndex)))) - *ptrui32 = ui32 - - // step forward four bytes in the destinaiton buffer - writeIndex += 4 - } - - // can we continue reading on the fast ascii path? - if useFastPath { - // we have now dealt with all the avalable 8 byte chunks, we have at most 7 bytes remaining. - - // have we got at least 4 bytes remaining to be read? - if len(s)-readIndex >= 4 { - // deal with the next 32 bit region - - // read 32 bits from the current read position in the source slice - ui32 := *(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&s[0])) + uintptr(readIndex))) - - // mask the 32 bit value as above. again, if we find a value - // this is not ascii and we need to fall back to the slow path - // this time with a 32 bit mask - if ui32&mask32 > 0 { - // we have found non ascii text and must fallback - useFastPath = false - } else { - - // read the two odd positions bytes and write as a single 16 bit value - var ui16 uint16 = 0 - ui16 |= uint16(byte(ui32)) - ui32 = ui32 >> 8 - - ui16 |= uint16(ui32) - - ptrui16 := ((*uint16)(unsafe.Pointer(uintptr(unsafe.Pointer(&buf[0])) + uintptr((writeIndex))))) - *ptrui16 = ui16 - - // step forward the read and write positions. - readIndex += 4 - writeIndex += 2 - } - } - - // Are we still on the fast path? - if useFastPath { - // have we got at least 2 bytes remaining to be read? - // actually we can only have at most 2 bytes at this point - // since we know the source buffer has even length. - if len(s)-readIndex >= 2 { - - // read 2 bytes - ui16 := *(*uint16)(unsafe.Pointer(uintptr(unsafe.Pointer(&s[0])) + uintptr(readIndex))) - - // mask again, but only 16bits - if ui16&mask16 == 0 { - // manually pull out the low byte and write to our destination buffer - buf[writeIndex] = byte(ui16 & 0xFF) - // we have now successfully read the entire ascii buffer and can convert to a string - return *(*string)(unsafe.Pointer(&buf)), nil - } - } else { - // there were no further bytes to read, but we have successfully read the ascii - // and can convert to a string - return *(*string)(unsafe.Pointer(&buf)), nil - } - } + buf := make([]uint16, len(s)/2) + for i := 0; i < len(s); i += 2 { + buf[i/2] = binary.LittleEndian.Uint16(s[i:]) } - - // one of the above checks has found non ascii values in the buffer, either - // a high bit set in an odd byte or any non zero in an even byte. - // we fall back to a slower conversion here. - - // we can reuse the underlying array and create our own uint16 slice here - // because utf16.Decode allocates a new buffer and only reads its input. - - // declare a real uint16 slice so that the compiler can keep track of - // the underlying memory as we transfer & convert it. - // This is to ensure that the GC does not prematurely collect our data. - var uint16slice []uint16 - - uint16Header := (*reflect.SliceHeader)(unsafe.Pointer(&uint16slice)) - sourceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&s)) - - uint16Header.Data = sourceHeader.Data - // it is important to reference s after the assignment of the Data - // pointer to make sure that s is not garbage collected before - // we have another reference to the data. - uint16Header.Len = len(s) / 2 // the output is half the length in bytes - uint16Header.Cap = uint16Header.Len // the capacity is also half the number of bytes - - // decode the uint16s as utf-16 and return a string. - // After this point both s and uint16slice can be garbage collected. - return string(utf16.Decode(uint16slice)), nil + return string(utf16.Decode(buf)), nil } func manglePassword(password string) []byte { @@ -822,7 +685,7 @@ func writeUsVarChar(w io.Writer, s string) (err error) { return } -func readBVarChar(r io.Reader) (string, error) { +func readBVarChar(r io.Reader) (res string, err error) { numchars, err := readByte(r) if err != nil { return "", err @@ -1187,16 +1050,14 @@ func connect(ctx context.Context, c *Connector, logger ContextLogger, p msdsn.Co dialCtx, cancel = context.WithTimeout(ctx, dt) defer cancel() } - // if instance is specified use instance resolution service if len(p.Instance) > 0 && p.Port != 0 && uint64(p.LogFlags)&logDebug != 0 { // both instance name and port specified // when port is specified instance name is not used // you should not provide instance name when you provide port logger.Log(ctx, msdsn.LogDebug, "WARN: You specified both instance name and port in the connection string, port will be used and instance name will be ignored") - } else if len(p.Instance) > 0 && p.Port == 0 { - // If instance is specified, but no port, check SQL Server Browser - // for the instance and discover its port. + } + if len(p.Instance) > 0 { p.Instance = strings.ToUpper(p.Instance) d := c.getDialer(&p) instances, err := getInstances(dialCtx, d, p.Host) @@ -1216,7 +1077,6 @@ func connect(ctx context.Context, c *Connector, logger ContextLogger, p msdsn.Co } p.Port = port } - if p.Port == 0 { p.Port = defaultServerPort } @@ -1282,7 +1142,7 @@ initiate_connection: if config.DynamicRecordSizingDisabled == false { config = config.Clone() - // fix for https://github.com/microsoft/go-mssqldb/issues/166 + // fix for https://github.com/denisenkom/go-mssqldb/issues/166 // Go implementation of TLS payload size heuristic algorithm splits single TDS package to multiple TCP segments, // while SQL Server seems to expect one TCP segment per encrypted TDS package. // Setting DynamicRecordSizingDisabled to true disables that algorithm and uses 16384 bytes per TLS package diff --git a/deps/go-mssqldb/tds_login_test.go b/deps/go-mssqldb/tds_login_test.go index 3bb11e5..f7c4cb7 100644 --- a/deps/go-mssqldb/tds_login_test.go +++ b/deps/go-mssqldb/tds_login_test.go @@ -11,7 +11,7 @@ import ( "sync/atomic" "testing" - "github.com/microsoft/go-mssqldb/msdsn" + "github.com/denisenkom/go-mssqldb/msdsn" ) type MockTransportDialer struct { diff --git a/deps/go-mssqldb/tds_test.go b/deps/go-mssqldb/tds_test.go index 0caeed8..7d9af0d 100644 --- a/deps/go-mssqldb/tds_test.go +++ b/deps/go-mssqldb/tds_test.go @@ -13,13 +13,11 @@ import ( "os" "path" "runtime" - "strings" "sync" "testing" "time" - "unicode/utf16" - "github.com/microsoft/go-mssqldb/msdsn" + "github.com/denisenkom/go-mssqldb/msdsn" ) type MockTransport struct { @@ -586,32 +584,6 @@ func TestBadHost(t *testing.T) { testConnectionBad(t, params.URL().String()) } -func TestSqlBrowserNotUsedIfPortSpecified(t *testing.T) { - const errorSubstrStringToCheckFor = "unable to get instances from Sql Server Browser" - - // Connect to an instance on a host that doesn't exist (so connection will always expectedly fail) - params := testConnParams(t) - params.Host = "badhost" - params.Instance = "foobar" - - // Specify no port, so error must indicate SQL Browser lookup failed - params.Port = 0 // No port spcified, sql browser should be used - - err := testConnectionBad(t, params.URL().String()) - - if !strings.Contains(err.Error(), errorSubstrStringToCheckFor) { - t.Fatal("Connection should have tried to use SQL Browser") - } - - // Specify port, ensure error does not indicate SQL Browser lookup failed - params.Port = 1500 // Specify a port, sql browser should not be tried - err = testConnectionBad(t, params.URL().String()) - - if strings.Contains(err.Error(), errorSubstrStringToCheckFor) { - t.Fatal("Connection should not have tried to use SQL Browser, because none zero Port specified") - } -} - func TestSSPIAuth(t *testing.T) { if runtime.GOOS != "windows" { t.Skip("Only on windows") @@ -658,160 +630,6 @@ func TestUcs22Str(t *testing.T) { } } -var encoded123456789Bytes = []byte{0x31, 0, 0x32, 0, 0x33, 0, 0x34, 0, 0x35, 0, 0x36, 0, 0x37, 0, 0x38, 0, 0x39, 0} -var encoded12345678Bytes = []byte{0x31, 0, 0x32, 0, 0x33, 0, 0x34, 0, 0x35, 0, 0x36, 0, 0x37, 0, 0x38, 0} -var encoded1234567Bytes = []byte{0x31, 0, 0x32, 0, 0x33, 0, 0x34, 0, 0x35, 0, 0x36, 0, 0x37, 0} -var encoded123456Bytes = []byte{0x31, 0, 0x32, 0, 0x33, 0, 0x34, 0, 0x35, 0, 0x36, 0} -var encoded12345Bytes = []byte{0x31, 0, 0x32, 0, 0x33, 0, 0x34, 0, 0x35, 0} -var encoded1234Bytes = []byte{0x31, 0, 0x32, 0, 0x33, 0, 0x34, 0} -var encoded123Bytes = []byte{0x31, 0, 0x32, 0, 0x33, 0} -var encoded12Bytes = []byte{0x31, 0, 0x32, 0} -var encoded1Bytes = []byte{0x31, 0} - -var encodedLongASCIIBytes = []byte{0x31, 0, 0x32, 0, 0x33, 0, 0x34, 0, 0x35, 0, 0x36, 0, 0x37, 0, 0x38, 0, 0x39, 0, - // a-z - 0x61, 0x0, 0x62, 0x0, 0x63, 0x0, 0x64, 0x0, 0x65, 0x0, 0x66, 0x0, 0x67, 0x0, 0x68, 0x0, 0x69, 0x0, 0x6a, 0x0, 0x6b, 0x0, 0x6c, 0x0, 0x6d, 0x0, 0x6e, 0x0, 0x6f, 0x0, 0x70, 0x0, 0x71, 0x0, 0x72, 0x0, 0x73, 0x0, 0x74, 0x0, 0x75, 0x0, 0x76, 0x0, 0x77, 0x0, 0x78, 0x0, 0x79, 0x0, 0x7a, 0x0, - // A-Z - 0x41, 0x0, 0x42, 0x0, 0x43, 0x0, 0x44, 0x0, 0x45, 0x0, 0x46, 0x0, 0x47, 0x0, 0x48, 0x0, 0x49, 0x0, 0x4a, 0x0, 0x4b, 0x0, 0x4c, 0x0, 0x4d, 0x0, 0x4e, 0x0, 0x4f, 0x0, 0x50, 0x0, 0x51, 0x0, 0x52, 0x0, 0x53, 0x0, 0x54, 0x0, 0x55, 0x0, 0x56, 0x0, 0x57, 0x0, 0x58, 0x0, 0x59, 0x0, 0x5a, 0x0, -} -var decodedLongASCIIString string = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - -// multiple copies of the above -var encodedLongerASCIIBytes []byte -var decodedLongerASCIIString string - -var encodedUnicode1 = []byte{0x61, 0x0, 0x62, 0x0, 0x63, 0x0, 0x64, 0x0, 0x65, 0x0, 0x66, 0x0, 0x67, 0x0, 0x68, 0x0, 0x69, 0x0, 0x6a, 0x1} -var encodedUnicode2 = []byte{0x61, 0x0, 0x62, 0x0, 0x63, 0x0, 0x64, 0x0, 0x65, 0x0, 0x66, 0x0, 0x67, 0x0, 0x68, 0x0, 0x69, 0x0, 0x6a, 0x0, 0x6b, 0x0, 0x6c, 0x0, 0x6d, 0x1} -var encodedUnicode3 = []byte{0x61, 0x0, 0x62, 0x0, 0x63, 0x0, 0x64, 0x0, 0x65, 0x0, 0x66, 0x0, 0x67, 0x0, 0x68, 0x0, 0x69, 0x0, 0x6a, 0x0, 0x6b, 0x0, 0x6c, 0x0, 0x6d, 0x1, 0x1, 0x1} -var encodedASCIIWithTrailingUnicode = []byte{0x61, 0x0, 0x62, 0x0, 0x63, 0x0, 0x64, 0x0, 0x65, 0x0, 0x66, 0x0, 0x67, 0x0, 0x68, 0x0, 0x69, 0x0, 0x6a, 0x0, 0x6b, 0x0, 0x6c, 0x0, 0x6d, 0x0, 0x6e, 0x0, 0x6f, 0x0, 0x7e, 0x76, 0x70, 0x0} -var stringASCIIWithTrailingUnicode = "abcdefghijklmno百p" -var longEmoji = "😀😃😄😁😆😅🤣😂🙂🙃😉😊😇😍🤩😘😗" -var longEmojiBytes []byte -var encodedASCIIWithTrailingUnicode2 []byte - -// create various test strings and byte slices for the ucs22str function -func init() { - - uint16s := utf16.Encode([]rune(longEmoji)) - - longEmojiBytes = make([]byte, len(uint16s)*2) - - for i := 0; i < len(uint16s); i++ { - longEmojiBytes[i*2] = byte(uint16s[i] & 0xFF) - longEmojiBytes[(i*2)+1] = byte((uint16s[i] >> 8) & 0xFF) - } - - uint16s = utf16.Encode([]rune(stringASCIIWithTrailingUnicode)) - - encodedASCIIWithTrailingUnicode2 = make([]byte, len(uint16s)*2) - - for i := 0; i < len(uint16s); i++ { - encodedASCIIWithTrailingUnicode2[i*2] = byte(uint16s[i] & 0xFF) - encodedASCIIWithTrailingUnicode2[(i*2)+1] = byte((uint16s[i] >> 8) & 0xFF) - } - - equal := bytes.Compare(encodedASCIIWithTrailingUnicode, encodedASCIIWithTrailingUnicode2) - - if equal != 0 { - fmt.Print("Expected array to equal.") - } - - for i := 0; i < 10; i++ { - encodedLongerASCIIBytes = append(encodedLongerASCIIBytes, encodedLongASCIIBytes...) - decodedLongerASCIIString = decodedLongerASCIIString + decodedLongASCIIString - } -} - -func ExerciseUCS2ToStringFunction(name string, sut func([]byte) (string, error), t *testing.T) { - - tests := []struct { - name string - input []byte - expected string - }{ - {"Ascii 1", encoded1Bytes, "1"}, - {"Ascii 2", encoded12Bytes, "12"}, - {"Ascii 3", encoded123Bytes, "123"}, - {"Ascii 4", encoded1234Bytes, "1234"}, - {"Ascii 5", encoded12345Bytes, "12345"}, - {"Ascii 6", encoded123456Bytes, "123456"}, - {"Ascii 7", encoded1234567Bytes, "1234567"}, - {"Ascii 8", encoded12345678Bytes, "12345678"}, - {"Ascii 9", encoded123456789Bytes, "123456789"}, - {"Long Ascii", encodedLongASCIIBytes, decodedLongASCIIString}, - {"Longer Ascii", encodedLongerASCIIBytes, decodedLongerASCIIString}, - {"Random Unicode1", encodedUnicode1, "abcdefghiŪ"}, - {"Random Unicode2", encodedUnicode2, "abcdefghijklŭ"}, - {"Random Unicode3", encodedUnicode3, "abcdefghijklŭā"}, - {"TrailingUnicode", encodedASCIIWithTrailingUnicode, stringASCIIWithTrailingUnicode}, - {"LongEmoji", longEmojiBytes, longEmoji}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - - actual, err := sut(tt.input) - - if err != nil { - t.Errorf("%s errored: %s", name, err) - } - - if actual != tt.expected { - t.Errorf("%s expected to return %s but it returned %s", name, tt.expected, actual) - } - }) - } -} - -func TestUcs22str(t *testing.T) { - ExerciseUCS2ToStringFunction("ucs22str", ucs22str, t) -} - -var sideeffect_varchar string - -//ucs22str benchmarks -func BenchmarkUcs22strAscii(b *testing.B) { - for n := 0; n < b.N; n++ { - s, _ := ucs22str(encoded123Bytes) - sideeffect_varchar = s - } -} - -func BenchmarkUcs22strMediumAscii(b *testing.B) { - for n := 0; n < b.N; n++ { - s, _ := ucs22str(encoded123456789Bytes) - sideeffect_varchar = s - } -} - -func BenchmarkUcs22strLongAscii(b *testing.B) { - for n := 0; n < b.N; n++ { - s, _ := ucs22str(encodedLongASCIIBytes) - sideeffect_varchar = s - } -} - -func BenchmarkUcs22strLongerAscii(b *testing.B) { - for n := 0; n < b.N; n++ { - s, _ := ucs22str(encodedLongerASCIIBytes) - sideeffect_varchar = s - } -} - -func BenchmarkUcs22strTrailingUnicode(b *testing.B) { - for n := 0; n < b.N; n++ { - s, _ := ucs22str(encodedASCIIWithTrailingUnicode) - sideeffect_varchar = s - } -} - -func BenchmarkUcs22strLongEmojis(b *testing.B) { - for n := 0; n < b.N; n++ { - s, _ := ucs22str(longEmojiBytes) - sideeffect_varchar = s - } -} - func TestReadUcs2(t *testing.T) { buf := bytes.NewBuffer([]byte{0x31, 0, 0x32, 0, 0x33, 0}) // 123 in UCS2 encoding s, err := readUcs2(buf, 3) diff --git a/deps/go-mssqldb/token.go b/deps/go-mssqldb/token.go index 5f9e820..61c88fc 100644 --- a/deps/go-mssqldb/token.go +++ b/deps/go-mssqldb/token.go @@ -9,8 +9,8 @@ import ( "io/ioutil" "strconv" + "github.com/denisenkom/go-mssqldb/msdsn" "github.com/golang-sql/sqlexp" - "github.com/microsoft/go-mssqldb/msdsn" ) //go:generate go run golang.org/x/tools/cmd/stringer -type token @@ -49,20 +49,6 @@ const ( doneSrvError = 0x100 ) -// CurCmd values in done (undocumented) -const ( - cmdSelect = 0xc1 - // cmdInsert = 0xc3 - // cmdDelete = 0xc4 - // cmdUpdate = 0xc5 - // cmdAbort = 0xd2 - // cmdBeginXaxt = 0xd4 - // cmdEndXact = 0xd5 - // cmdBulkInsert = 0xf0 - // cmdOpenCursor = 0x20 - // cmdMerge = 0x117 -) - // ENVCHANGE types // http://msdn.microsoft.com/en-us/library/dd303449.aspx const ( @@ -659,6 +645,7 @@ func parseReturnValue(r *tdsBuffer) (nv namedValue) { } func processSingleResponse(ctx context.Context, sess *tdsSession, ch chan tokenStruct, outs outputs) { + firstResult := true defer func() { if err := recover(); err != nil { if sess.logFlags&logErrors != 0 { @@ -668,7 +655,7 @@ func processSingleResponse(ctx context.Context, sess *tdsSession, ch chan tokenS } close(ch) }() - colsReceived := false + packet_type, err := sess.buf.BeginRead() if err != nil { if sess.logFlags&logErrors != 0 { @@ -710,26 +697,18 @@ func processSingleResponse(ctx context.Context, sess *tdsSession, ch chan tokenS done := parseDoneInProc(sess.buf) ch <- done - if done.Status&doneCount != 0 { - if sess.logFlags&logRows != 0 { - sess.logger.Log(ctx, msdsn.LogRows, fmt.Sprintf("(%d rows affected)", done.RowCount)) - } + if sess.logFlags&logRows != 0 && done.Status&doneCount != 0 { + sess.logger.Log(ctx, msdsn.LogRows, fmt.Sprintf("(%d rows affected)", done.RowCount)) - if (colsReceived || done.CurCmd != cmdSelect) && outs.msgq != nil { + if outs.msgq != nil { _ = sqlexp.ReturnMessageEnqueue(ctx, outs.msgq, sqlexp.MsgRowsAffected{Count: int64(done.RowCount)}) } } - if outs.msgq != nil { - // For now we ignore ctx->Done errors that ReturnMessageEnqueue might return - // It's not clear how to handle them correctly here, and data/sql seems - // to set Rows.Err correctly when ctx expires already - _ = sqlexp.ReturnMessageEnqueue(ctx, outs.msgq, sqlexp.MsgNextResultSet{}) - } - colsReceived = false if done.Status&doneMore == 0 { - // Rows marks the request as done when seeing this done token. We queue another result set message - // so the app calls NextResultSet again which will return false. if outs.msgq != nil { + // For now we ignore ctx->Done errors that ReturnMessageEnqueue might return + // It's not clear how to handle them correctly here, and data/sql seems + // to set Rows.Err correctly when ctx expires already _ = sqlexp.ReturnMessageEnqueue(ctx, outs.msgq, sqlexp.MsgNextResultSet{}) } return @@ -750,24 +729,16 @@ func processSingleResponse(ctx context.Context, sess *tdsSession, ch chan tokenS } return } + if sess.logFlags&logRows != 0 && done.Status&doneCount != 0 { + sess.logger.Log(ctx, msdsn.LogRows, fmt.Sprintf("(%d row(s) affected)", done.RowCount)) + } ch <- done if done.Status&doneCount != 0 { - if sess.logFlags&logRows != 0 { - sess.logger.Log(ctx, msdsn.LogRows, fmt.Sprintf("(%d row(s) affected)", done.RowCount)) - } - - if (colsReceived || done.CurCmd != cmdSelect) && outs.msgq != nil { + if outs.msgq != nil { _ = sqlexp.ReturnMessageEnqueue(ctx, outs.msgq, sqlexp.MsgRowsAffected{Count: int64(done.RowCount)}) } - - } - colsReceived = false - if outs.msgq != nil { - _ = sqlexp.ReturnMessageEnqueue(ctx, outs.msgq, sqlexp.MsgNextResultSet{}) } if done.Status&doneMore == 0 { - // Rows marks the request as done when seeing this done token. We queue another result set message - // so the app calls NextResultSet again which will return false. if outs.msgq != nil { _ = sqlexp.ReturnMessageEnqueue(ctx, outs.msgq, sqlexp.MsgNextResultSet{}) } @@ -776,10 +747,14 @@ func processSingleResponse(ctx context.Context, sess *tdsSession, ch chan tokenS case tokenColMetadata: columns = parseColMetadata72(sess.buf) ch <- columns - colsReceived = true + if outs.msgq != nil { + if !firstResult { + _ = sqlexp.ReturnMessageEnqueue(ctx, outs.msgq, sqlexp.MsgNextResultSet{}) + } _ = sqlexp.ReturnMessageEnqueue(ctx, outs.msgq, sqlexp.MsgNext{}) } + firstResult = false case tokenRow: row := make([]interface{}, len(columns)) diff --git a/deps/go-mssqldb/tvp_example_test.go b/deps/go-mssqldb/tvp_example_test.go index 2f8ede5..c27f98e 100644 --- a/deps/go-mssqldb/tvp_example_test.go +++ b/deps/go-mssqldb/tvp_example_test.go @@ -8,7 +8,7 @@ import ( "fmt" "log" - mssql "github.com/microsoft/go-mssqldb" + mssql "github.com/denisenkom/go-mssqldb" ) // This example shows how to use tvp type diff --git a/deps/go-mssqldb/types.go b/deps/go-mssqldb/types.go index 8780341..822a7d8 100644 --- a/deps/go-mssqldb/types.go +++ b/deps/go-mssqldb/types.go @@ -10,8 +10,8 @@ import ( "strconv" "time" - "github.com/microsoft/go-mssqldb/internal/cp" - "github.com/microsoft/go-mssqldb/internal/decimal" + "github.com/denisenkom/go-mssqldb/internal/cp" + "github.com/denisenkom/go-mssqldb/internal/decimal" ) // fixed-length data types @@ -1543,13 +1543,13 @@ func makeGoLangTypePrecisionScale(ti typeInfo) (int64, int64, bool) { panic("invalid size of DATETIMEN") } case typeDateTime2N: - return int64(ti.Prec), int64(ti.Scale), true + return 0, 0, false case typeDateN: return 0, 0, false case typeTimeN: - return int64(ti.Prec), int64(ti.Scale), true + return 0, 0, false case typeDateTimeOffsetN: - return int64(ti.Prec), int64(ti.Scale), true + return 0, 0, false case typeBigVarBin: return 0, 0, false case typeVarChar: diff --git a/go.mod b/go.mod index 8628037..6b76d30 100644 --- a/go.mod +++ b/go.mod @@ -2,13 +2,14 @@ module github.com/PGSSoft/terraform-provider-mssql go 1.18 -replace github.com/microsoft/go-mssqldb v0.15.0 => ./deps/go-mssqldb +replace github.com/denisenkom/go-mssqldb v0.12.2 => ./deps/go-mssqldb require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql v1.0.0 github.com/DATA-DOG/go-sqlmock v1.5.0 + github.com/denisenkom/go-mssqldb v0.12.2 github.com/docker/docker v20.10.17+incompatible github.com/docker/go-connections v0.4.0 github.com/glendc/go-external-ip v0.1.0 @@ -16,7 +17,6 @@ require ( github.com/hashicorp/terraform-plugin-framework v0.9.0 github.com/hashicorp/terraform-plugin-go v0.10.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0 - github.com/microsoft/go-mssqldb v0.15.0 github.com/microsoft/kiota-authentication-azure-go v0.3.1 github.com/microsoftgraph/msgraph-sdk-go v0.30.0 github.com/stretchr/testify v1.8.0 diff --git a/go.sum b/go.sum index 6647900..b448091 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1 h1:tz19qLF65vuu2ibfTqGVJxG/zZAI27NEIIbvAOQwYbw= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql v1.0.0 h1:rycGPpUtVFwM9uLUL2ux8EL8kGfl3qF1u76aEHvB4Qw= @@ -62,7 +64,6 @@ github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= @@ -105,7 +106,6 @@ github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= @@ -274,6 +274,7 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= @@ -341,10 +342,10 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -366,12 +367,11 @@ golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -406,13 +406,10 @@ golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220224120231-95c6836cb0e7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -478,7 +475,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/provider/main_test.go b/internal/provider/main_test.go index b38612f..07291d3 100644 --- a/internal/provider/main_test.go +++ b/internal/provider/main_test.go @@ -9,6 +9,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql" "github.com/PGSSoft/terraform-provider-mssql/internal/sql" + "github.com/denisenkom/go-mssqldb/azuread" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" @@ -19,7 +20,6 @@ import ( "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/microsoft/go-mssqldb/azuread" a "github.com/microsoft/kiota-authentication-azure-go" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" "github.com/stretchr/testify/require" diff --git a/internal/sql/azureAuth.go b/internal/sql/azureAuth.go index e03ea62..6de7a00 100644 --- a/internal/sql/azureAuth.go +++ b/internal/sql/azureAuth.go @@ -3,8 +3,8 @@ package sql import ( "context" "fmt" + "github.com/denisenkom/go-mssqldb/azuread" "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/microsoft/go-mssqldb/azuread" "net/url" ) diff --git a/internal/sql/connection.go b/internal/sql/connection.go index 8e7f41c..4faaed5 100644 --- a/internal/sql/connection.go +++ b/internal/sql/connection.go @@ -7,9 +7,9 @@ import ( "net/url" "regexp" + _ "github.com/denisenkom/go-mssqldb" + _ "github.com/denisenkom/go-mssqldb/azuread" "github.com/hashicorp/terraform-plugin-framework/diag" - _ "github.com/microsoft/go-mssqldb" - _ "github.com/microsoft/go-mssqldb/azuread" ) var azureSQLEditionPattern = regexp.MustCompile("^SQL Azure.*")