mirror of
https://github.com/documize/community.git
synced 2025-07-25 08:09:43 +02:00
Merge pull request #238 from documize/mssqlserver
Microsoft SQL Server 2016+ database support
This commit is contained in:
commit
eecf316d50
94 changed files with 75577 additions and 838 deletions
23
Gopkg.lock
generated
23
Gopkg.lock
generated
|
@ -1,6 +1,14 @@
|
|||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b62a3c5b37db602bf1158e921da1a762315a4c37855fd418a14498aa87a342d5"
|
||||
name = "cloud.google.com/go"
|
||||
packages = ["civil"]
|
||||
pruneopts = "UT"
|
||||
revision = "2fa99f4c25c422525316dcb1fd3d5b94e1944cfd"
|
||||
version = "v0.37.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:606d068450c82b9ddaa21de992f73563754077f0f411235cdfe71d0903a268c3"
|
||||
name = "github.com/codegangsta/negroni"
|
||||
|
@ -9,6 +17,17 @@
|
|||
revision = "5dbbc83f748fc3ad38585842b0aedab546d0ea1e"
|
||||
version = "v0.3.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:cf0505eb7d4704d5ab445353dc64122acf56d13937e20dac5570b995cb21232c"
|
||||
name = "github.com/denisenkom/go-mssqldb"
|
||||
packages = [
|
||||
".",
|
||||
"internal/cp",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "a8ed825ac8537383ef814eaf5a16174751796a2b"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:217f778e19b8d206112c21d21a7cc72ca3cb493b67631680a2324bc50335d432"
|
||||
name = "github.com/dgrijalva/jwt-go"
|
||||
|
@ -188,11 +207,12 @@
|
|||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:1ecf2a49df33be51e757d0033d5d51d5f784f35f68e5a38f797b2d3f03357d71"
|
||||
digest = "1:68344dbfaa4179bb50a583eb8172ace3f1edaf3aebc24e68c03f549f6e6b60dc"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = [
|
||||
"bcrypt",
|
||||
"blowfish",
|
||||
"md4",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "650f4a345ab4e5b245a3034b110ebc7299e68186"
|
||||
|
@ -275,6 +295,7 @@
|
|||
analyzer-version = 1
|
||||
input-imports = [
|
||||
"github.com/codegangsta/negroni",
|
||||
"github.com/denisenkom/go-mssqldb",
|
||||
"github.com/dgrijalva/jwt-go",
|
||||
"github.com/documize/blackfriday",
|
||||
"github.com/documize/glick",
|
||||
|
|
|
@ -96,3 +96,7 @@
|
|||
[[constraint]]
|
||||
name = "gopkg.in/andygrunwald/go-jira.v1"
|
||||
version = "1.5.0"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/denisenkom/go-mssqldb"
|
||||
|
|
31
NOTICES.md
31
NOTICES.md
|
@ -2514,3 +2514,34 @@ https:///github.com/trivago/tgo
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
https://github.com/denisenkom/go-mssqldb
|
||||
|
||||
Copyright (c) 2012 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
|
11
README.md
11
README.md
|
@ -13,9 +13,9 @@ All you need to provide is PostgreSQL or any MySQL variant.
|
|||
|
||||
## Latest Release
|
||||
|
||||
[Community Edition: v2.2.1](https://github.com/documize/community/releases)
|
||||
[Community Edition: v2.3.0](https://github.com/documize/community/releases)
|
||||
|
||||
[Enterprise Edition: v2.2.1](https://www.documize.com/downloads)
|
||||
[Enterprise Edition: v2.3.0](https://www.documize.com/downloads)
|
||||
|
||||
> *We provide frequent product updates for both cloud and self-hosted customers.*
|
||||
>
|
||||
|
@ -27,11 +27,12 @@ All you need to provide is PostgreSQL or any MySQL variant.
|
|||
- Windows
|
||||
- macOS
|
||||
|
||||
Heck, Documize will probably run just fine on a Raspberry Pi 3.
|
||||
Heck, Documize will probably run just fine on a Raspberry Pi.
|
||||
|
||||
## Database Support
|
||||
|
||||
- PostgreSQL (v9.6+)
|
||||
- Microsoft SQL Server (2016+)
|
||||
- MySQL (v5.7.10+ and v8.0.12+)
|
||||
- Percona (v5.7.16-10+)
|
||||
- MariaDB (10.3.0+)
|
||||
|
@ -44,11 +45,11 @@ Heck, Documize will probably run just fine on a Raspberry Pi 3.
|
|||
- Brave
|
||||
- Vivaldi
|
||||
- Opera
|
||||
- Microsoft Edge (v42+)
|
||||
- Edge (v42+)
|
||||
|
||||
## Technology Stack
|
||||
|
||||
- Go (v1.12.1)
|
||||
- Go (v1.12.2)
|
||||
- Ember JS (v3.8.0)
|
||||
|
||||
## Authentication Options
|
||||
|
|
|
@ -37,10 +37,12 @@ rd /s /q embed\bindata\scripts
|
|||
mkdir embed\bindata\scripts
|
||||
mkdir embed\bindata\scripts\mysql
|
||||
mkdir embed\bindata\scripts\postgresql
|
||||
mkdir embed\bindata\scripts\sqlserver
|
||||
|
||||
echo "Copying database scripts folder"
|
||||
robocopy /e /NFL /NDL /NJH core\database\scripts\mysql embed\bindata\scripts\mysql
|
||||
robocopy /e /NFL /NDL /NJH core\database\scripts\postgresql embed\bindata\scripts\postgresql
|
||||
robocopy /e /NFL /NDL /NJH core\database\scripts\sqlserver embed\bindata\scripts\sqlserver
|
||||
|
||||
echo "Generating in-memory static assets..."
|
||||
go get -u github.com/jteeuwen/go-bindata/...
|
||||
|
@ -51,12 +53,12 @@ cd ..
|
|||
|
||||
echo "Compiling Windows"
|
||||
set GOOS=windows
|
||||
go build -gcflags=-trimpath=%GOPATH% -asmflags=-trimpath=%GOPATH% -o bin/documize-community-windows-amd64.exe edition/community.go
|
||||
go build -ldflags="-s -w" -gcflags="all=-trimpath=$GOPATH" -o bin/documize-community-windows-amd64.exe edition/community.go
|
||||
|
||||
echo "Compiling Linux"
|
||||
set GOOS=linux
|
||||
go build -gcflags=-trimpath=%GOPATH% -asmflags=-trimpath=%GOPATH% -o bin/documize-community-linux-amd64 edition/community.go
|
||||
go build -ldflags="-s -w" -gcflags="all=-trimpath=$GOPATH" -o bin/documize-community-linux-amd64 edition/community.go
|
||||
|
||||
echo "Compiling Darwin"
|
||||
set GOOS=darwin
|
||||
go build -gcflags=-trimpath=%GOPATH% -asmflags=-trimpath=%GOPATH% -o bin/documize-community-darwin-amd64 edition/community.go
|
||||
go build -ldflags="-s -w" -gcflags="all=-trimpath=$GOPATH" -o bin/documize-community-darwin-amd64 edition/community.go
|
||||
|
|
6
build.sh
6
build.sh
|
@ -32,8 +32,10 @@ rm -rf embed/bindata/scripts
|
|||
mkdir -p embed/bindata/scripts
|
||||
mkdir -p embed/bindata/scripts/mysql
|
||||
mkdir -p embed/bindata/scripts/postgresql
|
||||
mkdir -p embed/bindata/scripts/sqlserver
|
||||
cp -r core/database/scripts/mysql/*.sql embed/bindata/scripts/mysql
|
||||
cp -r core/database/scripts/postgresql/*.sql embed/bindata/scripts/postgresql
|
||||
cp -r core/database/scripts/sqlserver/*.sql embed/bindata/scripts/sqlserver
|
||||
|
||||
echo "Generating in-memory static assets..."
|
||||
# go get -u github.com/jteeuwen/go-bindata/...
|
||||
|
@ -47,10 +49,10 @@ for arch in amd64 ; do
|
|||
for os in darwin linux windows ; do
|
||||
if [ "$os" == "windows" ] ; then
|
||||
echo "Compiling documize-community-$os-$arch.exe"
|
||||
env GOOS=$os GOARCH=$arch go build -gcflags="all=-trimpath=$GOPATH" -o bin/documize-community-$os-$arch.exe ./edition/community.go
|
||||
env GOOS=$os GOARCH=$arch GODEBUG=tls13=1 go build -ldflags="-s -w" -gcflags="all=-trimpath=$GOPATH" -o bin/documize-community-$os-$arch.exe ./edition/community.go
|
||||
else
|
||||
echo "Compiling documize-community-$os-$arch"
|
||||
env GOOS=$os GOARCH=$arch go build -gcflags="all=-trimpath=$GOPATH" -o bin/documize-community-$os-$arch ./edition/community.go
|
||||
env GOOS=$os GOARCH=$arch GODEBUG=tls13=1 go build -ldflags="-s -w" -gcflags="all=-trimpath=$GOPATH" -o bin/documize-community-$os-$arch ./edition/community.go
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
|
|
@ -28,6 +28,8 @@ func RebindParams(sql string, s env.StoreType) string {
|
|||
switch s {
|
||||
case env.StoreTypePostgreSQL:
|
||||
bindParam = sqlx.DOLLAR
|
||||
case env.StoreTypeSQLServer:
|
||||
bindParam = sqlx.AT
|
||||
}
|
||||
|
||||
return sqlx.Rebind(bindParam, sql)
|
||||
|
|
|
@ -46,6 +46,11 @@ func LoadScripts() (s Scripts, err error) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
// PostgreSQL
|
||||
s.SQLServer, err = loadFiles(fmt.Sprintf("%s/sqlserver", assetDir))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
@ -57,7 +62,7 @@ func SpecificScripts(runtime *env.Runtime, all Scripts) (s []Script) {
|
|||
return all.MySQL
|
||||
case env.StoreTypePostgreSQL:
|
||||
return all.PostgreSQL
|
||||
case env.StoreTypeMSSQL:
|
||||
case env.StoreTypeSQLServer:
|
||||
return all.SQLServer
|
||||
}
|
||||
|
||||
|
|
469
core/database/scripts/sqlserver/db_00001.sql
Normal file
469
core/database/scripts/sqlserver/db_00001.sql
Normal file
|
@ -0,0 +1,469 @@
|
|||
-- SQL to set up the Documize database
|
||||
|
||||
DROP TABLE IF EXISTS dmz_action;
|
||||
CREATE TABLE dmz_action (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_requestorid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_actiontype INT NOT NULL DEFAULT '0',
|
||||
c_note NVARCHAR(2000) NOT NULL DEFAULT '',
|
||||
c_requested DATETIME2 NULL DEFAULT NULL,
|
||||
c_due DATETIME2 NULL DEFAULT NULL,
|
||||
c_completed DATETIME2 NULL DEFAULT NULL,
|
||||
c_iscomplete BIT NOT NULL DEFAULT '0',
|
||||
c_reftype NVARCHAR(1) NOT NULL DEFAULT 'D',
|
||||
c_reftypeid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_action_1 ON dmz_action (c_refid);
|
||||
CREATE INDEX idx_action_2 ON dmz_action (c_userid);
|
||||
CREATE INDEX idx_action_3 ON dmz_action (c_docid);
|
||||
CREATE INDEX idx_action_4 ON dmz_action (c_requestorid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_audit_log;
|
||||
CREATE TABLE dmz_audit_log (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_eventtype NVARCHAR(100) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_ip NVARCHAR(39) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_audit_log_1 ON dmz_audit_log (c_orgid);
|
||||
CREATE INDEX idx_audit_log_2 ON dmz_audit_log (c_userid);
|
||||
CREATE INDEX idx_audit_log_3 ON dmz_audit_log (c_eventtype);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_category;
|
||||
CREATE TABLE dmz_category (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_spaceid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_name NVARCHAR(50) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_category_1 ON dmz_category (c_refid);
|
||||
CREATE INDEX idx_category_2 ON dmz_category (c_orgid);
|
||||
CREATE INDEX idx_category_3 ON dmz_category (c_orgid,c_spaceid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_category_member;
|
||||
CREATE TABLE dmz_category_member (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_spaceid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_categoryid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_category_member_1 ON dmz_category_member (c_docid);
|
||||
CREATE INDEX idx_category_member_2 ON dmz_category_member (c_orgid,c_docid);
|
||||
CREATE INDEX idx_category_member_3 ON dmz_category_member (c_orgid,c_spaceid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_config;
|
||||
CREATE TABLE dmz_config (
|
||||
c_key NVARCHAR(200) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_config NVARCHAR(MAX) DEFAULT NULL
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_doc;
|
||||
CREATE TABLE dmz_doc (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_spaceid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_job NVARCHAR(36) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_location NVARCHAR(2000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_name NVARCHAR(2000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_desc NVARCHAR(2000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_slug NVARCHAR(2000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_tags NVARCHAR(1000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_template BIT NOT NULL DEFAULT '0',
|
||||
c_protection INT NOT NULL DEFAULT '0',
|
||||
c_approval INT NOT NULL DEFAULT '0',
|
||||
c_lifecycle INT NOT NULL DEFAULT '1',
|
||||
c_versioned BIT NOT NULL DEFAULT '0',
|
||||
c_versionid NVARCHAR(100) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_versionorder INT NOT NULL DEFAULT '0',
|
||||
c_groupid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_doc_1 ON dmz_doc (id);
|
||||
CREATE INDEX idx_doc_2 ON dmz_doc (c_orgid);
|
||||
CREATE INDEX idx_doc_3 ON dmz_doc (c_spaceid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_doc_attachment;
|
||||
CREATE TABLE dmz_doc_attachment (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_job NVARCHAR(36) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_fileid NVARCHAR(10) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_filename NVARCHAR(255) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_data VARBINARY(MAX),
|
||||
c_extension NVARCHAR(6) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_doc_attachment_1 ON dmz_doc_attachment (id);
|
||||
CREATE INDEX idx_doc_attachment_2 ON dmz_doc_attachment (c_orgid);
|
||||
CREATE INDEX idx_doc_attachment_3 ON dmz_doc_attachment (c_docid);
|
||||
CREATE INDEX idx_doc_attachment_4 ON dmz_doc_attachment (c_job,c_fileid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_doc_comment;
|
||||
CREATE TABLE dmz_doc_comment (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS DEFAULT '',
|
||||
c_email NVARCHAR(250) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_feedback NVARCHAR(MAX) COLLATE Latin1_General_CS_AS,
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_doc_comment_1 ON dmz_doc_comment (c_refid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_doc_link;
|
||||
CREATE TABLE dmz_doc_link (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_spaceid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_sourcedocid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_sourcesectionid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_type NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_targetdocid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_targetid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_externalid NVARCHAR(1000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_orphan BIT NOT NULL DEFAULT '0',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_doc_share;
|
||||
CREATE TABLE dmz_doc_share (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS DEFAULT '',
|
||||
c_email NVARCHAR(250) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_message NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_viewed NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_secret NVARCHAR(250) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_expires NVARCHAR(20) COLLATE Latin1_General_CS_AS DEFAULT '',
|
||||
c_active BIT NOT NULL DEFAULT '1',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_doc_vote;
|
||||
CREATE TABLE dmz_doc_vote (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_voter NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_vote INT NOT NULL DEFAULT '0',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_doc_vote_1 ON dmz_doc_vote (c_refid);
|
||||
CREATE INDEX idx_doc_vote_2 ON dmz_doc_vote (c_docid);
|
||||
CREATE INDEX idx_doc_vote_3 ON dmz_doc_vote (c_orgid);
|
||||
CREATE INDEX idx_doc_vote_4 ON dmz_doc_vote (c_orgid,c_docid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_group;
|
||||
CREATE TABLE dmz_group (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_name NVARCHAR(50) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_desc NVARCHAR(100) COLLATE Latin1_General_CS_AS DEFAULT '',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_group_1 ON dmz_group (c_refid);
|
||||
CREATE INDEX idx_group_2 ON dmz_group (c_orgid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_group_member;
|
||||
CREATE TABLE dmz_group_member (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_groupid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_group_member_1 ON dmz_group_member (c_groupid,c_userid);
|
||||
CREATE INDEX idx_group_member_2 ON dmz_group_member (c_orgid,c_groupid,c_userid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_org;
|
||||
CREATE TABLE dmz_org (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_company NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_title NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_message NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_domain NVARCHAR(200) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_service NVARCHAR(200) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT 'https://api.documize.com',
|
||||
c_email NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_anonaccess BIT NOT NULL DEFAULT '0',
|
||||
c_authprovider NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT 'documize',
|
||||
c_authconfig NVARCHAR(MAX) DEFAULT NULL,
|
||||
c_maxtags INT NOT NULL DEFAULT '3',
|
||||
c_sub NVARCHAR(MAX) NULL,
|
||||
c_theme NVARCHAR(20) NOT NULL DEFAULT '',
|
||||
c_logo VARBINARY(MAX),
|
||||
c_verified BIT NOT NULL DEFAULT '0',
|
||||
c_serial NVARCHAR(50) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_active BIT NOT NULL DEFAULT '1',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
);
|
||||
CREATE INDEX idx_org_1 ON dmz_org (id);
|
||||
CREATE INDEX idx_org_2 ON dmz_org (c_domain);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_permission;
|
||||
CREATE TABLE dmz_permission (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_who NVARCHAR(30) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_whoid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_action NVARCHAR(30) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_scope NVARCHAR(30) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_location NVARCHAR(100) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_permission_1 ON dmz_permission (c_orgid);
|
||||
CREATE INDEX idx_permission_2 ON dmz_permission (c_orgid,c_who,c_whoid,c_location);
|
||||
CREATE INDEX idx_permission_3 ON dmz_permission (c_orgid,c_who,c_whoid,c_location,c_action);
|
||||
CREATE INDEX idx_permission_4 ON dmz_permission (c_orgid,c_location,c_refid);
|
||||
CREATE INDEX idx_permission_5 ON dmz_permission (c_orgid,c_who,c_location,c_action);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_pin;
|
||||
CREATE TABLE dmz_pin (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS DEFAULT '',
|
||||
c_spaceid NVARCHAR(20) COLLATE Latin1_General_CS_AS DEFAULT '',
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS DEFAULT '',
|
||||
c_sequence BIGINT NOT NULL DEFAULT '99',
|
||||
c_name NVARCHAR(100) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_pin_1 ON dmz_pin (c_userid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_search;
|
||||
CREATE TABLE dmz_search (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_itemid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_itemtype NVARCHAR(10) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_content NVARCHAR(MAX) COLLATE Latin1_General_CS_AS,
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_search_1 ON dmz_search (c_orgid);
|
||||
CREATE INDEX idx_search_2 ON dmz_search (c_docid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_section;
|
||||
CREATE TABLE dmz_section (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_contenttype NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT 'wysiwyg',
|
||||
c_type NVARCHAR(10) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT 'section',
|
||||
c_templateid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_level bigint NOT NULL,
|
||||
c_sequence double precision NOT NULL,
|
||||
c_name NVARCHAR(2000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_body NVARCHAR(MAX) COLLATE Latin1_General_CS_AS,
|
||||
c_revisions bigint NOT NULL,
|
||||
c_status INT NOT NULL DEFAULT '0',
|
||||
c_relativeid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_section_1 ON dmz_section (id);
|
||||
CREATE INDEX idx_section_2 ON dmz_section (c_orgid);
|
||||
CREATE INDEX idx_section_3 ON dmz_section (c_docid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_section_meta;
|
||||
CREATE TABLE dmz_section_meta (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_sectionid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_rawbody NVARCHAR(MAX),
|
||||
c_config NVARCHAR(MAX) DEFAULT NULL,
|
||||
c_external BIT DEFAULT '0',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_section_meta_1 ON dmz_section_meta (id);
|
||||
CREATE INDEX idx_section_meta_2 ON dmz_section_meta (c_sectionid);
|
||||
CREATE INDEX idx_section_meta_3 ON dmz_section_meta (c_orgid);
|
||||
CREATE INDEX idx_section_meta_4 ON dmz_section_meta (c_docid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_section_revision;
|
||||
CREATE TABLE dmz_section_revision (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_ownerid NVARCHAR(20) COLLATE Latin1_General_CS_AS DEFAULT '',
|
||||
c_sectionid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_contenttype NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT 'wysiwyg',
|
||||
c_type NVARCHAR(10) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT 'section',
|
||||
c_name NVARCHAR(2000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_body NVARCHAR(MAX) COLLATE Latin1_General_CS_AS,
|
||||
c_rawbody NVARCHAR(MAX),
|
||||
c_config NVARCHAR(MAX) DEFAULT NULL,
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_section_revision_1 ON dmz_section_revision (id);
|
||||
CREATE INDEX idx_section_revision_2 ON dmz_section_revision (c_orgid);
|
||||
CREATE INDEX idx_section_revision_3 ON dmz_section_revision (c_docid);
|
||||
CREATE INDEX idx_section_revision_4 ON dmz_section_revision (c_sectionid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_section_template;
|
||||
CREATE TABLE dmz_section_template (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_spaceid NVARCHAR(20) COLLATE Latin1_General_CS_AS DEFAULT '',
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS DEFAULT '',
|
||||
c_contenttype NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT 'wysiwyg',
|
||||
c_type NVARCHAR(10) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT 'section',
|
||||
c_name NVARCHAR(2000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_body NVARCHAR(MAX) COLLATE Latin1_General_CS_AS,
|
||||
c_desc NVARCHAR(2000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_used INT NOT NULL,
|
||||
c_rawbody NVARCHAR(MAX),
|
||||
c_config NVARCHAR(MAX) DEFAULT NULL,
|
||||
c_external BIT DEFAULT '0',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_section_template_1 ON dmz_section_template (c_refid);
|
||||
CREATE INDEX idx_section_template_2 ON dmz_section_template (c_spaceid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_space;
|
||||
CREATE TABLE dmz_space (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_name NVARCHAR(300) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_type INT NOT NULL DEFAULT '1',
|
||||
c_lifecycle INT NOT NULL DEFAULT '1',
|
||||
c_desc NVARCHAR(200) NOT NULL DEFAULT '',
|
||||
c_labelid NVARCHAR(20) NOT NULL DEFAULT '' COLLATE Latin1_General_CS_AS,
|
||||
c_likes NVARCHAR(1000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_icon NVARCHAR(50) NOT NULL DEFAULT '',
|
||||
c_count_category INT NOT NULL DEFAULT 0,
|
||||
c_count_content INT NOT NULL DEFAULT 0,
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_space_1 ON dmz_space (id);
|
||||
CREATE INDEX idx_space_2 ON dmz_space (c_userid);
|
||||
CREATE INDEX idx_space_3 ON dmz_space (c_orgid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_space_label;
|
||||
CREATE TABLE dmz_space_label (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_name NVARCHAR(50) NOT NULL DEFAULT '',
|
||||
c_color NVARCHAR(10) NOT NULL DEFAULT '',
|
||||
c_created DATETIME2 DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_space_label_1 ON dmz_space_label (id);
|
||||
CREATE INDEX idx_space_label_2 ON dmz_space_label (c_orgid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_user;
|
||||
CREATE TABLE dmz_user (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_firstname NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_lastname NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_email NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_initials NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_globaladmin BIT NOT NULL DEFAULT '0',
|
||||
c_password NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_salt NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_reset NVARCHAR(500) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_active BIT NOT NULL DEFAULT '1',
|
||||
c_lastversion NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_user_1 ON dmz_user (id);
|
||||
CREATE INDEX idx_user_2 ON dmz_user (c_email);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_user_account;
|
||||
CREATE TABLE dmz_user_account (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_refid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_editor BIT NOT NULL DEFAULT '0',
|
||||
c_admin BIT NOT NULL DEFAULT '0',
|
||||
c_users BIT NOT NULL DEFAULT '1',
|
||||
c_analytics BIT NOT NULL DEFAULT '0',
|
||||
c_active BIT NOT NULL DEFAULT '1',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_user_account_1 ON dmz_user_account (id);
|
||||
CREATE INDEX idx_user_account_2 ON dmz_user_account (c_userid);
|
||||
CREATE INDEX idx_user_account_3 ON dmz_user_account (c_orgid);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_user_activity;
|
||||
CREATE TABLE dmz_user_activity (
|
||||
id BIGINT PRIMARY KEY IDENTITY (1, 1) NOT NULL,
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_spaceid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_docid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_sectionid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_sourcetype INT NOT NULL DEFAULT '0',
|
||||
c_activitytype INT NOT NULL DEFAULT '0',
|
||||
c_metadata NVARCHAR(1000) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '',
|
||||
c_created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_user_activity_1 ON dmz_user_activity (c_orgid);
|
||||
CREATE INDEX idx_user_activity_2 ON dmz_user_activity (c_userid);
|
||||
CREATE INDEX idx_user_activity_3 ON dmz_user_activity (c_activitytype);
|
||||
CREATE INDEX idx_user_activity_4 ON dmz_user_activity (c_orgid,c_docid,c_sourcetype);
|
||||
CREATE INDEX idx_user_activity_5 ON dmz_user_activity (c_orgid,c_docid,c_userid,c_sourcetype);
|
||||
|
||||
DROP TABLE IF EXISTS dmz_user_config;
|
||||
CREATE TABLE dmz_user_config (
|
||||
c_orgid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_userid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_key NVARCHAR(200) COLLATE Latin1_General_CS_AS NOT NULL,
|
||||
c_config NVARCHAR(MAX) DEFAULT NULL
|
||||
);
|
||||
|
||||
INSERT INTO dmz_config VALUES ('SMTP','{"userid": "","password": "","host": "","port": "","sender": ""}');
|
||||
INSERT INTO dmz_config VALUES ('FILEPLUGINS', '[{"Comment": "Disable (or not) built-in html import (NOTE: no Plugin name)","Disabled": false,"API": "Convert","Actions": ["htm","html"]},{"Comment": "Disable (or not) built-in Documize API import used from SDK (NOTE: no Plugin name)","Disabled": false,"API": "Convert","Actions": ["documizeapi"]}]');
|
||||
INSERT INTO dmz_config VALUES ('SECTION-TRELLO','{"appKey": ""}');
|
||||
INSERT INTO dmz_config VALUES ('META','{"database": "0"}');
|
4
core/env/flags.go
vendored
4
core/env/flags.go
vendored
|
@ -82,7 +82,7 @@ func ParseFlags() (f Flags, ok bool) {
|
|||
register(&port, "port", false, "http/https port number")
|
||||
register(&forcePort2SSL, "forcesslport", false, "redirect given http port number to TLS")
|
||||
register(&siteMode, "offline", false, "set to '1' for OFFLINE mode")
|
||||
register(&dbType, "dbtype", true, "specify the database provider: mysql|percona|mariadb|postgresql")
|
||||
register(&dbType, "dbtype", true, "specify the database provider: mysql|percona|mariadb|postgresql|sqlserver")
|
||||
register(&dbConn, "db", true, `'database specific connection string for example "user:password@tcp(localhost:3306)/dbname"`)
|
||||
register(&location, "location", false, `reserved`)
|
||||
|
||||
|
@ -90,6 +90,7 @@ func ParseFlags() (f Flags, ok bool) {
|
|||
ok = false
|
||||
}
|
||||
|
||||
f.DBType = strings.ToLower(dbType)
|
||||
f.DBConn = dbConn
|
||||
f.ForceHTTPPort2SSL = forcePort2SSL
|
||||
f.HTTPPort = port
|
||||
|
@ -97,7 +98,6 @@ func ParseFlags() (f Flags, ok bool) {
|
|||
f.SiteMode = siteMode
|
||||
f.SSLCertFile = certFile
|
||||
f.SSLKeyFile = keyFile
|
||||
f.DBType = strings.ToLower(dbType)
|
||||
|
||||
// reserved
|
||||
if len(location) == 0 {
|
||||
|
|
15
core/env/provider.go
vendored
15
core/env/provider.go
vendored
|
@ -28,8 +28,8 @@ const (
|
|||
// StoreTypePostgreSQL is PostgreSQL
|
||||
StoreTypePostgreSQL StoreType = "PostgreSQL"
|
||||
|
||||
// StoreTypeMSSQL is Microsoft SQL Server
|
||||
StoreTypeMSSQL StoreType = "MSSQL"
|
||||
// StoreTypeSQLServer is Microsoft SQL Server
|
||||
StoreTypeSQLServer StoreType = "SQLServer"
|
||||
)
|
||||
|
||||
// StoreProvider defines a database provider.
|
||||
|
@ -103,4 +103,15 @@ type StoreProvider interface {
|
|||
// Must use ? for parameter placeholder character as DB layer
|
||||
// will convert to database specific parameter placeholder character.
|
||||
ConvertTimestamp() (statement string)
|
||||
|
||||
// IsTrue returns storage provider boolean TRUE:
|
||||
// MySQL is 1, PostgresSQL is TRUE, SQL Server is 1
|
||||
IsTrue() string
|
||||
|
||||
// IsFalse returns storage provider boolean FALSE:
|
||||
// MySQL is 0, PostgresSQL is FALSE, SQL Server is 0
|
||||
IsFalse() string
|
||||
|
||||
// RowLimit returns SQL for limited number of returned rows
|
||||
RowLimit(max int) string
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ func (s Store) GetUserAccounts(ctx domain.RequestContext, userID string) (t []ac
|
|||
a.c_active AS active, a.c_created AS created, a.c_revised AS revised,
|
||||
b.c_company AS company, b.c_title AS title, b.c_message AS message, b.c_domain as domain
|
||||
FROM dmz_user_account a, dmz_org b
|
||||
WHERE a.c_userid=? AND a.c_orgid=b.c_refid AND a.c_active=true
|
||||
WHERE a.c_userid=? AND a.c_orgid=b.c_refid AND a.c_active=`+s.IsTrue()+`
|
||||
ORDER BY b.c_title`),
|
||||
userID)
|
||||
|
||||
|
@ -88,7 +88,7 @@ func (s Store) GetAccountsByOrg(ctx domain.RequestContext) (t []account.Account,
|
|||
a.c_active AS active, a.c_created AS created, a.c_revised AS revised,
|
||||
b.c_company AS company, b.c_title AS title, b.c_message AS message, b.c_domain as domain
|
||||
FROM dmz_user_account a, dmz_org b
|
||||
WHERE a.c_orgid=b.c_refid AND a.c_orgid=? AND a.c_active=true`),
|
||||
WHERE a.c_orgid=b.c_refid AND a.c_orgid=? AND a.c_active=`+s.IsTrue()),
|
||||
ctx.OrgID)
|
||||
|
||||
if err != sql.ErrNoRows && err != nil {
|
||||
|
@ -100,7 +100,7 @@ func (s Store) GetAccountsByOrg(ctx domain.RequestContext) (t []account.Account,
|
|||
|
||||
// CountOrgAccounts returns the numnber of active user accounts for specified organization.
|
||||
func (s Store) CountOrgAccounts(ctx domain.RequestContext) (c int) {
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT count(*) FROM dmz_user_account WHERE c_orgid=? AND c_active=true"), ctx.OrgID)
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT count(*) FROM dmz_user_account WHERE c_orgid=? AND c_active="+s.IsTrue()), ctx.OrgID)
|
||||
err := row.Scan(&c)
|
||||
if err == sql.ErrNoRows {
|
||||
return 0
|
||||
|
|
|
@ -122,6 +122,7 @@ func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
// ValidateToken finds and validates authentication token.
|
||||
// TODO: remove
|
||||
func (h *Handler) ValidateToken(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO should this go after token validation?
|
||||
if s := r.URL.Query().Get("section"); s != "" {
|
||||
|
|
|
@ -375,9 +375,10 @@ func (r *restoreHandler) dmzOrg() (err error) {
|
|||
org[i].RefID, org[i].Company, org[i].Title, org[i].Message,
|
||||
strings.ToLower(org[i].Domain), org[i].ConversionEndpoint, strings.ToLower(org[i].Email),
|
||||
org[i].AllowAnonymousAccess, org[i].AuthProvider, org[i].AuthConfig,
|
||||
org[i].MaxTags, true, org[i].Serial, org[i].Subscription,
|
||||
org[i].MaxTags, r.Runtime.StoreProvider.IsTrue(), org[i].Serial,
|
||||
org[i].Subscription, org[i].Active,
|
||||
org[i].Theme, org[i].Logo,
|
||||
org[i].Active, org[i].Created, org[i].Revised)
|
||||
org[i].Created, org[i].Revised)
|
||||
if err != nil {
|
||||
r.Context.Transaction.Rollback()
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to insert %s %s", filename, org[i].RefID))
|
||||
|
|
|
@ -223,29 +223,29 @@ func (s Store) GetSpaceCategorySummary(ctx domain.RequestContext, spaceID string
|
|||
c = []category.SummaryModel{}
|
||||
|
||||
err = s.Runtime.Db.Select(&c, s.Bind(`
|
||||
SELECT 'documents' AS type, c_categoryid AS categoryid, COUNT(*) AS count
|
||||
SELECT 'documents' AS grouptype, c_categoryid AS categoryid, COUNT(*) AS count
|
||||
FROM dmz_category_member
|
||||
WHERE c_orgid=? AND c_spaceid=?
|
||||
AND c_docid IN (
|
||||
SELECT c_refid
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_template=false AND c_groupid=''
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_template=`+s.IsFalse()+` AND c_groupid=''
|
||||
UNION ALL
|
||||
SELECT d.c_refid
|
||||
FROM (
|
||||
SELECT c_groupid, MIN(c_versionorder) AS latestversion
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_groupid!='' AND c_template=false
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_groupid!='' AND c_template=`+s.IsFalse()+`
|
||||
GROUP BY c_groupid
|
||||
) AS x INNER JOIN dmz_doc AS d ON d.c_groupid=x.c_groupid AND d.c_versionorder=x.latestversion
|
||||
)
|
||||
GROUP BY c_categoryid, type
|
||||
GROUP BY c_categoryid
|
||||
UNION ALL
|
||||
SELECT 'users' AS type, c_refid AS categoryid, count(*) AS count
|
||||
SELECT 'users' AS grouptype, c_refid AS categoryid, count(*) AS count
|
||||
FROM dmz_permission
|
||||
WHERE c_orgid=? AND c_location='category' AND c_refid IN
|
||||
(SELECT c_refid FROM dmz_category WHERE c_orgid=? AND c_spaceid=?)
|
||||
GROUP BY c_refid, type`),
|
||||
GROUP BY c_refid`),
|
||||
ctx.OrgID, spaceID,
|
||||
ctx.OrgID, spaceID, ctx.OrgID, spaceID,
|
||||
ctx.OrgID, ctx.OrgID, spaceID)
|
||||
|
|
|
@ -80,7 +80,7 @@ func (s Store) GetBySpace(ctx domain.RequestContext, spaceID string) (documents
|
|||
c_lifecycle AS lifecycle, c_versioned AS versioned, c_versionid AS versionid,
|
||||
c_versionorder AS versionorder, c_groupid AS groupid, c_created AS created, c_revised AS revised
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_template=false AND c_spaceid IN
|
||||
WHERE c_orgid=? AND c_template=`+s.IsFalse()+` AND c_spaceid IN
|
||||
(SELECT c_refid FROM dmz_permission WHERE c_orgid=? AND c_location='space' AND c_refid=? AND c_refid IN
|
||||
(SELECT c_refid from dmz_permission WHERE c_orgid=? AND c_who='user' AND (c_whoid=? OR c_whoid='0') AND c_location='space' AND c_action='view'
|
||||
UNION ALL
|
||||
|
@ -113,7 +113,7 @@ func (s Store) TemplatesBySpace(ctx domain.RequestContext, spaceID string) (docu
|
|||
c_lifecycle AS lifecycle, c_versioned AS versioned, c_versionid AS versionid,
|
||||
c_versionorder AS versionorder, c_groupid AS groupid, c_created AS created, c_revised AS revised
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_template=true AND c_lifecycle=1
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_template=`+s.IsTrue()+` AND c_lifecycle=1
|
||||
AND c_spaceid IN
|
||||
(SELECT c_refid FROM dmz_space WHERE c_orgid=? AND c_refid IN
|
||||
(SELECT c_refid FROM dmz_permission WHERE c_orgid=? AND c_location='space' AND c_refid IN
|
||||
|
@ -144,7 +144,7 @@ func (s Store) PublicDocuments(ctx domain.RequestContext, orgID string) (documen
|
|||
SELECT d.c_refid AS documentid, d.c_name AS document, d.c_revised as revised, l.c_refid AS spaceid, l.c_name AS space
|
||||
FROM dmz_doc d
|
||||
LEFT JOIN dmz_space l ON l.c_refid=d.c_spaceid
|
||||
WHERE d.c_orgid=? AND l.c_type=1 AND d.c_lifecycle=1 AND d.c_template=false`),
|
||||
WHERE d.c_orgid=? AND l.c_type=1 AND d.c_lifecycle=1 AND d.c_template=`+s.IsFalse()),
|
||||
orgID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
|
|
|
@ -94,7 +94,7 @@ func (s Store) GetPageLinks(ctx domain.RequestContext, documentID, pageID string
|
|||
func (s Store) MarkOrphanDocumentLink(ctx domain.RequestContext, documentID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
_, err = ctx.Transaction.Exec(s.Bind(`UPDATE dmz_doc_link SET
|
||||
c_orphan=true, c_revised=?
|
||||
c_orphan=`+s.IsTrue()+`, c_revised=?
|
||||
WHERE c_type='document' AND c_orgid=? AND c_targetdocid=?`),
|
||||
revised, ctx.OrgID, documentID)
|
||||
|
||||
|
@ -109,7 +109,7 @@ func (s Store) MarkOrphanDocumentLink(ctx domain.RequestContext, documentID stri
|
|||
func (s Store) MarkOrphanPageLink(ctx domain.RequestContext, pageID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
_, err = ctx.Transaction.Exec(s.Bind(`UPDATE dmz_doc_link SET
|
||||
c_orphan=true, c_revised=?
|
||||
c_orphan=`+s.IsTrue()+`, c_revised=?
|
||||
WHERE c_type='section' AND c_orgid=? AND c_targetid=?`),
|
||||
revised, ctx.OrgID, pageID)
|
||||
|
||||
|
@ -124,7 +124,7 @@ func (s Store) MarkOrphanPageLink(ctx domain.RequestContext, pageID string) (err
|
|||
func (s Store) MarkOrphanAttachmentLink(ctx domain.RequestContext, attachmentID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
_, err = ctx.Transaction.Exec(s.Bind(`UPDATE dmz_doc_link SET
|
||||
c_orphan=true, c_revised=?
|
||||
c_orphan=`+s.IsTrue()+`, c_revised=?
|
||||
WHERE c_type='file' AND c_orgid=? AND c_targetid=?`),
|
||||
revised, ctx.OrgID, attachmentID)
|
||||
|
||||
|
|
|
@ -86,11 +86,12 @@ func (s Store) GetOrganizationByDomain(subdomain string) (o org.Organization, er
|
|||
coalesce(c_sub,`+s.EmptyJSON()+`) AS subscription,
|
||||
c_maxtags AS maxtags, c_created AS created, c_revised AS revised, c_theme AS theme
|
||||
FROM dmz_org
|
||||
WHERE c_domain=? AND c_active=true`),
|
||||
WHERE c_domain=? AND c_active=`+s.IsTrue()),
|
||||
subdomain)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
s.Runtime.Log.Error("meta", err)
|
||||
|
||||
// match on empty domain AS last resort
|
||||
err = s.Runtime.Db.Get(&o, s.Bind(`SELECT id, c_refid AS refid,
|
||||
|
@ -101,7 +102,7 @@ func (s Store) GetOrganizationByDomain(subdomain string) (o org.Organization, er
|
|||
coalesce(c_sub,`+s.EmptyJSON()+`) AS subscription,
|
||||
c_maxtags AS maxtags, c_created AS created, c_revised AS revised, c_theme AS theme
|
||||
FROM dmz_org
|
||||
WHERE c_domain='' AND c_active=true`))
|
||||
WHERE c_domain='' AND c_active=`+s.IsTrue()))
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "unable to execute select for empty subdomain")
|
||||
|
@ -134,7 +135,7 @@ func (s Store) DeleteOrganization(ctx domain.RequestContext, orgID string) (rows
|
|||
|
||||
// RemoveOrganization sets the orgID organization to be inactive, thus executing a "soft delete" operation.
|
||||
func (s Store) RemoveOrganization(ctx domain.RequestContext, orgID string) (err error) {
|
||||
_, err = ctx.Transaction.Exec(s.Bind("UPDATE dmz_org SET c_active=false WHERE c_refid=?"), orgID)
|
||||
_, err = ctx.Transaction.Exec(s.Bind("UPDATE dmz_org SET c_active="+s.IsFalse()+" WHERE c_refid=?"), orgID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute soft delete for org %s", orgID))
|
||||
|
@ -162,7 +163,7 @@ func (s Store) UpdateAuthConfig(ctx domain.RequestContext, org org.Organization)
|
|||
|
||||
// CheckDomain makes sure there is an organisation with the correct domain
|
||||
func (s Store) CheckDomain(ctx domain.RequestContext, domain string) string {
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT COUNT(*) FROM dmz_org WHERE c_domain=? AND c_active=true"), domain)
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT COUNT(*) FROM dmz_org WHERE c_domain=? AND c_active="+s.IsTrue()), domain)
|
||||
|
||||
var count int
|
||||
err := row.Scan(&count)
|
||||
|
@ -179,7 +180,7 @@ func (s Store) CheckDomain(ctx domain.RequestContext, domain string) string {
|
|||
|
||||
// Logo fetchs stored image from store or NULL.
|
||||
func (s Store) Logo(ctx domain.RequestContext, domain string) (l []byte, err error) {
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT c_logo FROM dmz_org WHERE c_domain=? AND c_active=true"), domain)
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT c_logo FROM dmz_org WHERE c_domain=? AND c_active="+s.IsTrue()), domain)
|
||||
|
||||
err = row.Scan(&l)
|
||||
if err == sql.ErrNoRows {
|
||||
|
|
|
@ -61,10 +61,12 @@ func (s Store) Add(ctx domain.RequestContext, model page.NewPage) (err error) {
|
|||
|
||||
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_section (c_refid, c_orgid, c_docid, c_userid, c_contenttype, c_type, c_level, c_name, c_body, c_revisions, c_sequence, c_templateid, c_status, c_relativeid, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"),
|
||||
model.Page.RefID, model.Page.OrgID, model.Page.DocumentID, model.Page.UserID, model.Page.ContentType, model.Page.Type, model.Page.Level, model.Page.Name, model.Page.Body, model.Page.Revisions, model.Page.Sequence, model.Page.TemplateID, model.Page.Status, model.Page.RelativeID, model.Page.Created, model.Page.Revised)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute page insert")
|
||||
}
|
||||
|
||||
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_section_meta (c_sectionid, c_orgid, c_userid, c_docid, c_rawbody, c_config, c_external, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"),
|
||||
model.Meta.SectionID, model.Meta.OrgID, model.Meta.UserID, model.Meta.DocumentID, model.Meta.RawBody, model.Meta.Config, model.Meta.ExternalSource, model.Meta.Created, model.Meta.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute page meta insert")
|
||||
}
|
||||
|
@ -241,7 +243,7 @@ func (s Store) GetPageMeta(ctx domain.RequestContext, pageID string) (meta page.
|
|||
c_orgid AS orgid, c_userid AS userid, c_docid AS documentid,
|
||||
c_rawbody AS rawbody, coalesce(c_config,`+s.EmptyJSON()+`) as config,
|
||||
c_external AS externalsource, c_created AS created, c_revised AS revised
|
||||
FROM dmz_section_meta
|
||||
FROM dmz_section_meta
|
||||
WHERE c_orgid=? AND c_sectionid=?`),
|
||||
ctx.OrgID, pageID)
|
||||
|
||||
|
@ -256,7 +258,7 @@ func (s Store) GetPageMeta(ctx domain.RequestContext, pageID string) (meta page.
|
|||
func (s Store) GetDocumentPageMeta(ctx domain.RequestContext, documentID string, externalSourceOnly bool) (meta []page.Meta, err error) {
|
||||
filter := ""
|
||||
if externalSourceOnly {
|
||||
filter = " AND c_external=true"
|
||||
filter = " AND c_external=" + s.IsTrue()
|
||||
}
|
||||
|
||||
err = s.Runtime.Db.Select(&meta, s.Bind(`SELECT id, c_sectionid AS sectionid,
|
||||
|
|
|
@ -165,7 +165,7 @@ func (s Store) GetCategoryUsers(ctx domain.RequestContext, catID string) (u []us
|
|||
SELECT u.id, COALESCE(u.c_refid, '') AS refid, COALESCE(u.c_firstname, '') AS firstname, COALESCE(u.c_lastname, '') as lastname, u.email AS email, u.initials AS initials, u.password AS password, u.salt AS salt, u.c_reset AS reset, u.c_created AS created, u.c_revised AS revised
|
||||
FROM dmz_user u
|
||||
LEFT JOIN dmz_user_account a ON u.c_refid = a.c_userid
|
||||
WHERE a.c_orgid=? AND a.c_active=true AND u.c_refid IN (
|
||||
WHERE a.c_orgid=? AND a.c_active=`+s.IsTrue()+` AND u.c_refid IN (
|
||||
SELECT c_whoid from dmz_permission
|
||||
WHERE c_orgid=? AND c_who='user' AND c_location='category' AND c_refid=?
|
||||
UNION ALL
|
||||
|
|
|
@ -13,6 +13,7 @@ package search
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/model/attachment"
|
||||
"github.com/documize/community/model/category"
|
||||
|
|
|
@ -335,10 +335,11 @@ func (s Store) matchLike(ctx domain.RequestContext, keywords, itemType string) (
|
|||
keywords = fmt.Sprintf("%%%s%%", strings.ToLower(keywords))
|
||||
|
||||
sql1 := s.Bind(`SELECT
|
||||
s.id, s.c_orgid AS orgid, s.c_docid AS documentid, s.c_itemid AS itemid, s.c_itemtype AS itemtype,
|
||||
d.c_spaceid as spaceid, COALESCE(d.c_name,'Unknown') AS document, d.c_tags AS tags, d.c_desc AS excerpt,
|
||||
COALESCE(l.c_name,'Unknown') AS space, d.c_created AS created, d.c_revised AS revised
|
||||
FROM
|
||||
s.id, s.c_orgid AS orgid, s.c_docid AS documentid, s.c_itemid AS itemid, s.c_itemtype AS itemtype,
|
||||
d.c_spaceid as spaceid, COALESCE(d.c_name,'Unknown') AS document, d.c_tags AS tags,
|
||||
d.c_desc AS excerpt, d.c_template AS template, d.c_versionid AS versionid,
|
||||
COALESCE(l.c_name,'Unknown') AS space, d.c_created AS created, d.c_revised AS revised
|
||||
FROM
|
||||
dmz_search s,
|
||||
dmz_doc d
|
||||
LEFT JOIN
|
||||
|
|
281
domain/search/store_sqlserver.go
Normal file
281
domain/search/store_sqlserver.go
Normal file
|
@ -0,0 +1,281 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package search
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/documize/community/core/stringutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/attachment"
|
||||
"github.com/documize/community/model/doc"
|
||||
"github.com/documize/community/model/page"
|
||||
"github.com/documize/community/model/search"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// StoreSQLServer provides data access to space information.
|
||||
type StoreSQLServer struct {
|
||||
store.Context
|
||||
store.SearchStorer
|
||||
}
|
||||
|
||||
// IndexDocument adds search index entries for document inserting title, tags and attachments as
|
||||
// searchable items. Any existing document entries are removed.
|
||||
func (s StoreSQLServer) IndexDocument(ctx domain.RequestContext, doc doc.Document, a []attachment.Attachment) (err error) {
|
||||
method := "search.IndexDocument"
|
||||
|
||||
// remove previous search entries
|
||||
_, err = ctx.Transaction.Exec(s.Bind("DELETE FROM dmz_search WHERE c_orgid=? AND c_docid=? AND (c_itemtype='doc' OR c_itemtype='file' OR c_itemtype='tag')"),
|
||||
ctx.OrgID, doc.RefID)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "execute delete document index entries")
|
||||
s.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
// insert doc title
|
||||
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_search (c_orgid, c_docid, c_itemid, c_itemtype, c_content) VALUES (?, ?, ?, ?, ?)"),
|
||||
ctx.OrgID, doc.RefID, "", "doc", doc.Name)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "execute insert document title entry")
|
||||
s.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
// insert doc tags
|
||||
tags := strings.Split(doc.Tags, "#")
|
||||
for _, t := range tags {
|
||||
t = strings.TrimSpace(t)
|
||||
if len(t) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_search (c_orgid, c_docid, c_itemid, c_itemtype, c_content) VALUES (?, ?, ?, ?, ?)"),
|
||||
ctx.OrgID, doc.RefID, "", "tag", t)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "execute insert document tag entry")
|
||||
s.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for _, file := range a {
|
||||
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_search (c_orgid, c_docid, c_itemid, c_itemtype, c_content) VALUES (?, ?, ?, ?, ?)"),
|
||||
ctx.OrgID, doc.RefID, file.RefID, "file", file.Filename)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "execute insert document file entry")
|
||||
s.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteDocument removes all search entries for document.
|
||||
func (s StoreSQLServer) DeleteDocument(ctx domain.RequestContext, ID string) (err error) {
|
||||
method := "search.DeleteDocument"
|
||||
|
||||
_, err = ctx.Transaction.Exec(s.Bind("DELETE FROM dmz_search WHERE c_orgid=? AND c_docid=?"),
|
||||
ctx.OrgID, ID)
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "execute delete document entries")
|
||||
s.Runtime.Log.Error(method, err)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// IndexContent adds search index entry for document context.
|
||||
// Any existing document entries are removed.
|
||||
func (s StoreSQLServer) IndexContent(ctx domain.RequestContext, p page.Page) (err error) {
|
||||
method := "search.IndexContent"
|
||||
|
||||
// remove previous search entries
|
||||
_, err = ctx.Transaction.Exec(s.Bind("DELETE FROM dmz_search WHERE c_orgid=? AND c_docid=? AND c_itemid=? AND c_itemtype='page'"),
|
||||
ctx.OrgID, p.DocumentID, p.RefID)
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "execute delete document content entry")
|
||||
s.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
err = nil
|
||||
|
||||
// prepare content
|
||||
content, err := stringutil.HTML(p.Body).Text(false)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "search strip HTML failed")
|
||||
s.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
content = strings.TrimSpace(content)
|
||||
|
||||
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_search (c_orgid, c_docid, c_itemid, c_itemtype, c_content) VALUES (?, ?, ?, ?, ?)"),
|
||||
ctx.OrgID, p.DocumentID, p.RefID, "page", content)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "execute insert section content entry")
|
||||
s.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
err = nil
|
||||
|
||||
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_search (c_orgid, c_docid, c_itemid, c_itemtype, c_content) VALUES (?, ?, ?, ?, ?)"),
|
||||
ctx.OrgID, p.DocumentID, p.RefID, "page", p.Name)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "execute insert section title entry")
|
||||
s.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteContent removes all search entries for specific document content.
|
||||
func (s StoreSQLServer) DeleteContent(ctx domain.RequestContext, pageID string) (err error) {
|
||||
method := "search.DeleteContent"
|
||||
|
||||
// remove all search entries
|
||||
_, err = ctx.Transaction.Exec(s.Bind("DELETE FROM dmz_search WHERE c_orgid=? AND c_itemid=? AND c_itemtype=?"),
|
||||
ctx.OrgID, pageID, "page")
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "execute delete document content entry")
|
||||
s.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Documents searches the documents that the client is allowed to see, using the keywords search string, then audits that search.
|
||||
// Visible documents include both those in the client's own organization and those that are public, or whose visibility includes the client.
|
||||
func (s StoreSQLServer) Documents(ctx domain.RequestContext, q search.QueryOptions) (results []search.QueryResult, err error) {
|
||||
q.Keywords = strings.TrimSpace(q.Keywords)
|
||||
if len(q.Keywords) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
results = []search.QueryResult{}
|
||||
|
||||
// Match doc names
|
||||
if q.Doc {
|
||||
r1, err1 := s.match(ctx, q.Keywords, "doc")
|
||||
if err1 != nil {
|
||||
err = errors.Wrap(err1, "search document names")
|
||||
return
|
||||
}
|
||||
|
||||
results = append(results, r1...)
|
||||
}
|
||||
|
||||
// Match doc content
|
||||
if q.Content {
|
||||
r2, err2 := s.match(ctx, q.Keywords, "page")
|
||||
if err2 != nil {
|
||||
err = errors.Wrap(err2, "search document content")
|
||||
return
|
||||
}
|
||||
|
||||
results = append(results, r2...)
|
||||
}
|
||||
|
||||
// Match doc tags
|
||||
if q.Tag {
|
||||
r3, err3 := s.match(ctx, q.Keywords, "tag")
|
||||
if err3 != nil {
|
||||
err = errors.Wrap(err3, "search document tag")
|
||||
return
|
||||
}
|
||||
|
||||
results = append(results, r3...)
|
||||
}
|
||||
|
||||
// Match doc attachments
|
||||
if q.Attachment {
|
||||
r4, err4 := s.match(ctx, q.Keywords, "file")
|
||||
if err4 != nil {
|
||||
err = errors.Wrap(err4, "search document attachments")
|
||||
return
|
||||
}
|
||||
|
||||
results = append(results, r4...)
|
||||
}
|
||||
|
||||
if len(results) == 0 {
|
||||
results = []search.QueryResult{}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s StoreSQLServer) match(ctx domain.RequestContext, keywords, itemType string) (r []search.QueryResult, err error) {
|
||||
// LIKE clause does not like quotes!
|
||||
keywords = strings.Replace(keywords, "'", "", -1)
|
||||
keywords = strings.Replace(keywords, "\"", "", -1)
|
||||
keywords = strings.Replace(keywords, "%", "", -1)
|
||||
keywords = fmt.Sprintf("%%%s%%", strings.ToLower(keywords))
|
||||
|
||||
// s.c_itemid AS itemid
|
||||
|
||||
sql1 := s.Bind(`SELECT
|
||||
s.id, s.c_orgid AS orgid, s.c_docid AS documentid, s.c_itemid AS itemid, s.c_itemtype AS itemtype,
|
||||
d.c_spaceid as spaceid, COALESCE(d.c_name,'Unknown') AS document, d.c_tags AS tags,
|
||||
d.c_desc AS excerpt, d.c_template AS template, d.c_versionid AS versionid,
|
||||
COALESCE(l.c_name,'Unknown') AS space, d.c_created AS created, d.c_revised AS revised
|
||||
FROM
|
||||
dmz_search s,
|
||||
dmz_doc d
|
||||
LEFT JOIN
|
||||
dmz_space l ON l.c_orgid=d.c_orgid AND l.c_refid = d.c_spaceid
|
||||
WHERE
|
||||
s.c_orgid = ?
|
||||
AND s.c_itemtype = ?
|
||||
AND s.c_docid = d.c_refid
|
||||
AND d.c_spaceid IN
|
||||
(
|
||||
SELECT c_refid FROM dmz_space WHERE c_orgid=? AND c_refid IN
|
||||
(
|
||||
SELECT c_refid from dmz_permission WHERE c_orgid=? AND c_who='user' AND (c_whoid=? OR c_whoid='0') AND c_location='space'
|
||||
UNION ALL
|
||||
SELECT p.c_refid from dmz_permission p LEFT JOIN dmz_group_member r ON p.c_whoid=r.c_groupid WHERE p.c_orgid=? AND p.c_who='role'
|
||||
AND p.c_location='space' AND (r.c_userid=? OR r.c_userid='0')
|
||||
)
|
||||
)
|
||||
AND LOWER(s.c_content) LIKE ?`)
|
||||
|
||||
err = s.Runtime.Db.Select(&r,
|
||||
sql1,
|
||||
ctx.OrgID,
|
||||
itemType,
|
||||
ctx.OrgID,
|
||||
ctx.OrgID,
|
||||
ctx.UserID,
|
||||
ctx.OrgID,
|
||||
ctx.UserID,
|
||||
keywords)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
r = []search.QueryResult{}
|
||||
}
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "search document")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
|
@ -14,6 +14,7 @@ package store
|
|||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -36,6 +37,8 @@ func (c *Context) Bind(sql string) string {
|
|||
switch c.Runtime.StoreProvider.Type() {
|
||||
case env.StoreTypePostgreSQL:
|
||||
bindParam = sqlx.DOLLAR
|
||||
case env.StoreTypeSQLServer:
|
||||
bindParam = sqlx.AT
|
||||
}
|
||||
|
||||
return sqlx.Rebind(bindParam, sql)
|
||||
|
@ -106,3 +109,31 @@ func (c *Context) EmptyJSON() string {
|
|||
func (c *Context) GetJSONValue(column, attribute string) string {
|
||||
return c.Runtime.StoreProvider.JSONGetValue(column, attribute)
|
||||
}
|
||||
|
||||
// IsTrue return string representation of TRUE for storage provider.
|
||||
func (c *Context) IsTrue() string {
|
||||
return c.Runtime.StoreProvider.IsTrue()
|
||||
}
|
||||
|
||||
// IsFalse return string representation of FALSE for storage provider.
|
||||
func (c *Context) IsFalse() string {
|
||||
return c.Runtime.StoreProvider.IsFalse()
|
||||
}
|
||||
|
||||
// RowLimitVariants returns the SQL clause for limiting rows.
|
||||
// Depending on the storage provider, the limit clause goes either
|
||||
// at the start of the query or the end.
|
||||
func (c *Context) RowLimitVariants(max int) (variantStart string, variantEnd string) {
|
||||
variantStart = ""
|
||||
variantEnd = ""
|
||||
|
||||
if c.Runtime.StoreProvider.Type() == env.StoreTypeSQLServer {
|
||||
// SQL Server and variants use 'SELECT TOP nnn' syntax.
|
||||
variantStart = c.Runtime.StoreProvider.RowLimit(max)
|
||||
} else {
|
||||
// MySQL and variants use 'SELECT ... LIMIT nnn' syntax.
|
||||
variantEnd = c.Runtime.StoreProvider.RowLimit(max)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -15,10 +15,11 @@ import (
|
|||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/documize/community/model/category"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/documize/community/model/category"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/event"
|
||||
"github.com/documize/community/core/request"
|
||||
|
@ -36,6 +37,7 @@ import (
|
|||
"github.com/documize/community/model/doc"
|
||||
"github.com/documize/community/model/page"
|
||||
pm "github.com/documize/community/model/permission"
|
||||
|
||||
// "github.com/documize/community/model/template"
|
||||
"github.com/documize/community/model/workflow"
|
||||
uuid "github.com/nu7hatch/gouuid"
|
||||
|
@ -336,12 +338,7 @@ func (h *Handler) Use(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.Transaction, err = h.Runtime.Db.Beginx()
|
||||
if err != nil {
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
ctx.Transaction, _ = h.Runtime.StartTx(sql.LevelReadUncommitted)
|
||||
|
||||
// Prepare new document
|
||||
documentID = uniqueid.Generate()
|
||||
|
@ -386,11 +383,10 @@ func (h *Handler) Use(w http.ResponseWriter, r *http.Request) {
|
|||
model.Meta = meta
|
||||
|
||||
err = h.Store.Page.Add(ctx, model)
|
||||
|
||||
if err != nil {
|
||||
h.Runtime.Log.Error(method, err)
|
||||
ctx.Transaction.Rollback()
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -586,6 +586,7 @@ func (h *Handler) ForgotPassword(w http.ResponseWriter, r *http.Request) {
|
|||
ctx := domain.GetRequestContext(r)
|
||||
ctx.Subdomain = organization.GetSubdomainFromHost(r)
|
||||
|
||||
// Get email address from payload.
|
||||
defer streamutil.Close(r.Body)
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
|
@ -593,7 +594,6 @@ func (h *Handler) ForgotPassword(w http.ResponseWriter, r *http.Request) {
|
|||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
u := new(user.User)
|
||||
err = json.Unmarshal(body, &u)
|
||||
if err != nil {
|
||||
|
@ -602,6 +602,15 @@ func (h *Handler) ForgotPassword(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
// Exit process if user does not exist.
|
||||
_, err = h.Store.User.GetByEmail(ctx, u.Email)
|
||||
if err != nil {
|
||||
response.WriteNotFound(w)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
// Set token for password reset process.
|
||||
ctx.Transaction, err = h.Runtime.Db.Beginx()
|
||||
if err != nil {
|
||||
response.WriteServerError(w, method, err)
|
||||
|
@ -610,7 +619,6 @@ func (h *Handler) ForgotPassword(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
token := secrets.GenerateSalt()
|
||||
|
||||
err = h.Store.User.ForgotUserPassword(ctx, u.Email, token)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
ctx.Transaction.Rollback()
|
||||
|
@ -618,7 +626,6 @@ func (h *Handler) ForgotPassword(w http.ResponseWriter, r *http.Request) {
|
|||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
ctx.Transaction.Rollback()
|
||||
h.Runtime.Log.Info(fmt.Sprintf("User %s not found for password reset process", u.Email))
|
||||
|
@ -628,6 +635,7 @@ func (h *Handler) ForgotPassword(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
ctx.Transaction.Commit()
|
||||
|
||||
// Fire reset email to user.
|
||||
appURL := ctx.GetAppURL(fmt.Sprintf("auth/reset/%s", token))
|
||||
mailer := mail.Mailer{Runtime: h.Runtime, Store: h.Store, Context: ctx}
|
||||
go mailer.PasswordReset(u.Email, appURL)
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/user"
|
||||
|
@ -153,7 +154,7 @@ func (s Store) GetActiveUsersForOrganization(ctx domain.RequestContext) (u []use
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? AND a.c_active=true
|
||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? AND a.c_active=`+s.IsTrue()+`
|
||||
ORDER BY u.c_firstname, u.c_lastname`),
|
||||
ctx.OrgID)
|
||||
|
||||
|
@ -178,7 +179,8 @@ func (s Store) GetUsersForOrganization(ctx domain.RequestContext, filter string,
|
|||
likeQuery = " AND (LOWER(u.c_firstname) LIKE '%" + filter + "%' OR LOWER(u.c_lastname) LIKE '%" + filter + "%' OR LOWER(u.c_email) LIKE '%" + filter + "%') "
|
||||
}
|
||||
|
||||
err = s.Runtime.Db.Select(&u, s.Bind(`SELECT u.id, u.c_refid AS refid,
|
||||
if s.Runtime.StoreProvider.Type() == env.StoreTypeSQLServer {
|
||||
err = s.Runtime.Db.Select(&u, s.Bind(`SELECT TOP(`+strconv.Itoa(limit)+`) u.id, u.c_refid AS refid,
|
||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
||||
u.c_initials AS initials, u.c_globaladmin AS globaladmin,
|
||||
u.c_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||
|
@ -186,7 +188,18 @@ func (s Store) GetUsersForOrganization(ctx domain.RequestContext, filter string,
|
|||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? `+likeQuery+
|
||||
`ORDER BY u.c_firstname, u.c_lastname LIMIT `+strconv.Itoa(limit)), ctx.OrgID)
|
||||
`ORDER BY u.c_firstname, u.c_lastname`), ctx.OrgID)
|
||||
} else {
|
||||
err = s.Runtime.Db.Select(&u, s.Bind(`SELECT u.id, u.c_refid AS refid,
|
||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
||||
u.c_initials AS initials, u.c_globaladmin AS globaladmin,
|
||||
u.c_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? `+likeQuery+
|
||||
`ORDER BY u.c_firstname, u.c_lastname LIMIT `+strconv.Itoa(limit)), ctx.OrgID)
|
||||
}
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
|
@ -210,7 +223,7 @@ func (s Store) GetSpaceUsers(ctx domain.RequestContext, spaceID string) (u []use
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=true AND u.c_refid IN (
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=`+s.IsTrue()+` AND u.c_refid IN (
|
||||
SELECT c_whoid from dmz_permission WHERE c_orgid=? AND c_who='user' AND c_scope='object' AND c_location='space' AND c_refid=?
|
||||
UNION ALL
|
||||
SELECT r.c_userid from dmz_group_member r LEFT JOIN dmz_permission p ON p.c_whoid=r.c_groupid WHERE p.c_orgid=? AND p.c_who='role' AND p.c_scope='object' AND p.c_location='space' AND p.c_refid=?
|
||||
|
@ -236,22 +249,6 @@ func (s Store) GetUsersForSpaces(ctx domain.RequestContext, spaces []string) (u
|
|||
return
|
||||
}
|
||||
|
||||
// query, args, err := sqlx.In(s.Bind(`
|
||||
// SELECT u.id, u.c_refid AS refid,
|
||||
// u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
||||
// u.c_initials AS initials, u.c_globaladmin AS globaladmin,
|
||||
// u.c_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||
// u.c_created AS created, u.c_revised AS revised,
|
||||
// a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
// FROM dmz_user u, dmz_user_account a
|
||||
// WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=true AND u.c_refid IN (
|
||||
// SELECT c_whoid from dmz_permission WHERE c_orgid=? AND c_who='user' AND c_scope='object' AND c_location='space' AND c_refid IN(?)
|
||||
// UNION ALL
|
||||
// SELECT r.c_userid from dmz_group_member r LEFT JOIN dmz_permission p ON p.c_whoid=r.c_groupid WHERE p.c_orgid=? AND p.c_who='role' AND p.c_scope='object' AND p.c_location='space' AND p.c_refid IN(?)
|
||||
// )
|
||||
// ORDER BY u.c_firstname, u.c_lastname`),
|
||||
// ctx.OrgID, ctx.OrgID, spaces, ctx.OrgID, spaces)
|
||||
|
||||
query, args, err := sqlx.In(`
|
||||
SELECT u.id, u.c_refid AS refid,
|
||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
||||
|
@ -260,7 +257,7 @@ func (s Store) GetUsersForSpaces(ctx domain.RequestContext, spaces []string) (u
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=true AND u.c_refid IN (
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=`+s.IsTrue()+` AND u.c_refid IN (
|
||||
SELECT c_whoid from dmz_permission WHERE c_orgid=? AND c_who='user' AND c_scope='object' AND c_location='space' AND c_refid IN(?)
|
||||
UNION ALL
|
||||
SELECT r.c_userid from dmz_group_member r LEFT JOIN dmz_permission p ON p.c_whoid=r.c_groupid WHERE p.c_orgid=? AND p.c_who='role' AND p.c_scope='object' AND p.c_location='space' AND p.c_refid IN(?)
|
||||
|
@ -333,7 +330,7 @@ func (s Store) ForgotUserPassword(ctx domain.RequestContext, email, token string
|
|||
|
||||
// CountActiveUsers returns the number of active users in the system.
|
||||
func (s Store) CountActiveUsers() (c []domain.SubscriptionUserAccount) {
|
||||
err := s.Runtime.Db.Select(&c, "SELECT c_orgid AS orgid, COUNT(*) AS users FROM dmz_user_account WHERE c_active=true GROUP BY c_orgid ORDER BY c_orgid")
|
||||
err := s.Runtime.Db.Select(&c, "SELECT c_orgid AS orgid, COUNT(*) AS users FROM dmz_user_account WHERE c_active="+s.IsTrue()+" GROUP BY c_orgid ORDER BY c_orgid")
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
s.Runtime.Log.Error("CountActiveUsers", err)
|
||||
|
@ -360,7 +357,7 @@ func (s Store) MatchUsers(ctx domain.RequestContext, text string, maxMatches int
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE a.c_orgid=? AND u.c_refid=a.c_userid AND a.c_active=true `+likeQuery+` ORDER BY u.c_firstname, u.c_lastname LIMIT `+strconv.Itoa(maxMatches)),
|
||||
WHERE a.c_orgid=? AND u.c_refid=a.c_userid AND a.c_active=`+s.IsTrue()+likeQuery+` ORDER BY u.c_firstname, u.c_lastname LIMIT `+strconv.Itoa(maxMatches)),
|
||||
ctx.OrgID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
|
|
|
@ -61,8 +61,8 @@ func InitRuntime(r *env.Runtime, s *store.Store) bool {
|
|||
storage.SetMySQLProvider(r, s)
|
||||
case "postgresql":
|
||||
storage.SetPostgreSQLProvider(r, s)
|
||||
// case "mssql":
|
||||
// storage.SetSQLServerProvider(r, s)
|
||||
case "sqlserver":
|
||||
storage.SetSQLServerProvider(r, s)
|
||||
default:
|
||||
r.Log.Infof("Unsupported database type: %s", r.Flags.DBType)
|
||||
r.Log.Info("Documize supports the following database types: mysql | mariadb | percona | postgresql")
|
||||
|
@ -71,7 +71,7 @@ func InitRuntime(r *env.Runtime, s *store.Store) bool {
|
|||
}
|
||||
|
||||
// Open connection to database
|
||||
db, err := sqlx.Open(r.StoreProvider.DriverName(), r.StoreProvider.MakeConnectionString()) //r.Flags.DBConn
|
||||
db, err := sqlx.Open(r.StoreProvider.DriverName(), r.StoreProvider.MakeConnectionString())
|
||||
if err != nil {
|
||||
r.Log.Error("Unable to open database", err)
|
||||
os.Exit(1)
|
||||
|
|
|
@ -40,9 +40,9 @@ func main() {
|
|||
// product details
|
||||
rt.Product = domain.Product{}
|
||||
rt.Product.Major = "2"
|
||||
rt.Product.Minor = "2"
|
||||
rt.Product.Patch = "1"
|
||||
rt.Product.Revision = "190325132517"
|
||||
rt.Product.Minor = "3"
|
||||
rt.Product.Patch = "0"
|
||||
rt.Product.Revision = "190409124440"
|
||||
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
|
||||
rt.Product.Edition = domain.CommunityEdition
|
||||
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
||||
|
|
|
@ -190,8 +190,8 @@ func (p MySQLProvider) Params() map[string]string {
|
|||
}
|
||||
}
|
||||
|
||||
// Example holds storage provider specific connection string format.
|
||||
// used in error messages
|
||||
// Example holds storage provider specific connection string format
|
||||
// used in error messages.
|
||||
func (p MySQLProvider) Example() string {
|
||||
return "database connection string format is 'username:password@tcp(host:3306)/database'"
|
||||
}
|
||||
|
@ -354,6 +354,21 @@ func (p MySQLProvider) ConvertTimestamp() (statement string) {
|
|||
return `STR_TO_DATE(?,'%Y-%m-%d %H:%i:%s')`
|
||||
}
|
||||
|
||||
// IsTrue returns "1"
|
||||
func (p MySQLProvider) IsTrue() string {
|
||||
return "1"
|
||||
}
|
||||
|
||||
// IsFalse returns "0"
|
||||
func (p MySQLProvider) IsFalse() string {
|
||||
return "0"
|
||||
}
|
||||
|
||||
// RowLimit returns SQL for limiting number of rows returned.
|
||||
func (p MySQLProvider) RowLimit(max int) string {
|
||||
return fmt.Sprintf("LIMIT %d", max)
|
||||
}
|
||||
|
||||
// convertDatabaseVersion turns database version string as major,minor,patch numerics.
|
||||
func convertDatabaseVersion(v string) (ints []int, err error) {
|
||||
ints = []int{0, 0, 0}
|
||||
|
|
|
@ -37,7 +37,7 @@ import (
|
|||
space "github.com/documize/community/domain/space"
|
||||
"github.com/documize/community/domain/store"
|
||||
user "github.com/documize/community/domain/user"
|
||||
_ "github.com/lib/pq" // the mysql driver is required behind the scenes
|
||||
_ "github.com/lib/pq" // the PostgreSQL driver is required behind the scenes
|
||||
)
|
||||
|
||||
// PostgreSQLProvider supports by popular demand.
|
||||
|
@ -176,8 +176,8 @@ func (p PostgreSQLProvider) Params() map[string]string {
|
|||
return map[string]string{}
|
||||
}
|
||||
|
||||
// Example holds storage provider specific connection string format.
|
||||
// used in error messages
|
||||
// Example holds storage provider specific connection string format
|
||||
// used in error messages.
|
||||
func (p PostgreSQLProvider) Example() string {
|
||||
return "database connection string format is 'host=localhost port=5432 sslmode=disable user=admin password=secret dbname=documize'"
|
||||
}
|
||||
|
@ -295,3 +295,18 @@ func (p PostgreSQLProvider) VerfiyCharacterCollation(charset, collation string)
|
|||
func (p PostgreSQLProvider) ConvertTimestamp() (statement string) {
|
||||
return `to_timestamp(?,'YYYY-MM-DD HH24:MI:SS')`
|
||||
}
|
||||
|
||||
// IsTrue returns "true"
|
||||
func (p PostgreSQLProvider) IsTrue() string {
|
||||
return "true"
|
||||
}
|
||||
|
||||
// IsFalse returns "false"
|
||||
func (p PostgreSQLProvider) IsFalse() string {
|
||||
return "false"
|
||||
}
|
||||
|
||||
// RowLimit returns SQL for limiting number of rows returned.
|
||||
func (p PostgreSQLProvider) RowLimit(max int) string {
|
||||
return fmt.Sprintf("LIMIT %d", max)
|
||||
}
|
||||
|
|
377
edition/storage/sqlserver.go
Normal file
377
edition/storage/sqlserver.go
Normal file
|
@ -0,0 +1,377 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
// Package storage sets up database persistence providers.
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
_ "github.com/denisenkom/go-mssqldb" // the SQL Server driver is required behind the scenes
|
||||
"github.com/documize/community/core/env"
|
||||
account "github.com/documize/community/domain/account"
|
||||
activity "github.com/documize/community/domain/activity"
|
||||
attachment "github.com/documize/community/domain/attachment"
|
||||
audit "github.com/documize/community/domain/audit"
|
||||
block "github.com/documize/community/domain/block"
|
||||
category "github.com/documize/community/domain/category"
|
||||
document "github.com/documize/community/domain/document"
|
||||
group "github.com/documize/community/domain/group"
|
||||
label "github.com/documize/community/domain/label"
|
||||
link "github.com/documize/community/domain/link"
|
||||
meta "github.com/documize/community/domain/meta"
|
||||
org "github.com/documize/community/domain/organization"
|
||||
page "github.com/documize/community/domain/page"
|
||||
permission "github.com/documize/community/domain/permission"
|
||||
pin "github.com/documize/community/domain/pin"
|
||||
search "github.com/documize/community/domain/search"
|
||||
setting "github.com/documize/community/domain/setting"
|
||||
space "github.com/documize/community/domain/space"
|
||||
"github.com/documize/community/domain/store"
|
||||
user "github.com/documize/community/domain/user"
|
||||
)
|
||||
|
||||
// SQLServerProvider supports Microsoft SQl Server.
|
||||
type SQLServerProvider struct {
|
||||
// User specified connection string.
|
||||
ConnectionString string
|
||||
|
||||
// Unused for this provider.
|
||||
Variant env.StoreType
|
||||
}
|
||||
|
||||
// SetSQLServerProvider creates PostgreSQL provider.
|
||||
//
|
||||
// Useful links:
|
||||
//
|
||||
// Driver for Golang:
|
||||
// https://github.com/denisenkom/go-mssqldb
|
||||
// Docker Linux testing:
|
||||
// https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-2017
|
||||
// docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Passw0rd' -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest
|
||||
// JSON types:
|
||||
// https://docs.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-2017
|
||||
//
|
||||
// Supports 2016, 2017 and 2019.
|
||||
func SetSQLServerProvider(r *env.Runtime, s *store.Store) {
|
||||
// Set up provider specific details.
|
||||
r.StoreProvider = SQLServerProvider{
|
||||
ConnectionString: r.Flags.DBConn,
|
||||
Variant: env.StoreTypeSQLServer,
|
||||
}
|
||||
|
||||
// Wire up data providers.
|
||||
|
||||
// Account
|
||||
accountStore := account.Store{}
|
||||
accountStore.Runtime = r
|
||||
s.Account = accountStore
|
||||
|
||||
// Activity
|
||||
activityStore := activity.Store{}
|
||||
activityStore.Runtime = r
|
||||
s.Activity = activityStore
|
||||
|
||||
// Attachment
|
||||
attachmentStore := attachment.Store{}
|
||||
attachmentStore.Runtime = r
|
||||
s.Attachment = attachmentStore
|
||||
|
||||
// Audit
|
||||
auditStore := audit.Store{}
|
||||
auditStore.Runtime = r
|
||||
s.Audit = auditStore
|
||||
|
||||
// Section Template
|
||||
blockStore := block.Store{}
|
||||
blockStore.Runtime = r
|
||||
s.Block = blockStore
|
||||
|
||||
// Category
|
||||
categoryStore := category.Store{}
|
||||
categoryStore.Runtime = r
|
||||
s.Category = categoryStore
|
||||
|
||||
// Document
|
||||
documentStore := document.Store{}
|
||||
documentStore.Runtime = r
|
||||
s.Document = documentStore
|
||||
|
||||
// Group
|
||||
groupStore := group.Store{}
|
||||
groupStore.Runtime = r
|
||||
s.Group = groupStore
|
||||
|
||||
// Link
|
||||
linkStore := link.Store{}
|
||||
linkStore.Runtime = r
|
||||
s.Link = linkStore
|
||||
|
||||
// Meta
|
||||
metaStore := meta.Store{}
|
||||
metaStore.Runtime = r
|
||||
s.Meta = metaStore
|
||||
|
||||
// Organization (tenant)
|
||||
orgStore := org.Store{}
|
||||
orgStore.Runtime = r
|
||||
s.Organization = orgStore
|
||||
|
||||
// Page (section)
|
||||
pageStore := page.Store{}
|
||||
pageStore.Runtime = r
|
||||
s.Page = pageStore
|
||||
|
||||
// Permission
|
||||
permissionStore := permission.Store{}
|
||||
permissionStore.Runtime = r
|
||||
s.Permission = permissionStore
|
||||
|
||||
// Pin
|
||||
pinStore := pin.Store{}
|
||||
pinStore.Runtime = r
|
||||
s.Pin = pinStore
|
||||
|
||||
// Search
|
||||
searchStore := search.StoreSQLServer{}
|
||||
searchStore.Runtime = r
|
||||
s.Search = searchStore
|
||||
|
||||
// Setting
|
||||
settingStore := setting.Store{}
|
||||
settingStore.Runtime = r
|
||||
s.Setting = settingStore
|
||||
|
||||
// Space
|
||||
spaceStore := space.Store{}
|
||||
spaceStore.Runtime = r
|
||||
s.Space = spaceStore
|
||||
|
||||
// User
|
||||
userStore := user.Store{}
|
||||
userStore.Runtime = r
|
||||
s.User = userStore
|
||||
|
||||
// Space Label
|
||||
labelStore := label.Store{}
|
||||
labelStore.Runtime = r
|
||||
s.Label = labelStore
|
||||
}
|
||||
|
||||
// Type returns name of provider
|
||||
func (p SQLServerProvider) Type() env.StoreType {
|
||||
return env.StoreTypeSQLServer
|
||||
}
|
||||
|
||||
// TypeVariant returns databse flavor
|
||||
func (p SQLServerProvider) TypeVariant() env.StoreType {
|
||||
return p.Variant
|
||||
}
|
||||
|
||||
// DriverName returns database/sql driver name.
|
||||
func (p SQLServerProvider) DriverName() string {
|
||||
return "sqlserver"
|
||||
}
|
||||
|
||||
// Params returns connection string parameters that must be present before connecting to DB.
|
||||
func (p SQLServerProvider) Params() map[string]string {
|
||||
// Not used for this provider.
|
||||
// return map[string]string{}
|
||||
|
||||
return map[string]string{
|
||||
"app+name": "Documize",
|
||||
"connection+timeout": "0",
|
||||
"keep-alive": "0",
|
||||
}
|
||||
}
|
||||
|
||||
// Example holds storage provider specific connection string format
|
||||
// used in error messages.
|
||||
func (p SQLServerProvider) Example() string {
|
||||
return "database connection string format options: sqlserver://username:password@host:port?database=Documize OR sqlserver://username:password@host/instance?database=Documize OR sqlserver://sa@localhost/SQLExpress?database=Documize"
|
||||
}
|
||||
|
||||
// DatabaseName holds the SQL database name where Documize tables live.
|
||||
func (p SQLServerProvider) DatabaseName() string {
|
||||
bits := strings.Split(p.ConnectionString, "?")
|
||||
if len(bits) != 2 {
|
||||
return ""
|
||||
}
|
||||
|
||||
params := strings.Split(bits[len(bits)-1], "&")
|
||||
for _, s := range params {
|
||||
s = strings.TrimSpace(s)
|
||||
if strings.Contains(s, "database=") {
|
||||
s = strings.Replace(s, "database=", "", 1)
|
||||
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
// MakeConnectionString returns provider specific DB connection string
|
||||
// complete with default parameters.
|
||||
func (p SQLServerProvider) MakeConnectionString() string {
|
||||
queryBits := strings.Split(p.ConnectionString, "?")
|
||||
ret := queryBits[0] + "?"
|
||||
retFirst := true
|
||||
|
||||
params := p.Params()
|
||||
|
||||
if len(queryBits) == 2 {
|
||||
paramBits := strings.Split(queryBits[1], "&")
|
||||
for _, pb := range paramBits {
|
||||
found := false
|
||||
if assignBits := strings.Split(pb, "="); len(assignBits) == 2 {
|
||||
_, found = params[strings.TrimSpace(assignBits[0])]
|
||||
}
|
||||
if !found { // if we can't work out what it is, put it through
|
||||
if retFirst {
|
||||
retFirst = false
|
||||
} else {
|
||||
ret += "&"
|
||||
}
|
||||
ret += pb
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
if retFirst {
|
||||
retFirst = false
|
||||
} else {
|
||||
ret += "&"
|
||||
}
|
||||
ret += k + "=" + v
|
||||
}
|
||||
|
||||
return ret
|
||||
// No special processing so return as-is.
|
||||
// return p.ConnectionString
|
||||
}
|
||||
|
||||
// QueryMeta is how to extract version number, version related comment,
|
||||
// character set and collation from database provider.
|
||||
func (p SQLServerProvider) QueryMeta() string {
|
||||
return fmt.Sprintf(`
|
||||
SELECT
|
||||
CAST(SERVERPROPERTY('productversion') AS VARCHAR) AS version,
|
||||
@@VERSION AS comment,
|
||||
collation_name AS collation,
|
||||
'' AS charset
|
||||
FROM sys.databases
|
||||
WHERE name='%s'`, p.DatabaseName())
|
||||
}
|
||||
|
||||
// QueryRecordVersionUpgrade returns database specific insert statement
|
||||
// that records the database version number.
|
||||
func (p SQLServerProvider) QueryRecordVersionUpgrade(version int) string {
|
||||
// Make record that holds new database version number.
|
||||
json := fmt.Sprintf("{\"database\": \"%d\"}", version)
|
||||
|
||||
return fmt.Sprintf(`UPDATE dmz_config SET c_config='%s' WHERE c_key='META'`, json)
|
||||
}
|
||||
|
||||
// QueryRecordVersionUpgradeLegacy returns database specific insert statement
|
||||
// that records the database version number.
|
||||
func (p SQLServerProvider) QueryRecordVersionUpgradeLegacy(version int) string {
|
||||
// This provider has no legacy schema.
|
||||
return p.QueryRecordVersionUpgrade(version)
|
||||
}
|
||||
|
||||
// QueryGetDatabaseVersion returns the schema version number.
|
||||
func (p SQLServerProvider) QueryGetDatabaseVersion() string {
|
||||
return "SELECT JSON_VALUE(c_config, '$.database') FROM dmz_config WHERE c_key = 'META';"
|
||||
}
|
||||
|
||||
// QueryGetDatabaseVersionLegacy returns the schema version number before The Great Schema Migration (v25, MySQL).
|
||||
func (p SQLServerProvider) QueryGetDatabaseVersionLegacy() string {
|
||||
// This provider has no legacy schema.
|
||||
return p.QueryGetDatabaseVersion()
|
||||
}
|
||||
|
||||
// QueryTableList returns a list tables in Documize database.
|
||||
func (p SQLServerProvider) QueryTableList() string {
|
||||
return fmt.Sprintf(`SELECT TABLE_NAME
|
||||
FROM %s.INFORMATION_SCHEMA.TABLES`, p.DatabaseName())
|
||||
}
|
||||
|
||||
// QueryDateInterval returns provider specific interval style
|
||||
// date SQL.
|
||||
func (p SQLServerProvider) QueryDateInterval(days int64) string {
|
||||
return fmt.Sprintf("DATEADD(DAY, -%d, GETDATE())", days)
|
||||
}
|
||||
|
||||
// JSONEmpty returns empty SQL JSON object.
|
||||
// Typically used as 2nd parameter to COALESCE().
|
||||
func (p SQLServerProvider) JSONEmpty() string {
|
||||
return "'{}'"
|
||||
}
|
||||
|
||||
// JSONGetValue returns JSON attribute selection syntax.
|
||||
// Typically used in SELECT <my_json_field> query.
|
||||
func (p SQLServerProvider) JSONGetValue(column, attribute string) string {
|
||||
if len(attribute) > 0 {
|
||||
return fmt.Sprintf("JSON_VALUE(%s, '$.%s'", column, attribute)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("JSON_QUERY(%s)", column)
|
||||
}
|
||||
|
||||
// VerfiyVersion checks to see if actual database meets
|
||||
// minimum version requirements.
|
||||
//
|
||||
// See: http://sqlserverbuilds.blogspot.com
|
||||
func (p SQLServerProvider) VerfiyVersion(dbVersion string) (bool, string) {
|
||||
|
||||
if strings.HasPrefix(dbVersion, "13.") ||
|
||||
strings.HasPrefix(dbVersion, "14.") ||
|
||||
strings.HasPrefix(dbVersion, "15.") {
|
||||
return true, ""
|
||||
}
|
||||
|
||||
return false, "Microsoft SQL Server 2016, 2017 or 2019 is required"
|
||||
}
|
||||
|
||||
// VerfiyCharacterCollation needs to ensure utf8.
|
||||
// https://www.red-gate.com/simple-talk/sql/sql-development/questions-sql-server-collations-shy-ask/
|
||||
func (p SQLServerProvider) VerfiyCharacterCollation(charset, collation string) (charOK bool, requirements string) {
|
||||
// Collation & characters check ignored.
|
||||
return true, ""
|
||||
}
|
||||
|
||||
// ConvertTimestamp returns SQL function to correctly convert
|
||||
// ISO 8601 format (e.g. '2016-09-08T06:37:23Z') to SQL specific
|
||||
// timestamp value (e.g. 2016-09-08 06:37:23).
|
||||
//
|
||||
// We must use ? for parameter placeholder character as DB layer
|
||||
// will convert to database specific parameter placeholder character.
|
||||
func (p SQLServerProvider) ConvertTimestamp() (statement string) {
|
||||
return `convert(varchar, ?, 13)`
|
||||
}
|
||||
|
||||
// IsTrue returns "1"
|
||||
func (p SQLServerProvider) IsTrue() string {
|
||||
return "1"
|
||||
}
|
||||
|
||||
// IsFalse returns "0"
|
||||
func (p SQLServerProvider) IsFalse() string {
|
||||
return "0"
|
||||
}
|
||||
|
||||
// RowLimit returns SQL for limiting number of rows returned.
|
||||
func (p SQLServerProvider) RowLimit(max int) string {
|
||||
return fmt.Sprintf("TOP %d", max)
|
||||
}
|
88
edition/storage/storage_test.go
Normal file
88
edition/storage/storage_test.go
Normal file
|
@ -0,0 +1,88 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package storage
|
||||
|
||||
// go test -timeout 30s github.com/documize/community/edition/storage -v
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
func TestSQLServerProviderDatabaseName(t *testing.T) {
|
||||
r := env.Runtime{}
|
||||
s := store.Store{}
|
||||
r.Flags.DBType = "sqlserver"
|
||||
r.Flags.DBConn = "sqlserver://username:password@host:port?database=Test1Documize"
|
||||
|
||||
SetSQLServerProvider(&r, &s)
|
||||
|
||||
if r.StoreProvider.DatabaseName() != "Test1Documize" {
|
||||
t.Errorf("expected %s got %s", "Test1Documize", r.StoreProvider.DatabaseName())
|
||||
}
|
||||
|
||||
t.Log(r.StoreProvider.MakeConnectionString())
|
||||
}
|
||||
|
||||
func TestSQLServerProviderDatabaseNameWithParams(t *testing.T) {
|
||||
r := env.Runtime{}
|
||||
s := store.Store{}
|
||||
r.Flags.DBType = "sqlserver"
|
||||
r.Flags.DBConn = "sqlserver://username:password@host:port?database=Test2Documize&some=param"
|
||||
|
||||
SetSQLServerProvider(&r, &s)
|
||||
|
||||
if r.StoreProvider.DatabaseName() != "Test2Documize" {
|
||||
t.Errorf("expected %s got %s", "Test2Documize", r.StoreProvider.DatabaseName())
|
||||
}
|
||||
|
||||
t.Log(r.StoreProvider.MakeConnectionString())
|
||||
}
|
||||
|
||||
func TestSQLServerVersion(t *testing.T) {
|
||||
r := env.Runtime{}
|
||||
s := store.Store{}
|
||||
r.Flags.DBType = "sqlserver"
|
||||
r.Flags.DBConn = "sqlserver://username:password@host:port?database=Test2Documize&some=param"
|
||||
|
||||
SetSQLServerProvider(&r, &s)
|
||||
|
||||
version := "15.0.1300.359"
|
||||
ok, msg := r.StoreProvider.VerfiyVersion(version)
|
||||
if !ok {
|
||||
t.Errorf("2019 check failed: %s", msg)
|
||||
}
|
||||
t.Log(version)
|
||||
|
||||
version = "14.0.3048.4"
|
||||
ok, msg = r.StoreProvider.VerfiyVersion(version)
|
||||
if !ok {
|
||||
t.Errorf("2017 check failed: %s", msg)
|
||||
}
|
||||
t.Log(version)
|
||||
|
||||
version = "13.0.1601.5"
|
||||
ok, msg = r.StoreProvider.VerfiyVersion(version)
|
||||
if !ok {
|
||||
t.Errorf("2016 check failed: %s", msg)
|
||||
}
|
||||
t.Log(version)
|
||||
|
||||
version = "12.0.6214.1"
|
||||
ok, msg = r.StoreProvider.VerfiyVersion(version)
|
||||
if ok {
|
||||
t.Errorf("unsupported release check failed: %s", msg)
|
||||
}
|
||||
t.Log(version)
|
||||
}
|
1501
embed/bindata.go
1501
embed/bindata.go
File diff suppressed because one or more lines are too long
|
@ -18,6 +18,7 @@ import Component from '@ember/component';
|
|||
export default Component.extend({
|
||||
email: "",
|
||||
sayThanks: false,
|
||||
sayError: false,
|
||||
emailEmpty: empty('email'),
|
||||
hasEmptyEmailError: and('emailEmpty', 'emailIsEmpty'),
|
||||
|
||||
|
@ -30,10 +31,16 @@ export default Component.extend({
|
|||
return $("#email").focus();
|
||||
}
|
||||
|
||||
set(this, 'sayThanks', false);
|
||||
set(this, 'sayError', false);
|
||||
|
||||
set(this, 'emailIsEmpty', false);
|
||||
|
||||
this.get('forgot')(email).then(() => {
|
||||
set(this, 'sayThanks', true);
|
||||
set(this, 'email', '');
|
||||
set(this, 'emailIsEmpty', false);
|
||||
}).catch(() => {
|
||||
set(this, 'sayError', true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,10 +136,13 @@ let constants = EmberObject.extend({
|
|||
Publish: 7,
|
||||
},
|
||||
|
||||
// Meta
|
||||
// Database type
|
||||
StoreProvider: { // eslint-disable-line ember/avoid-leaking-state-in-ember-objects
|
||||
MySQL: 'MySQL',
|
||||
PostgreSQL: 'PostgreSQL',
|
||||
Percona: 'Percona',
|
||||
MariaDB: 'MariaDB',
|
||||
SQLServer: 'SQLServer',
|
||||
},
|
||||
|
||||
// Product is where we try to balance the fine line between useful open core
|
||||
|
|
|
@ -2516,4 +2516,35 @@ https:///github.com/trivago/tgo
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
https://github.com/denisenkom/go-mssqldb
|
||||
|
||||
Copyright (c) 2012 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
</pre>
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
<div class="explain">Show results that have "google", either "apple" or "microsoft" but not "ibm"</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if (eq appMeta.storageProvider constants.StoreProvider.SQLServer)}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
{{/layout/master-sidebar}}
|
||||
|
@ -64,7 +66,7 @@
|
|||
{{#layout/master-content}}
|
||||
{{layout/logo-heading
|
||||
title="Search"
|
||||
desc="Basic and advanced search queries"
|
||||
desc="Find content"
|
||||
icon=constants.Icon.Search}}
|
||||
|
||||
{{search/search-view
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
// https://documize.com
|
||||
|
||||
import { isEmpty } from '@ember/utils';
|
||||
|
||||
import RSVP from 'rsvp';
|
||||
import Service, { inject as service } from '@ember/service';
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
{{#attach-popover class="ember-attacher-popper" hideOn="clickout" showOn="click" isShown=false}}
|
||||
<ul class="menu">
|
||||
<li class="item" {{action "onExport"}}>Export as HTML file</li>
|
||||
<li class="item" {{action "onPDF"}}>Download as PDF</li>
|
||||
<li class="item" {{action "onPrintDocument"}}>Print...</li>
|
||||
</ul>
|
||||
{{/attach-popover}}
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
<form {{action "forgot" on="submit"}}>
|
||||
{{#if sayThanks}}
|
||||
<div class="reset-thanks margin-bottom-30">Thanks. Check your email for instructions.</div>
|
||||
<p class="color-green-700 margin-bottom-30">Thanks. Check your email for instructions.</p>
|
||||
{{else}}
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
{{focus-input type="email" value=email id="email" class=(if hasEmptyEmailError "form-control is-invalid" "form-control")}}
|
||||
{{#if sayError}}
|
||||
<p class="color-red-700 margin-top-10">Email not found</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{ui/ui-button color=constants.Color.Yellow light=true label=constants.Label.Reset onClick=(action "forgot")}}
|
||||
{{/if}}
|
||||
|
||||
{{ui/ui-spacer size=400}}
|
||||
{{#link-to "auth.login"}}Click here to sign in{{/link-to}}
|
||||
</form>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "documize",
|
||||
"version": "2.2.1",
|
||||
"version": "2.3.0",
|
||||
"description": "The Document IDE",
|
||||
"repository": "",
|
||||
"license": "AGPL",
|
||||
|
|
|
@ -32,7 +32,7 @@ type Member struct {
|
|||
|
||||
// SummaryModel holds number of documents and users for space categories.
|
||||
type SummaryModel struct {
|
||||
Type string `json:"type"` // documents or users
|
||||
GroupType string `json:"type"` // documents or users
|
||||
CategoryID string `json:"categoryId"`
|
||||
Count int64 `json:"count"`
|
||||
}
|
||||
|
|
15
vendor/cloud.google.com/go/AUTHORS
generated
vendored
Normal file
15
vendor/cloud.google.com/go/AUTHORS
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
# This is the official list of cloud authors for copyright purposes.
|
||||
# This file is distinct from the CONTRIBUTORS files.
|
||||
# See the latter for an explanation.
|
||||
|
||||
# Names should be added to this file as:
|
||||
# Name or Organization <email address>
|
||||
# The email address is not required for organizations.
|
||||
|
||||
Filippo Valsorda <hi@filippo.io>
|
||||
Google Inc.
|
||||
Ingo Oeser <nightlyone@googlemail.com>
|
||||
Palm Stone Games, Inc.
|
||||
Paweł Knap <pawelknap88@gmail.com>
|
||||
Péter Szilágyi <peterke@gmail.com>
|
||||
Tyler Treat <ttreat31@gmail.com>
|
40
vendor/cloud.google.com/go/CONTRIBUTORS
generated
vendored
Normal file
40
vendor/cloud.google.com/go/CONTRIBUTORS
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
# People who have agreed to one of the CLAs and can contribute patches.
|
||||
# The AUTHORS file lists the copyright holders; this file
|
||||
# lists people. For example, Google employees are listed here
|
||||
# but not in AUTHORS, because Google holds the copyright.
|
||||
#
|
||||
# https://developers.google.com/open-source/cla/individual
|
||||
# https://developers.google.com/open-source/cla/corporate
|
||||
#
|
||||
# Names should be added to this file as:
|
||||
# Name <email address>
|
||||
|
||||
# Keep the list alphabetically sorted.
|
||||
|
||||
Alexis Hunt <lexer@google.com>
|
||||
Andreas Litt <andreas.litt@gmail.com>
|
||||
Andrew Gerrand <adg@golang.org>
|
||||
Brad Fitzpatrick <bradfitz@golang.org>
|
||||
Burcu Dogan <jbd@google.com>
|
||||
Dave Day <djd@golang.org>
|
||||
David Sansome <me@davidsansome.com>
|
||||
David Symonds <dsymonds@golang.org>
|
||||
Filippo Valsorda <hi@filippo.io>
|
||||
Glenn Lewis <gmlewis@google.com>
|
||||
Ingo Oeser <nightlyone@googlemail.com>
|
||||
James Hall <james.hall@shopify.com>
|
||||
Johan Euphrosine <proppy@google.com>
|
||||
Jonathan Amsterdam <jba@google.com>
|
||||
Kunpei Sakai <namusyaka@gmail.com>
|
||||
Luna Duclos <luna.duclos@palmstonegames.com>
|
||||
Magnus Hiie <magnus.hiie@gmail.com>
|
||||
Mario Castro <mariocaster@gmail.com>
|
||||
Michael McGreevy <mcgreevy@golang.org>
|
||||
Omar Jarjur <ojarjur@google.com>
|
||||
Paweł Knap <pawelknap88@gmail.com>
|
||||
Péter Szilágyi <peterke@gmail.com>
|
||||
Sarah Adams <shadams@google.com>
|
||||
Thanatat Tamtan <acoshift@gmail.com>
|
||||
Toby Burress <kurin@google.com>
|
||||
Tuo Shan <shantuo@google.com>
|
||||
Tyler Treat <ttreat31@gmail.com>
|
202
vendor/cloud.google.com/go/LICENSE
generated
vendored
Normal file
202
vendor/cloud.google.com/go/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
277
vendor/cloud.google.com/go/civil/civil.go
generated
vendored
Normal file
277
vendor/cloud.google.com/go/civil/civil.go
generated
vendored
Normal file
|
@ -0,0 +1,277 @@
|
|||
// Copyright 2016 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package civil implements types for civil time, a time-zone-independent
|
||||
// representation of time that follows the rules of the proleptic
|
||||
// Gregorian calendar with exactly 24-hour days, 60-minute hours, and 60-second
|
||||
// minutes.
|
||||
//
|
||||
// Because they lack location information, these types do not represent unique
|
||||
// moments or intervals of time. Use time.Time for that purpose.
|
||||
package civil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A Date represents a date (year, month, day).
|
||||
//
|
||||
// This type does not include location information, and therefore does not
|
||||
// describe a unique 24-hour timespan.
|
||||
type Date struct {
|
||||
Year int // Year (e.g., 2014).
|
||||
Month time.Month // Month of the year (January = 1, ...).
|
||||
Day int // Day of the month, starting at 1.
|
||||
}
|
||||
|
||||
// DateOf returns the Date in which a time occurs in that time's location.
|
||||
func DateOf(t time.Time) Date {
|
||||
var d Date
|
||||
d.Year, d.Month, d.Day = t.Date()
|
||||
return d
|
||||
}
|
||||
|
||||
// ParseDate parses a string in RFC3339 full-date format and returns the date value it represents.
|
||||
func ParseDate(s string) (Date, error) {
|
||||
t, err := time.Parse("2006-01-02", s)
|
||||
if err != nil {
|
||||
return Date{}, err
|
||||
}
|
||||
return DateOf(t), nil
|
||||
}
|
||||
|
||||
// String returns the date in RFC3339 full-date format.
|
||||
func (d Date) String() string {
|
||||
return fmt.Sprintf("%04d-%02d-%02d", d.Year, d.Month, d.Day)
|
||||
}
|
||||
|
||||
// IsValid reports whether the date is valid.
|
||||
func (d Date) IsValid() bool {
|
||||
return DateOf(d.In(time.UTC)) == d
|
||||
}
|
||||
|
||||
// In returns the time corresponding to time 00:00:00 of the date in the location.
|
||||
//
|
||||
// In is always consistent with time.Date, even when time.Date returns a time
|
||||
// on a different day. For example, if loc is America/Indiana/Vincennes, then both
|
||||
// time.Date(1955, time.May, 1, 0, 0, 0, 0, loc)
|
||||
// and
|
||||
// civil.Date{Year: 1955, Month: time.May, Day: 1}.In(loc)
|
||||
// return 23:00:00 on April 30, 1955.
|
||||
//
|
||||
// In panics if loc is nil.
|
||||
func (d Date) In(loc *time.Location) time.Time {
|
||||
return time.Date(d.Year, d.Month, d.Day, 0, 0, 0, 0, loc)
|
||||
}
|
||||
|
||||
// AddDays returns the date that is n days in the future.
|
||||
// n can also be negative to go into the past.
|
||||
func (d Date) AddDays(n int) Date {
|
||||
return DateOf(d.In(time.UTC).AddDate(0, 0, n))
|
||||
}
|
||||
|
||||
// DaysSince returns the signed number of days between the date and s, not including the end day.
|
||||
// This is the inverse operation to AddDays.
|
||||
func (d Date) DaysSince(s Date) (days int) {
|
||||
// We convert to Unix time so we do not have to worry about leap seconds:
|
||||
// Unix time increases by exactly 86400 seconds per day.
|
||||
deltaUnix := d.In(time.UTC).Unix() - s.In(time.UTC).Unix()
|
||||
return int(deltaUnix / 86400)
|
||||
}
|
||||
|
||||
// Before reports whether d1 occurs before d2.
|
||||
func (d1 Date) Before(d2 Date) bool {
|
||||
if d1.Year != d2.Year {
|
||||
return d1.Year < d2.Year
|
||||
}
|
||||
if d1.Month != d2.Month {
|
||||
return d1.Month < d2.Month
|
||||
}
|
||||
return d1.Day < d2.Day
|
||||
}
|
||||
|
||||
// After reports whether d1 occurs after d2.
|
||||
func (d1 Date) After(d2 Date) bool {
|
||||
return d2.Before(d1)
|
||||
}
|
||||
|
||||
// MarshalText implements the encoding.TextMarshaler interface.
|
||||
// The output is the result of d.String().
|
||||
func (d Date) MarshalText() ([]byte, error) {
|
||||
return []byte(d.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the encoding.TextUnmarshaler interface.
|
||||
// The date is expected to be a string in a format accepted by ParseDate.
|
||||
func (d *Date) UnmarshalText(data []byte) error {
|
||||
var err error
|
||||
*d, err = ParseDate(string(data))
|
||||
return err
|
||||
}
|
||||
|
||||
// A Time represents a time with nanosecond precision.
|
||||
//
|
||||
// This type does not include location information, and therefore does not
|
||||
// describe a unique moment in time.
|
||||
//
|
||||
// This type exists to represent the TIME type in storage-based APIs like BigQuery.
|
||||
// Most operations on Times are unlikely to be meaningful. Prefer the DateTime type.
|
||||
type Time struct {
|
||||
Hour int // The hour of the day in 24-hour format; range [0-23]
|
||||
Minute int // The minute of the hour; range [0-59]
|
||||
Second int // The second of the minute; range [0-59]
|
||||
Nanosecond int // The nanosecond of the second; range [0-999999999]
|
||||
}
|
||||
|
||||
// TimeOf returns the Time representing the time of day in which a time occurs
|
||||
// in that time's location. It ignores the date.
|
||||
func TimeOf(t time.Time) Time {
|
||||
var tm Time
|
||||
tm.Hour, tm.Minute, tm.Second = t.Clock()
|
||||
tm.Nanosecond = t.Nanosecond()
|
||||
return tm
|
||||
}
|
||||
|
||||
// ParseTime parses a string and returns the time value it represents.
|
||||
// ParseTime accepts an extended form of the RFC3339 partial-time format. After
|
||||
// the HH:MM:SS part of the string, an optional fractional part may appear,
|
||||
// consisting of a decimal point followed by one to nine decimal digits.
|
||||
// (RFC3339 admits only one digit after the decimal point).
|
||||
func ParseTime(s string) (Time, error) {
|
||||
t, err := time.Parse("15:04:05.999999999", s)
|
||||
if err != nil {
|
||||
return Time{}, err
|
||||
}
|
||||
return TimeOf(t), nil
|
||||
}
|
||||
|
||||
// String returns the date in the format described in ParseTime. If Nanoseconds
|
||||
// is zero, no fractional part will be generated. Otherwise, the result will
|
||||
// end with a fractional part consisting of a decimal point and nine digits.
|
||||
func (t Time) String() string {
|
||||
s := fmt.Sprintf("%02d:%02d:%02d", t.Hour, t.Minute, t.Second)
|
||||
if t.Nanosecond == 0 {
|
||||
return s
|
||||
}
|
||||
return s + fmt.Sprintf(".%09d", t.Nanosecond)
|
||||
}
|
||||
|
||||
// IsValid reports whether the time is valid.
|
||||
func (t Time) IsValid() bool {
|
||||
// Construct a non-zero time.
|
||||
tm := time.Date(2, 2, 2, t.Hour, t.Minute, t.Second, t.Nanosecond, time.UTC)
|
||||
return TimeOf(tm) == t
|
||||
}
|
||||
|
||||
// MarshalText implements the encoding.TextMarshaler interface.
|
||||
// The output is the result of t.String().
|
||||
func (t Time) MarshalText() ([]byte, error) {
|
||||
return []byte(t.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the encoding.TextUnmarshaler interface.
|
||||
// The time is expected to be a string in a format accepted by ParseTime.
|
||||
func (t *Time) UnmarshalText(data []byte) error {
|
||||
var err error
|
||||
*t, err = ParseTime(string(data))
|
||||
return err
|
||||
}
|
||||
|
||||
// A DateTime represents a date and time.
|
||||
//
|
||||
// This type does not include location information, and therefore does not
|
||||
// describe a unique moment in time.
|
||||
type DateTime struct {
|
||||
Date Date
|
||||
Time Time
|
||||
}
|
||||
|
||||
// Note: We deliberately do not embed Date into DateTime, to avoid promoting AddDays and Sub.
|
||||
|
||||
// DateTimeOf returns the DateTime in which a time occurs in that time's location.
|
||||
func DateTimeOf(t time.Time) DateTime {
|
||||
return DateTime{
|
||||
Date: DateOf(t),
|
||||
Time: TimeOf(t),
|
||||
}
|
||||
}
|
||||
|
||||
// ParseDateTime parses a string and returns the DateTime it represents.
|
||||
// ParseDateTime accepts a variant of the RFC3339 date-time format that omits
|
||||
// the time offset but includes an optional fractional time, as described in
|
||||
// ParseTime. Informally, the accepted format is
|
||||
// YYYY-MM-DDTHH:MM:SS[.FFFFFFFFF]
|
||||
// where the 'T' may be a lower-case 't'.
|
||||
func ParseDateTime(s string) (DateTime, error) {
|
||||
t, err := time.Parse("2006-01-02T15:04:05.999999999", s)
|
||||
if err != nil {
|
||||
t, err = time.Parse("2006-01-02t15:04:05.999999999", s)
|
||||
if err != nil {
|
||||
return DateTime{}, err
|
||||
}
|
||||
}
|
||||
return DateTimeOf(t), nil
|
||||
}
|
||||
|
||||
// String returns the date in the format described in ParseDate.
|
||||
func (dt DateTime) String() string {
|
||||
return dt.Date.String() + "T" + dt.Time.String()
|
||||
}
|
||||
|
||||
// IsValid reports whether the datetime is valid.
|
||||
func (dt DateTime) IsValid() bool {
|
||||
return dt.Date.IsValid() && dt.Time.IsValid()
|
||||
}
|
||||
|
||||
// In returns the time corresponding to the DateTime in the given location.
|
||||
//
|
||||
// If the time is missing or ambigous at the location, In returns the same
|
||||
// result as time.Date. For example, if loc is America/Indiana/Vincennes, then
|
||||
// both
|
||||
// time.Date(1955, time.May, 1, 0, 30, 0, 0, loc)
|
||||
// and
|
||||
// civil.DateTime{
|
||||
// civil.Date{Year: 1955, Month: time.May, Day: 1}},
|
||||
// civil.Time{Minute: 30}}.In(loc)
|
||||
// return 23:30:00 on April 30, 1955.
|
||||
//
|
||||
// In panics if loc is nil.
|
||||
func (dt DateTime) In(loc *time.Location) time.Time {
|
||||
return time.Date(dt.Date.Year, dt.Date.Month, dt.Date.Day, dt.Time.Hour, dt.Time.Minute, dt.Time.Second, dt.Time.Nanosecond, loc)
|
||||
}
|
||||
|
||||
// Before reports whether dt1 occurs before dt2.
|
||||
func (dt1 DateTime) Before(dt2 DateTime) bool {
|
||||
return dt1.In(time.UTC).Before(dt2.In(time.UTC))
|
||||
}
|
||||
|
||||
// After reports whether dt1 occurs after dt2.
|
||||
func (dt1 DateTime) After(dt2 DateTime) bool {
|
||||
return dt2.Before(dt1)
|
||||
}
|
||||
|
||||
// MarshalText implements the encoding.TextMarshaler interface.
|
||||
// The output is the result of dt.String().
|
||||
func (dt DateTime) MarshalText() ([]byte, error) {
|
||||
return []byte(dt.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the encoding.TextUnmarshaler interface.
|
||||
// The datetime is expected to be a string in a format accepted by ParseDateTime
|
||||
func (dt *DateTime) UnmarshalText(data []byte) error {
|
||||
var err error
|
||||
*dt, err = ParseDateTime(string(data))
|
||||
return err
|
||||
}
|
27
vendor/github.com/denisenkom/go-mssqldb/LICENSE.txt
generated
vendored
Normal file
27
vendor/github.com/denisenkom/go-mssqldb/LICENSE.txt
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
Copyright (c) 2012 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
255
vendor/github.com/denisenkom/go-mssqldb/README.md
generated
vendored
Normal file
255
vendor/github.com/denisenkom/go-mssqldb/README.md
generated
vendored
Normal file
|
@ -0,0 +1,255 @@
|
|||
# A pure Go MSSQL driver for Go's database/sql package
|
||||
|
||||
[](http://godoc.org/github.com/denisenkom/go-mssqldb)
|
||||
[](https://ci.appveyor.com/project/denisenkom/go-mssqldb)
|
||||
[](https://codecov.io/gh/denisenkom/go-mssqldb)
|
||||
|
||||
## Install
|
||||
|
||||
Requires Go 1.8 or above.
|
||||
|
||||
Install with `go get github.com/denisenkom/go-mssqldb` .
|
||||
|
||||
## Connection Parameters and DSN
|
||||
|
||||
The recommended connection string uses a URL format:
|
||||
`sqlserver://username:password@host/instance?param1=value¶m2=value`
|
||||
Other supported formats are listed below.
|
||||
|
||||
### Common parameters:
|
||||
|
||||
* `user id` - enter the SQL Server Authentication user id or the Windows Authentication user id in the DOMAIN\User format. On Windows, if user id is empty or missing Single-Sign-On is used.
|
||||
* `password`
|
||||
* `database`
|
||||
* `connection timeout` - in seconds (default is 0 for no timeout), set to 0 for no timeout. Recommended to set to 0 and use context to manage query and connection timeouts.
|
||||
* `dial timeout` - in seconds (default is 15), set to 0 for no timeout
|
||||
* `encrypt`
|
||||
* `disable` - Data send between client and server is not encrypted.
|
||||
* `false` - Data sent between client and server is not encrypted beyond the login packet. (Default)
|
||||
* `true` - Data sent between client and server is encrypted.
|
||||
* `app name` - The application name (default is go-mssqldb)
|
||||
|
||||
### Connection parameters for ODBC and ADO style connection strings:
|
||||
|
||||
* `server` - host or host\instance (default localhost)
|
||||
* `port` - used only when there is no instance in server (default 1433)
|
||||
|
||||
### Less common parameters:
|
||||
|
||||
* `keepAlive` - in seconds; 0 to disable (default is 30)
|
||||
* `failoverpartner` - host or host\instance (default is no partner).
|
||||
* `failoverport` - used only when there is no instance in failoverpartner (default 1433)
|
||||
* `packet size` - in bytes; 512 to 32767 (default is 4096)
|
||||
* Encrypted connections have a maximum packet size of 16383 bytes
|
||||
* Further information on usage: https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-network-packet-size-server-configuration-option
|
||||
* `log` - logging flags (default 0/no logging, 63 for full logging)
|
||||
* 1 log errors
|
||||
* 2 log messages
|
||||
* 4 log rows affected
|
||||
* 8 trace sql statements
|
||||
* 16 log statement parameters
|
||||
* 32 log transaction begin/end
|
||||
* `TrustServerCertificate`
|
||||
* false - Server certificate is checked. Default is false if encypt is specified.
|
||||
* true - Server certificate is not checked. Default is true if encrypt is not specified. If trust server certificate is true, driver accepts any certificate presented by the server and any host name in that certificate. In this mode, TLS is susceptible to man-in-the-middle attacks. This should be used only for testing.
|
||||
* `certificate` - The file that contains the public key certificate of the CA that signed the SQL Server certificate. The specified certificate overrides the go platform specific CA certificates.
|
||||
* `hostNameInCertificate` - Specifies the Common Name (CN) in the server certificate. Default value is the server host.
|
||||
* `ServerSPN` - The kerberos SPN (Service Principal Name) for the server. Default is MSSQLSvc/host:port.
|
||||
* `Workstation ID` - The workstation name (default is the host name)
|
||||
* `ApplicationIntent` - Can be given the value `ReadOnly` to initiate a read-only connection to an Availability Group listener.
|
||||
|
||||
### The connection string can be specified in one of three formats:
|
||||
|
||||
|
||||
1. URL: with `sqlserver` scheme. username and password appears before the host. Any instance appears as
|
||||
the first segment in the path. All other options are query parameters. Examples:
|
||||
|
||||
* `sqlserver://username:password@host/instance?param1=value¶m2=value`
|
||||
* `sqlserver://username:password@host:port?param1=value¶m2=value`
|
||||
* `sqlserver://sa@localhost/SQLExpress?database=master&connection+timeout=30` // `SQLExpress instance.
|
||||
* `sqlserver://sa:mypass@localhost?database=master&connection+timeout=30` // username=sa, password=mypass.
|
||||
* `sqlserver://sa:mypass@localhost:1234?database=master&connection+timeout=30` // port 1234 on localhost.
|
||||
* `sqlserver://sa:my%7Bpass@somehost?connection+timeout=30` // password is "my{pass"
|
||||
|
||||
A string of this format can be constructed using the `URL` type in the `net/url` package.
|
||||
|
||||
```go
|
||||
query := url.Values{}
|
||||
query.Add("app name", "MyAppName")
|
||||
|
||||
u := &url.URL{
|
||||
Scheme: "sqlserver",
|
||||
User: url.UserPassword(username, password),
|
||||
Host: fmt.Sprintf("%s:%d", hostname, port),
|
||||
// Path: instance, // if connecting to an instance instead of a port
|
||||
RawQuery: query.Encode(),
|
||||
}
|
||||
db, err := sql.Open("sqlserver", u.String())
|
||||
```
|
||||
|
||||
2. ADO: `key=value` pairs separated by `;`. Values may not contain `;`, leading and trailing whitespace is ignored.
|
||||
Examples:
|
||||
|
||||
* `server=localhost\\SQLExpress;user id=sa;database=master;app name=MyAppName`
|
||||
* `server=localhost;user id=sa;database=master;app name=MyAppName`
|
||||
|
||||
3. ODBC: Prefix with `odbc`, `key=value` pairs separated by `;`. Allow `;` by wrapping
|
||||
values in `{}`. Examples:
|
||||
|
||||
* `odbc:server=localhost\\SQLExpress;user id=sa;database=master;app name=MyAppName`
|
||||
* `odbc:server=localhost;user id=sa;database=master;app name=MyAppName`
|
||||
* `odbc:server=localhost;user id=sa;password={foo;bar}` // Value marked with `{}`, password is "foo;bar"
|
||||
* `odbc:server=localhost;user id=sa;password={foo{bar}` // Value marked with `{}`, password is "foo{bar"
|
||||
* `odbc:server=localhost;user id=sa;password={foobar }` // Value marked with `{}`, password is "foobar "
|
||||
* `odbc:server=localhost;user id=sa;password=foo{bar` // Literal `{`, password is "foo{bar"
|
||||
* `odbc:server=localhost;user id=sa;password=foo}bar` // Literal `}`, password is "foo}bar"
|
||||
* `odbc:server=localhost;user id=sa;password={foo{bar}` // Literal `{`, password is "foo{bar"
|
||||
* `odbc:server=localhost;user id=sa;password={foo}}bar}` // Escaped `} with `}}`, password is "foo}bar"
|
||||
|
||||
## Executing Stored Procedures
|
||||
|
||||
To run a stored procedure, set the query text to the procedure name:
|
||||
```go
|
||||
var account = "abc"
|
||||
_, err := db.ExecContext(ctx, "sp_RunMe",
|
||||
sql.Named("ID", 123),
|
||||
sql.Named("Account", sql.Out{Dest: &account}),
|
||||
)
|
||||
```
|
||||
|
||||
## Caveat for local temporary tables
|
||||
|
||||
Due to protocol limitations, temporary tables will only be allocated on the connection
|
||||
as a result of executing a query with zero parameters. The following query
|
||||
will, due to the use of a parameter, execute in its own session,
|
||||
and `#mytemp` will be de-allocated right away:
|
||||
|
||||
```go
|
||||
conn, err := pool.Conn(ctx)
|
||||
defer conn.Close()
|
||||
_, err := conn.ExecContext(ctx, "select @p1 as x into #mytemp", 1)
|
||||
// at this point #mytemp is already dropped again as the session of the ExecContext is over
|
||||
```
|
||||
|
||||
To work around this, always explicitly create the local temporary
|
||||
table in a query without any parameters. As a special case, the driver
|
||||
will then be able to execute the query directly on the
|
||||
connection-scoped session. The following example works:
|
||||
|
||||
```go
|
||||
conn, err := pool.Conn(ctx)
|
||||
|
||||
// Set us up so that temp table is always cleaned up, since conn.Close()
|
||||
// merely returns conn to pool, rather than actually closing the connection.
|
||||
defer func() {
|
||||
_, _ = conn.ExecContext(ctx, "drop table #mytemp") // always clean up
|
||||
conn.Close() // merely returns conn to pool
|
||||
}()
|
||||
|
||||
|
||||
// Since we not pass any parameters below, the query will execute on the scope of
|
||||
// the connection and succeed in creating the table.
|
||||
_, err := conn.ExecContext(ctx, "create table #mytemp ( x int )")
|
||||
|
||||
// #mytemp is now available even if you pass parameters
|
||||
_, err := conn.ExecContext(ctx, "insert into #mytemp (x) values (@p1)", 1)
|
||||
|
||||
```
|
||||
|
||||
## Return Status
|
||||
|
||||
To get the procedure return status, pass into the parameters a
|
||||
`*mssql.ReturnStatus`. For example:
|
||||
```
|
||||
var rs mssql.ReturnStatus
|
||||
_, err := db.ExecContext(ctx, "theproc", &rs)
|
||||
log.Printf("status=%d", rs)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
The `sqlserver` driver uses normal MS SQL Server syntax and expects parameters in
|
||||
the sql query to be in the form of either `@Name` or `@p1` to `@pN` (ordinal position).
|
||||
|
||||
```go
|
||||
db.QueryContext(ctx, `select * from t where ID = @ID and Name = @p2;`, sql.Named("ID", 6), "Bob")
|
||||
```
|
||||
|
||||
### Parameter Types
|
||||
|
||||
To pass specific types to the query parameters, say `varchar` or `date` types,
|
||||
you must convert the types to the type before passing in. The following types
|
||||
are supported:
|
||||
|
||||
* string -> nvarchar
|
||||
* mssql.VarChar -> varchar
|
||||
* time.Time -> datetimeoffset or datetime (TDS version dependent)
|
||||
* mssql.DateTime1 -> datetime
|
||||
* mssql.DateTimeOffset -> datetimeoffset
|
||||
* "cloud.google.com/go/civil".Date -> date
|
||||
* "cloud.google.com/go/civil".DateTime -> datetime2
|
||||
* "cloud.google.com/go/civil".Time -> time
|
||||
* mssql.TVPType -> Table Value Parameter (TDS version dependent)
|
||||
|
||||
## Important Notes
|
||||
|
||||
* [LastInsertId](https://golang.org/pkg/database/sql/#Result.LastInsertId) should
|
||||
not be used with this driver (or SQL Server) due to how the TDS protocol
|
||||
works. Please use the [OUTPUT Clause](https://docs.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql)
|
||||
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/denisenkom/go-mssqldb#NewConnector)
|
||||
may be used with [OpenDB](https://golang.org/pkg/database/sql/#OpenDB).
|
||||
* [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+.
|
||||
|
||||
## Features
|
||||
|
||||
* Can be used with SQL Server 2005 or newer
|
||||
* Can be used with Microsoft Azure SQL Database
|
||||
* Can be used on all go supported platforms (e.g. Linux, Mac OS X and Windows)
|
||||
* Supports new date/time types: date, time, datetime2, datetimeoffset
|
||||
* Supports string parameters longer than 8000 characters
|
||||
* Supports encryption using SSL/TLS
|
||||
* Supports SQL Server and Windows Authentication
|
||||
* Supports Single-Sign-On on Windows
|
||||
* Supports connections to AlwaysOn Availability Group listeners, including re-direction to read-only replicas.
|
||||
* Supports query notifications
|
||||
|
||||
## Tests
|
||||
|
||||
`go test` is used for testing. A running instance of MSSQL server is required.
|
||||
Environment variables are used to pass login information.
|
||||
|
||||
Example:
|
||||
|
||||
env SQLSERVER_DSN=sqlserver://user:pass@hostname/instance?database=test1 go test
|
||||
|
||||
## Deprecated
|
||||
|
||||
These features still exist in the driver, but they are are deprecated.
|
||||
|
||||
### Query Parameter Token Replace (driver "mssql")
|
||||
|
||||
If you use the driver name "mssql" (rather then "sqlserver") the SQL text
|
||||
will be loosly parsed and an attempt to extract identifiers using one of
|
||||
|
||||
* ?
|
||||
* ?nnn
|
||||
* :nnn
|
||||
* $nnn
|
||||
|
||||
will be used. This is not recommended with SQL Server.
|
||||
There is at least one existing `won't fix` issue with the query parsing.
|
||||
|
||||
Use the native "@Name" parameters instead with the "sqlserver" driver name.
|
||||
|
||||
## Known Issues
|
||||
|
||||
* SQL Server 2008 and 2008 R2 engine cannot handle login records when SSL encryption is not disabled.
|
||||
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: http://support.microsoft.com/kb/2653857
|
48
vendor/github.com/denisenkom/go-mssqldb/appveyor.yml
generated
vendored
Normal file
48
vendor/github.com/denisenkom/go-mssqldb/appveyor.yml
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
version: 1.0.{build}
|
||||
|
||||
os: Windows Server 2012 R2
|
||||
|
||||
clone_folder: c:\gopath\src\github.com\denisenkom\go-mssqldb
|
||||
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
HOST: localhost
|
||||
SQLUSER: sa
|
||||
SQLPASSWORD: Password12!
|
||||
DATABASE: test
|
||||
GOVERSION: 110
|
||||
matrix:
|
||||
- GOVERSION: 18
|
||||
SQLINSTANCE: SQL2016
|
||||
- GOVERSION: 19
|
||||
SQLINSTANCE: SQL2016
|
||||
- GOVERSION: 110
|
||||
SQLINSTANCE: SQL2016
|
||||
- SQLINSTANCE: SQL2014
|
||||
- SQLINSTANCE: SQL2012SP1
|
||||
- SQLINSTANCE: SQL2008R2SP2
|
||||
|
||||
install:
|
||||
- set GOROOT=c:\go%GOVERSION%
|
||||
- set PATH=%GOPATH%\bin;%GOROOT%\bin;%PATH%
|
||||
- go version
|
||||
- go env
|
||||
- go get -u cloud.google.com/go/civil
|
||||
|
||||
build_script:
|
||||
- go build
|
||||
|
||||
before_test:
|
||||
# setup SQL Server
|
||||
- ps: |
|
||||
$instanceName = $env:SQLINSTANCE
|
||||
Start-Service "MSSQL`$$instanceName"
|
||||
Start-Service "SQLBrowser"
|
||||
- sqlcmd -S "(local)\%SQLINSTANCE%" -Q "Use [master]; CREATE DATABASE test;"
|
||||
- sqlcmd -S "(local)\%SQLINSTANCE%" -h -1 -Q "set nocount on; Select @@version"
|
||||
- pip install codecov
|
||||
|
||||
|
||||
test_script:
|
||||
- go test -race -cpu 4 -coverprofile=coverage.txt -covermode=atomic
|
||||
- codecov -f coverage.txt
|
258
vendor/github.com/denisenkom/go-mssqldb/buf.go
generated
vendored
Normal file
258
vendor/github.com/denisenkom/go-mssqldb/buf.go
generated
vendored
Normal file
|
@ -0,0 +1,258 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"io"
|
||||
)
|
||||
|
||||
type packetType uint8
|
||||
|
||||
type header struct {
|
||||
PacketType packetType
|
||||
Status uint8
|
||||
Size uint16
|
||||
Spid uint16
|
||||
PacketNo uint8
|
||||
Pad uint8
|
||||
}
|
||||
|
||||
// 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
|
||||
// reads, not writes.
|
||||
type tdsBuffer struct {
|
||||
transport io.ReadWriteCloser
|
||||
|
||||
packetSize int
|
||||
|
||||
// Write fields.
|
||||
wbuf []byte
|
||||
wpos int
|
||||
wPacketSeq byte
|
||||
wPacketType packetType
|
||||
|
||||
// Read fields.
|
||||
rbuf []byte
|
||||
rpos int
|
||||
rsize int
|
||||
final bool
|
||||
rPacketType packetType
|
||||
|
||||
// afterFirst is assigned to right after tdsBuffer is created and
|
||||
// before the first use. It is executed after the first packet is
|
||||
// written and then removed.
|
||||
afterFirst func()
|
||||
}
|
||||
|
||||
func newTdsBuffer(bufsize uint16, transport io.ReadWriteCloser) *tdsBuffer {
|
||||
return &tdsBuffer{
|
||||
packetSize: int(bufsize),
|
||||
wbuf: make([]byte, 1<<16),
|
||||
rbuf: make([]byte, 1<<16),
|
||||
rpos: 8,
|
||||
transport: transport,
|
||||
}
|
||||
}
|
||||
|
||||
func (rw *tdsBuffer) ResizeBuffer(packetSize int) {
|
||||
rw.packetSize = packetSize
|
||||
}
|
||||
|
||||
func (w *tdsBuffer) PackageSize() int {
|
||||
return w.packetSize
|
||||
}
|
||||
|
||||
func (w *tdsBuffer) flush() (err error) {
|
||||
// Write packet size.
|
||||
w.wbuf[0] = byte(w.wPacketType)
|
||||
binary.BigEndian.PutUint16(w.wbuf[2:], uint16(w.wpos))
|
||||
w.wbuf[6] = w.wPacketSeq
|
||||
|
||||
// Write packet into underlying transport.
|
||||
if _, err = w.transport.Write(w.wbuf[:w.wpos]); err != nil {
|
||||
return err
|
||||
}
|
||||
// It is possible to create a whole new buffer after a flush.
|
||||
// Useful for debugging. Normally reuse the buffer.
|
||||
// w.wbuf = make([]byte, 1<<16)
|
||||
|
||||
// Execute afterFirst hook if it is set.
|
||||
if w.afterFirst != nil {
|
||||
w.afterFirst()
|
||||
w.afterFirst = nil
|
||||
}
|
||||
|
||||
w.wpos = 8
|
||||
w.wPacketSeq++
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *tdsBuffer) Write(p []byte) (total int, err error) {
|
||||
for {
|
||||
copied := copy(w.wbuf[w.wpos:w.packetSize], p)
|
||||
w.wpos += copied
|
||||
total += copied
|
||||
if copied == len(p) {
|
||||
return
|
||||
}
|
||||
if err = w.flush(); err != nil {
|
||||
return
|
||||
}
|
||||
p = p[copied:]
|
||||
}
|
||||
}
|
||||
|
||||
func (w *tdsBuffer) WriteByte(b byte) error {
|
||||
if int(w.wpos) == len(w.wbuf) || w.wpos == w.packetSize {
|
||||
if err := w.flush(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
w.wbuf[w.wpos] = b
|
||||
w.wpos += 1
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *tdsBuffer) BeginPacket(packetType packetType, resetSession bool) {
|
||||
status := byte(0)
|
||||
if resetSession {
|
||||
switch packetType {
|
||||
// Reset session can only be set on the following packet types.
|
||||
case packSQLBatch, packRPCRequest, packTransMgrReq:
|
||||
status = 0x8
|
||||
}
|
||||
}
|
||||
w.wbuf[1] = status // Packet is incomplete. This byte is set again in FinishPacket.
|
||||
w.wpos = 8
|
||||
w.wPacketSeq = 1
|
||||
w.wPacketType = packetType
|
||||
}
|
||||
|
||||
func (w *tdsBuffer) FinishPacket() error {
|
||||
w.wbuf[1] |= 1 // Mark this as the last packet in the message.
|
||||
return w.flush()
|
||||
}
|
||||
|
||||
var headerSize = binary.Size(header{})
|
||||
|
||||
func (r *tdsBuffer) readNextPacket() error {
|
||||
h := header{}
|
||||
var err error
|
||||
err = binary.Read(r.transport, binary.BigEndian, &h)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if int(h.Size) > r.packetSize {
|
||||
return errors.New("Invalid packet size, it is longer than buffer size")
|
||||
}
|
||||
if headerSize > int(h.Size) {
|
||||
return errors.New("Invalid packet size, it is shorter than header size")
|
||||
}
|
||||
_, err = io.ReadFull(r.transport, r.rbuf[headerSize:h.Size])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.rpos = headerSize
|
||||
r.rsize = int(h.Size)
|
||||
r.final = h.Status != 0
|
||||
r.rPacketType = h.PacketType
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) BeginRead() (packetType, error) {
|
||||
err := r.readNextPacket()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return r.rPacketType, nil
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) ReadByte() (res byte, err error) {
|
||||
if r.rpos == r.rsize {
|
||||
if r.final {
|
||||
return 0, io.EOF
|
||||
}
|
||||
err = r.readNextPacket()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
res = r.rbuf[r.rpos]
|
||||
r.rpos++
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) byte() byte {
|
||||
b, err := r.ReadByte()
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) ReadFull(buf []byte) {
|
||||
_, err := io.ReadFull(r, buf[:])
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) uint64() uint64 {
|
||||
var buf [8]byte
|
||||
r.ReadFull(buf[:])
|
||||
return binary.LittleEndian.Uint64(buf[:])
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) int32() int32 {
|
||||
return int32(r.uint32())
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) uint32() uint32 {
|
||||
var buf [4]byte
|
||||
r.ReadFull(buf[:])
|
||||
return binary.LittleEndian.Uint32(buf[:])
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) uint16() uint16 {
|
||||
var buf [2]byte
|
||||
r.ReadFull(buf[:])
|
||||
return binary.LittleEndian.Uint16(buf[:])
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) BVarChar() string {
|
||||
l := int(r.byte())
|
||||
return r.readUcs2(l)
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) UsVarChar() string {
|
||||
l := int(r.uint16())
|
||||
return r.readUcs2(l)
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) readUcs2(numchars int) string {
|
||||
b := make([]byte, numchars*2)
|
||||
r.ReadFull(b)
|
||||
res, err := ucs22str(b)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func (r *tdsBuffer) Read(buf []byte) (copied int, err error) {
|
||||
copied = 0
|
||||
err = nil
|
||||
if r.rpos == r.rsize {
|
||||
if r.final {
|
||||
return 0, io.EOF
|
||||
}
|
||||
err = r.readNextPacket()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
copied = copy(buf, r.rbuf[r.rpos:r.rsize])
|
||||
r.rpos += copied
|
||||
return
|
||||
}
|
554
vendor/github.com/denisenkom/go-mssqldb/bulkcopy.go
generated
vendored
Normal file
554
vendor/github.com/denisenkom/go-mssqldb/bulkcopy.go
generated
vendored
Normal file
|
@ -0,0 +1,554 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Bulk struct {
|
||||
// ctx is used only for AddRow and Done methods.
|
||||
// This could be removed if AddRow and Done accepted
|
||||
// a ctx field as well, which is available with the
|
||||
// database/sql call.
|
||||
ctx context.Context
|
||||
|
||||
cn *Conn
|
||||
metadata []columnStruct
|
||||
bulkColumns []columnStruct
|
||||
columnsName []string
|
||||
tablename string
|
||||
numRows int
|
||||
|
||||
headerSent bool
|
||||
Options BulkOptions
|
||||
Debug bool
|
||||
}
|
||||
type BulkOptions struct {
|
||||
CheckConstraints bool
|
||||
FireTriggers bool
|
||||
KeepNulls bool
|
||||
KilobytesPerBatch int
|
||||
RowsPerBatch int
|
||||
Order []string
|
||||
Tablock bool
|
||||
}
|
||||
|
||||
type DataValue interface{}
|
||||
|
||||
func (cn *Conn) CreateBulk(table string, columns []string) (_ *Bulk) {
|
||||
b := Bulk{ctx: context.Background(), cn: cn, tablename: table, headerSent: false, columnsName: columns}
|
||||
b.Debug = false
|
||||
return &b
|
||||
}
|
||||
|
||||
func (cn *Conn) CreateBulkContext(ctx context.Context, table string, columns []string) (_ *Bulk) {
|
||||
b := Bulk{ctx: ctx, cn: cn, tablename: table, headerSent: false, columnsName: columns}
|
||||
b.Debug = false
|
||||
return &b
|
||||
}
|
||||
|
||||
func (b *Bulk) sendBulkCommand(ctx context.Context) (err error) {
|
||||
//get table columns info
|
||||
err = b.getMetadata(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//match the columns
|
||||
for _, colname := range b.columnsName {
|
||||
var bulkCol *columnStruct
|
||||
|
||||
for _, m := range b.metadata {
|
||||
if m.ColName == colname {
|
||||
bulkCol = &m
|
||||
break
|
||||
}
|
||||
}
|
||||
if bulkCol != nil {
|
||||
|
||||
if bulkCol.ti.TypeId == typeUdt {
|
||||
//send udt as binary
|
||||
bulkCol.ti.TypeId = typeBigVarBin
|
||||
}
|
||||
b.bulkColumns = append(b.bulkColumns, *bulkCol)
|
||||
b.dlogf("Adding column %s %s %#x", colname, bulkCol.ColName, bulkCol.ti.TypeId)
|
||||
} else {
|
||||
return fmt.Errorf("Column %s does not exist in destination table %s", colname, b.tablename)
|
||||
}
|
||||
}
|
||||
|
||||
//create the bulk command
|
||||
|
||||
//columns definitions
|
||||
var col_defs bytes.Buffer
|
||||
for i, col := range b.bulkColumns {
|
||||
if i != 0 {
|
||||
col_defs.WriteString(", ")
|
||||
}
|
||||
col_defs.WriteString("[" + col.ColName + "] " + makeDecl(col.ti))
|
||||
}
|
||||
|
||||
//options
|
||||
var with_opts []string
|
||||
|
||||
if b.Options.CheckConstraints {
|
||||
with_opts = append(with_opts, "CHECK_CONSTRAINTS")
|
||||
}
|
||||
if b.Options.FireTriggers {
|
||||
with_opts = append(with_opts, "FIRE_TRIGGERS")
|
||||
}
|
||||
if b.Options.KeepNulls {
|
||||
with_opts = append(with_opts, "KEEP_NULLS")
|
||||
}
|
||||
if b.Options.KilobytesPerBatch > 0 {
|
||||
with_opts = append(with_opts, fmt.Sprintf("KILOBYTES_PER_BATCH = %d", b.Options.KilobytesPerBatch))
|
||||
}
|
||||
if b.Options.RowsPerBatch > 0 {
|
||||
with_opts = append(with_opts, fmt.Sprintf("ROWS_PER_BATCH = %d", b.Options.RowsPerBatch))
|
||||
}
|
||||
if len(b.Options.Order) > 0 {
|
||||
with_opts = append(with_opts, fmt.Sprintf("ORDER(%s)", strings.Join(b.Options.Order, ",")))
|
||||
}
|
||||
if b.Options.Tablock {
|
||||
with_opts = append(with_opts, "TABLOCK")
|
||||
}
|
||||
var with_part string
|
||||
if len(with_opts) > 0 {
|
||||
with_part = fmt.Sprintf("WITH (%s)", strings.Join(with_opts, ","))
|
||||
}
|
||||
|
||||
query := fmt.Sprintf("INSERT BULK %s (%s) %s", b.tablename, col_defs.String(), with_part)
|
||||
|
||||
stmt, err := b.cn.PrepareContext(ctx, query)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Prepare failed: %s", err.Error())
|
||||
}
|
||||
b.dlogf(query)
|
||||
|
||||
_, err = stmt.(*Stmt).ExecContext(ctx, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b.headerSent = true
|
||||
|
||||
var buf = b.cn.sess.buf
|
||||
buf.BeginPacket(packBulkLoadBCP, false)
|
||||
|
||||
// Send the columns metadata.
|
||||
columnMetadata := b.createColMetadata()
|
||||
_, err = buf.Write(columnMetadata)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AddRow immediately writes the row to the destination table.
|
||||
// The arguments are the row values in the order they were specified.
|
||||
func (b *Bulk) AddRow(row []interface{}) (err error) {
|
||||
if !b.headerSent {
|
||||
err = b.sendBulkCommand(b.ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if len(row) != len(b.bulkColumns) {
|
||||
return fmt.Errorf("Row does not have the same number of columns than the destination table %d %d",
|
||||
len(row), len(b.bulkColumns))
|
||||
}
|
||||
|
||||
bytes, err := b.makeRowData(row)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = b.cn.sess.buf.Write(bytes)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
b.numRows = b.numRows + 1
|
||||
return
|
||||
}
|
||||
|
||||
func (b *Bulk) makeRowData(row []interface{}) ([]byte, error) {
|
||||
buf := new(bytes.Buffer)
|
||||
buf.WriteByte(byte(tokenRow))
|
||||
|
||||
var logcol bytes.Buffer
|
||||
for i, col := range b.bulkColumns {
|
||||
|
||||
if b.Debug {
|
||||
logcol.WriteString(fmt.Sprintf(" col[%d]='%v' ", i, row[i]))
|
||||
}
|
||||
param, err := b.makeParam(row[i], col)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("bulkcopy: %s", err.Error())
|
||||
}
|
||||
|
||||
if col.ti.Writer == nil {
|
||||
return nil, fmt.Errorf("no writer for column: %s, TypeId: %#x",
|
||||
col.ColName, col.ti.TypeId)
|
||||
}
|
||||
err = col.ti.Writer(buf, param.ti, param.buffer)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("bulkcopy: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
b.dlogf("row[%d] %s\n", b.numRows, logcol.String())
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func (b *Bulk) Done() (rowcount int64, err error) {
|
||||
if b.headerSent == false {
|
||||
//no rows had been sent
|
||||
return 0, nil
|
||||
}
|
||||
var buf = b.cn.sess.buf
|
||||
buf.WriteByte(byte(tokenDone))
|
||||
|
||||
binary.Write(buf, binary.LittleEndian, uint16(doneFinal))
|
||||
binary.Write(buf, binary.LittleEndian, uint16(0)) // curcmd
|
||||
|
||||
if b.cn.sess.loginAck.TDSVersion >= verTDS72 {
|
||||
binary.Write(buf, binary.LittleEndian, uint64(0)) //rowcount 0
|
||||
} else {
|
||||
binary.Write(buf, binary.LittleEndian, uint32(0)) //rowcount 0
|
||||
}
|
||||
|
||||
buf.FinishPacket()
|
||||
|
||||
tokchan := make(chan tokenStruct, 5)
|
||||
go processResponse(b.ctx, b.cn.sess, tokchan, nil)
|
||||
|
||||
var rowCount int64
|
||||
for token := range tokchan {
|
||||
switch token := token.(type) {
|
||||
case doneStruct:
|
||||
if token.Status&doneCount != 0 {
|
||||
rowCount = int64(token.RowCount)
|
||||
}
|
||||
if token.isError() {
|
||||
return 0, token.getError()
|
||||
}
|
||||
case error:
|
||||
return 0, b.cn.checkBadConn(token)
|
||||
}
|
||||
}
|
||||
return rowCount, nil
|
||||
}
|
||||
|
||||
func (b *Bulk) createColMetadata() []byte {
|
||||
buf := new(bytes.Buffer)
|
||||
buf.WriteByte(byte(tokenColMetadata)) // token
|
||||
binary.Write(buf, binary.LittleEndian, uint16(len(b.bulkColumns))) // column count
|
||||
|
||||
for i, col := range b.bulkColumns {
|
||||
|
||||
if b.cn.sess.loginAck.TDSVersion >= verTDS72 {
|
||||
binary.Write(buf, binary.LittleEndian, uint32(col.UserType)) // usertype, always 0?
|
||||
} else {
|
||||
binary.Write(buf, binary.LittleEndian, uint16(col.UserType))
|
||||
}
|
||||
binary.Write(buf, binary.LittleEndian, uint16(col.Flags))
|
||||
|
||||
writeTypeInfo(buf, &b.bulkColumns[i].ti)
|
||||
|
||||
if col.ti.TypeId == typeNText ||
|
||||
col.ti.TypeId == typeText ||
|
||||
col.ti.TypeId == typeImage {
|
||||
|
||||
tablename_ucs2 := str2ucs2(b.tablename)
|
||||
binary.Write(buf, binary.LittleEndian, uint16(len(tablename_ucs2)/2))
|
||||
buf.Write(tablename_ucs2)
|
||||
}
|
||||
colname_ucs2 := str2ucs2(col.ColName)
|
||||
buf.WriteByte(uint8(len(colname_ucs2) / 2))
|
||||
buf.Write(colname_ucs2)
|
||||
}
|
||||
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
func (b *Bulk) getMetadata(ctx context.Context) (err error) {
|
||||
stmt, err := b.cn.prepareContext(ctx, "SET FMTONLY ON")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.ExecContext(ctx, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Get columns info.
|
||||
stmt, err = b.cn.prepareContext(ctx, fmt.Sprintf("select * from %s SET FMTONLY OFF", b.tablename))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
rows, err := stmt.QueryContext(ctx, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("get columns info failed: %v", err)
|
||||
}
|
||||
b.metadata = rows.(*Rows).cols
|
||||
|
||||
if b.Debug {
|
||||
for _, col := range b.metadata {
|
||||
b.dlogf("col: %s typeId: %#x size: %d scale: %d prec: %d flags: %d lcid: %#x\n",
|
||||
col.ColName, col.ti.TypeId, col.ti.Size, col.ti.Scale, col.ti.Prec,
|
||||
col.Flags, col.ti.Collation.LcidAndFlags)
|
||||
}
|
||||
}
|
||||
|
||||
return rows.Close()
|
||||
}
|
||||
|
||||
func (b *Bulk) makeParam(val DataValue, col columnStruct) (res param, err error) {
|
||||
res.ti.Size = col.ti.Size
|
||||
res.ti.TypeId = col.ti.TypeId
|
||||
|
||||
if val == nil {
|
||||
res.ti.Size = 0
|
||||
return
|
||||
}
|
||||
|
||||
switch col.ti.TypeId {
|
||||
|
||||
case typeInt1, typeInt2, typeInt4, typeInt8, typeIntN:
|
||||
var intvalue int64
|
||||
|
||||
switch val := val.(type) {
|
||||
case int:
|
||||
intvalue = int64(val)
|
||||
case int32:
|
||||
intvalue = int64(val)
|
||||
case int64:
|
||||
intvalue = val
|
||||
default:
|
||||
err = fmt.Errorf("mssql: invalid type for int column")
|
||||
return
|
||||
}
|
||||
|
||||
res.buffer = make([]byte, res.ti.Size)
|
||||
if col.ti.Size == 1 {
|
||||
res.buffer[0] = byte(intvalue)
|
||||
} else if col.ti.Size == 2 {
|
||||
binary.LittleEndian.PutUint16(res.buffer, uint16(intvalue))
|
||||
} else if col.ti.Size == 4 {
|
||||
binary.LittleEndian.PutUint32(res.buffer, uint32(intvalue))
|
||||
} else if col.ti.Size == 8 {
|
||||
binary.LittleEndian.PutUint64(res.buffer, uint64(intvalue))
|
||||
}
|
||||
case typeFlt4, typeFlt8, typeFltN:
|
||||
var floatvalue float64
|
||||
|
||||
switch val := val.(type) {
|
||||
case float32:
|
||||
floatvalue = float64(val)
|
||||
case float64:
|
||||
floatvalue = val
|
||||
case int:
|
||||
floatvalue = float64(val)
|
||||
case int64:
|
||||
floatvalue = float64(val)
|
||||
default:
|
||||
err = fmt.Errorf("mssql: invalid type for float column: %s", val)
|
||||
return
|
||||
}
|
||||
|
||||
if col.ti.Size == 4 {
|
||||
res.buffer = make([]byte, 4)
|
||||
binary.LittleEndian.PutUint32(res.buffer, math.Float32bits(float32(floatvalue)))
|
||||
} else if col.ti.Size == 8 {
|
||||
res.buffer = make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(res.buffer, math.Float64bits(floatvalue))
|
||||
}
|
||||
case typeNVarChar, typeNText, typeNChar:
|
||||
|
||||
switch val := val.(type) {
|
||||
case string:
|
||||
res.buffer = str2ucs2(val)
|
||||
case []byte:
|
||||
res.buffer = val
|
||||
default:
|
||||
err = fmt.Errorf("mssql: invalid type for nvarchar column: %s", val)
|
||||
return
|
||||
}
|
||||
res.ti.Size = len(res.buffer)
|
||||
|
||||
case typeVarChar, typeBigVarChar, typeText, typeChar, typeBigChar:
|
||||
switch val := val.(type) {
|
||||
case string:
|
||||
res.buffer = []byte(val)
|
||||
case []byte:
|
||||
res.buffer = val
|
||||
default:
|
||||
err = fmt.Errorf("mssql: invalid type for varchar column: %s", val)
|
||||
return
|
||||
}
|
||||
res.ti.Size = len(res.buffer)
|
||||
|
||||
case typeBit, typeBitN:
|
||||
if reflect.TypeOf(val).Kind() != reflect.Bool {
|
||||
err = fmt.Errorf("mssql: invalid type for bit column: %s", val)
|
||||
return
|
||||
}
|
||||
res.ti.TypeId = typeBitN
|
||||
res.ti.Size = 1
|
||||
res.buffer = make([]byte, 1)
|
||||
if val.(bool) {
|
||||
res.buffer[0] = 1
|
||||
}
|
||||
case typeDateTime2N:
|
||||
switch val := val.(type) {
|
||||
case time.Time:
|
||||
res.buffer = encodeDateTime2(val, int(col.ti.Scale))
|
||||
res.ti.Size = len(res.buffer)
|
||||
default:
|
||||
err = fmt.Errorf("mssql: invalid type for datetime2 column: %s", val)
|
||||
return
|
||||
}
|
||||
case typeDateTimeOffsetN:
|
||||
switch val := val.(type) {
|
||||
case time.Time:
|
||||
res.buffer = encodeDateTimeOffset(val, int(res.ti.Scale))
|
||||
res.ti.Size = len(res.buffer)
|
||||
|
||||
default:
|
||||
err = fmt.Errorf("mssql: invalid type for datetimeoffset column: %s", val)
|
||||
return
|
||||
}
|
||||
case typeDateN:
|
||||
switch val := val.(type) {
|
||||
case time.Time:
|
||||
res.buffer = encodeDate(val)
|
||||
res.ti.Size = len(res.buffer)
|
||||
default:
|
||||
err = fmt.Errorf("mssql: invalid type for date column: %s", val)
|
||||
return
|
||||
}
|
||||
case typeDateTime, typeDateTimeN, typeDateTim4:
|
||||
switch val := val.(type) {
|
||||
case time.Time:
|
||||
if col.ti.Size == 4 {
|
||||
res.buffer = encodeDateTim4(val)
|
||||
res.ti.Size = len(res.buffer)
|
||||
} else if col.ti.Size == 8 {
|
||||
res.buffer = encodeDateTime(val)
|
||||
res.ti.Size = len(res.buffer)
|
||||
} else {
|
||||
err = fmt.Errorf("mssql: invalid size of column")
|
||||
}
|
||||
|
||||
default:
|
||||
err = fmt.Errorf("mssql: invalid type for datetime column: %s", val)
|
||||
}
|
||||
|
||||
// case typeMoney, typeMoney4, typeMoneyN:
|
||||
case typeDecimal, typeDecimalN, typeNumeric, typeNumericN:
|
||||
var value float64
|
||||
switch v := val.(type) {
|
||||
case int:
|
||||
value = float64(v)
|
||||
case int8:
|
||||
value = float64(v)
|
||||
case int16:
|
||||
value = float64(v)
|
||||
case int32:
|
||||
value = float64(v)
|
||||
case int64:
|
||||
value = float64(v)
|
||||
case float32:
|
||||
value = float64(v)
|
||||
case float64:
|
||||
value = v
|
||||
case string:
|
||||
if value, err = strconv.ParseFloat(v, 64); err != nil {
|
||||
return res, fmt.Errorf("bulk: unable to convert string to float: %v", err)
|
||||
}
|
||||
default:
|
||||
return res, fmt.Errorf("unknown value for decimal: %#v", v)
|
||||
}
|
||||
|
||||
perc := col.ti.Prec
|
||||
scale := col.ti.Scale
|
||||
var dec Decimal
|
||||
dec, err = Float64ToDecimalScale(value, scale)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
dec.prec = perc
|
||||
|
||||
var length byte
|
||||
switch {
|
||||
case perc <= 9:
|
||||
length = 4
|
||||
case perc <= 19:
|
||||
length = 8
|
||||
case perc <= 28:
|
||||
length = 12
|
||||
default:
|
||||
length = 16
|
||||
}
|
||||
|
||||
buf := make([]byte, length+1)
|
||||
// first byte length written by typeInfo.writer
|
||||
res.ti.Size = int(length) + 1
|
||||
// second byte sign
|
||||
if value < 0 {
|
||||
buf[0] = 0
|
||||
} else {
|
||||
buf[0] = 1
|
||||
}
|
||||
|
||||
ub := dec.UnscaledBytes()
|
||||
l := len(ub)
|
||||
if l > int(length) {
|
||||
err = fmt.Errorf("decimal out of range: %s", dec)
|
||||
return res, err
|
||||
}
|
||||
// reverse the bytes
|
||||
for i, j := 1, l-1; j >= 0; i, j = i+1, j-1 {
|
||||
buf[i] = ub[j]
|
||||
}
|
||||
res.buffer = buf
|
||||
case typeBigVarBin, typeBigBinary:
|
||||
switch val := val.(type) {
|
||||
case []byte:
|
||||
res.ti.Size = len(val)
|
||||
res.buffer = val
|
||||
default:
|
||||
err = fmt.Errorf("mssql: invalid type for Binary column: %s", val)
|
||||
return
|
||||
}
|
||||
case typeGuid:
|
||||
switch val := val.(type) {
|
||||
case []byte:
|
||||
res.ti.Size = len(val)
|
||||
res.buffer = val
|
||||
default:
|
||||
err = fmt.Errorf("mssql: invalid type for Guid column: %s", val)
|
||||
return
|
||||
}
|
||||
|
||||
default:
|
||||
err = fmt.Errorf("mssql: type %x not implemented", col.ti.TypeId)
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func (b *Bulk) dlogf(format string, v ...interface{}) {
|
||||
if b.Debug {
|
||||
b.cn.sess.log.Printf(format, v...)
|
||||
}
|
||||
}
|
93
vendor/github.com/denisenkom/go-mssqldb/bulkcopy_sql.go
generated
vendored
Normal file
93
vendor/github.com/denisenkom/go-mssqldb/bulkcopy_sql.go
generated
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type copyin struct {
|
||||
cn *Conn
|
||||
bulkcopy *Bulk
|
||||
closed bool
|
||||
}
|
||||
|
||||
type serializableBulkConfig struct {
|
||||
TableName string
|
||||
ColumnsName []string
|
||||
Options BulkOptions
|
||||
}
|
||||
|
||||
func (d *Driver) OpenConnection(dsn string) (*Conn, error) {
|
||||
return d.open(context.Background(), dsn)
|
||||
}
|
||||
|
||||
func (c *Conn) prepareCopyIn(ctx context.Context, query string) (_ driver.Stmt, err error) {
|
||||
config_json := query[11:]
|
||||
|
||||
bulkconfig := serializableBulkConfig{}
|
||||
err = json.Unmarshal([]byte(config_json), &bulkconfig)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
bulkcopy := c.CreateBulkContext(ctx, bulkconfig.TableName, bulkconfig.ColumnsName)
|
||||
bulkcopy.Options = bulkconfig.Options
|
||||
|
||||
ci := ©in{
|
||||
cn: c,
|
||||
bulkcopy: bulkcopy,
|
||||
}
|
||||
|
||||
return ci, nil
|
||||
}
|
||||
|
||||
func CopyIn(table string, options BulkOptions, columns ...string) string {
|
||||
bulkconfig := &serializableBulkConfig{TableName: table, Options: options, ColumnsName: columns}
|
||||
|
||||
config_json, err := json.Marshal(bulkconfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
stmt := "INSERTBULK " + string(config_json)
|
||||
|
||||
return stmt
|
||||
}
|
||||
|
||||
func (ci *copyin) NumInput() int {
|
||||
return -1
|
||||
}
|
||||
|
||||
func (ci *copyin) Query(v []driver.Value) (r driver.Rows, err error) {
|
||||
panic("should never be called")
|
||||
}
|
||||
|
||||
func (ci *copyin) Exec(v []driver.Value) (r driver.Result, err error) {
|
||||
if ci.closed {
|
||||
return nil, errors.New("copyin query is closed")
|
||||
}
|
||||
|
||||
if len(v) == 0 {
|
||||
rowCount, err := ci.bulkcopy.Done()
|
||||
ci.closed = true
|
||||
return driver.RowsAffected(rowCount), err
|
||||
}
|
||||
|
||||
t := make([]interface{}, len(v))
|
||||
for i, val := range v {
|
||||
t[i] = val
|
||||
}
|
||||
|
||||
err = ci.bulkcopy.AddRow(t)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return driver.RowsAffected(0), nil
|
||||
}
|
||||
|
||||
func (ci *copyin) Close() (err error) {
|
||||
return nil
|
||||
}
|
306
vendor/github.com/denisenkom/go-mssqldb/convert.go
generated
vendored
Normal file
306
vendor/github.com/denisenkom/go-mssqldb/convert.go
generated
vendored
Normal file
|
@ -0,0 +1,306 @@
|
|||
package mssql
|
||||
|
||||
import "errors"
|
||||
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Type conversions for Scan.
|
||||
|
||||
// This file was imported from database.sql.convert for go 1.10.3 with minor modifications to get
|
||||
// convertAssign function
|
||||
// This function is used internally by sql to convert values during call to Scan, we need same
|
||||
// logic to return values for OUTPUT parameters.
|
||||
// TODO: sql library should instead expose function defaultCheckNamedValue to be callable by drivers
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
var errNilPtr = errors.New("destination pointer is nil") // embedded in descriptive error
|
||||
|
||||
// convertAssign copies to dest the value in src, converting it if possible.
|
||||
// An error is returned if the copy would result in loss of information.
|
||||
// dest should be a pointer type.
|
||||
func convertAssign(dest, src interface{}) error {
|
||||
// Common cases, without reflect.
|
||||
switch s := src.(type) {
|
||||
case string:
|
||||
switch d := dest.(type) {
|
||||
case *string:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = s
|
||||
return nil
|
||||
case *[]byte:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = []byte(s)
|
||||
return nil
|
||||
case *sql.RawBytes:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = append((*d)[:0], s...)
|
||||
return nil
|
||||
}
|
||||
case []byte:
|
||||
switch d := dest.(type) {
|
||||
case *string:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = string(s)
|
||||
return nil
|
||||
case *interface{}:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = cloneBytes(s)
|
||||
return nil
|
||||
case *[]byte:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = cloneBytes(s)
|
||||
return nil
|
||||
case *sql.RawBytes:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = s
|
||||
return nil
|
||||
}
|
||||
case time.Time:
|
||||
switch d := dest.(type) {
|
||||
case *time.Time:
|
||||
*d = s
|
||||
return nil
|
||||
case *string:
|
||||
*d = s.Format(time.RFC3339Nano)
|
||||
return nil
|
||||
case *[]byte:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = []byte(s.Format(time.RFC3339Nano))
|
||||
return nil
|
||||
case *sql.RawBytes:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = s.AppendFormat((*d)[:0], time.RFC3339Nano)
|
||||
return nil
|
||||
}
|
||||
case nil:
|
||||
switch d := dest.(type) {
|
||||
case *interface{}:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = nil
|
||||
return nil
|
||||
case *[]byte:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = nil
|
||||
return nil
|
||||
case *sql.RawBytes:
|
||||
if d == nil {
|
||||
return errNilPtr
|
||||
}
|
||||
*d = nil
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var sv reflect.Value
|
||||
|
||||
switch d := dest.(type) {
|
||||
case *string:
|
||||
sv = reflect.ValueOf(src)
|
||||
switch sv.Kind() {
|
||||
case reflect.Bool,
|
||||
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
|
||||
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
|
||||
reflect.Float32, reflect.Float64:
|
||||
*d = asString(src)
|
||||
return nil
|
||||
}
|
||||
case *[]byte:
|
||||
sv = reflect.ValueOf(src)
|
||||
if b, ok := asBytes(nil, sv); ok {
|
||||
*d = b
|
||||
return nil
|
||||
}
|
||||
case *sql.RawBytes:
|
||||
sv = reflect.ValueOf(src)
|
||||
if b, ok := asBytes([]byte(*d)[:0], sv); ok {
|
||||
*d = sql.RawBytes(b)
|
||||
return nil
|
||||
}
|
||||
case *bool:
|
||||
bv, err := driver.Bool.ConvertValue(src)
|
||||
if err == nil {
|
||||
*d = bv.(bool)
|
||||
}
|
||||
return err
|
||||
case *interface{}:
|
||||
*d = src
|
||||
return nil
|
||||
}
|
||||
|
||||
if scanner, ok := dest.(sql.Scanner); ok {
|
||||
return scanner.Scan(src)
|
||||
}
|
||||
|
||||
dpv := reflect.ValueOf(dest)
|
||||
if dpv.Kind() != reflect.Ptr {
|
||||
return errors.New("destination not a pointer")
|
||||
}
|
||||
if dpv.IsNil() {
|
||||
return errNilPtr
|
||||
}
|
||||
|
||||
if !sv.IsValid() {
|
||||
sv = reflect.ValueOf(src)
|
||||
}
|
||||
|
||||
dv := reflect.Indirect(dpv)
|
||||
if sv.IsValid() && sv.Type().AssignableTo(dv.Type()) {
|
||||
switch b := src.(type) {
|
||||
case []byte:
|
||||
dv.Set(reflect.ValueOf(cloneBytes(b)))
|
||||
default:
|
||||
dv.Set(sv)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if dv.Kind() == sv.Kind() && sv.Type().ConvertibleTo(dv.Type()) {
|
||||
dv.Set(sv.Convert(dv.Type()))
|
||||
return nil
|
||||
}
|
||||
|
||||
// The following conversions use a string value as an intermediate representation
|
||||
// to convert between various numeric types.
|
||||
//
|
||||
// This also allows scanning into user defined types such as "type Int int64".
|
||||
// For symmetry, also check for string destination types.
|
||||
switch dv.Kind() {
|
||||
case reflect.Ptr:
|
||||
if src == nil {
|
||||
dv.Set(reflect.Zero(dv.Type()))
|
||||
return nil
|
||||
} else {
|
||||
dv.Set(reflect.New(dv.Type().Elem()))
|
||||
return convertAssign(dv.Interface(), src)
|
||||
}
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
s := asString(src)
|
||||
i64, err := strconv.ParseInt(s, 10, dv.Type().Bits())
|
||||
if err != nil {
|
||||
err = strconvErr(err)
|
||||
return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err)
|
||||
}
|
||||
dv.SetInt(i64)
|
||||
return nil
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
s := asString(src)
|
||||
u64, err := strconv.ParseUint(s, 10, dv.Type().Bits())
|
||||
if err != nil {
|
||||
err = strconvErr(err)
|
||||
return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err)
|
||||
}
|
||||
dv.SetUint(u64)
|
||||
return nil
|
||||
case reflect.Float32, reflect.Float64:
|
||||
s := asString(src)
|
||||
f64, err := strconv.ParseFloat(s, dv.Type().Bits())
|
||||
if err != nil {
|
||||
err = strconvErr(err)
|
||||
return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err)
|
||||
}
|
||||
dv.SetFloat(f64)
|
||||
return nil
|
||||
case reflect.String:
|
||||
switch v := src.(type) {
|
||||
case string:
|
||||
dv.SetString(v)
|
||||
return nil
|
||||
case []byte:
|
||||
dv.SetString(string(v))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("unsupported Scan, storing driver.Value type %T into type %T", src, dest)
|
||||
}
|
||||
|
||||
func strconvErr(err error) error {
|
||||
if ne, ok := err.(*strconv.NumError); ok {
|
||||
return ne.Err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func cloneBytes(b []byte) []byte {
|
||||
if b == nil {
|
||||
return nil
|
||||
} else {
|
||||
c := make([]byte, len(b))
|
||||
copy(c, b)
|
||||
return c
|
||||
}
|
||||
}
|
||||
|
||||
func asString(src interface{}) string {
|
||||
switch v := src.(type) {
|
||||
case string:
|
||||
return v
|
||||
case []byte:
|
||||
return string(v)
|
||||
}
|
||||
rv := reflect.ValueOf(src)
|
||||
switch rv.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
return strconv.FormatInt(rv.Int(), 10)
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
return strconv.FormatUint(rv.Uint(), 10)
|
||||
case reflect.Float64:
|
||||
return strconv.FormatFloat(rv.Float(), 'g', -1, 64)
|
||||
case reflect.Float32:
|
||||
return strconv.FormatFloat(rv.Float(), 'g', -1, 32)
|
||||
case reflect.Bool:
|
||||
return strconv.FormatBool(rv.Bool())
|
||||
}
|
||||
return fmt.Sprintf("%v", src)
|
||||
}
|
||||
|
||||
func asBytes(buf []byte, rv reflect.Value) (b []byte, ok bool) {
|
||||
switch rv.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
return strconv.AppendInt(buf, rv.Int(), 10), true
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
return strconv.AppendUint(buf, rv.Uint(), 10), true
|
||||
case reflect.Float32:
|
||||
return strconv.AppendFloat(buf, rv.Float(), 'g', -1, 32), true
|
||||
case reflect.Float64:
|
||||
return strconv.AppendFloat(buf, rv.Float(), 'g', -1, 64), true
|
||||
case reflect.Bool:
|
||||
return strconv.AppendBool(buf, rv.Bool()), true
|
||||
case reflect.String:
|
||||
s := rv.String()
|
||||
return append(buf, s...), true
|
||||
}
|
||||
return
|
||||
}
|
131
vendor/github.com/denisenkom/go-mssqldb/decimal.go
generated
vendored
Normal file
131
vendor/github.com/denisenkom/go-mssqldb/decimal.go
generated
vendored
Normal file
|
@ -0,0 +1,131 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"math"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/ee780893.aspx
|
||||
type Decimal struct {
|
||||
integer [4]uint32
|
||||
positive bool
|
||||
prec uint8
|
||||
scale uint8
|
||||
}
|
||||
|
||||
var scaletblflt64 [39]float64
|
||||
|
||||
func (d Decimal) ToFloat64() float64 {
|
||||
val := float64(0)
|
||||
for i := 3; i >= 0; i-- {
|
||||
val *= 0x100000000
|
||||
val += float64(d.integer[i])
|
||||
}
|
||||
if !d.positive {
|
||||
val = -val
|
||||
}
|
||||
if d.scale != 0 {
|
||||
val /= scaletblflt64[d.scale]
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
const autoScale = 100
|
||||
|
||||
func Float64ToDecimal(f float64) (Decimal, error) {
|
||||
return Float64ToDecimalScale(f, autoScale)
|
||||
}
|
||||
|
||||
func Float64ToDecimalScale(f float64, scale uint8) (Decimal, error) {
|
||||
var dec Decimal
|
||||
if math.IsNaN(f) {
|
||||
return dec, errors.New("NaN")
|
||||
}
|
||||
if math.IsInf(f, 0) {
|
||||
return dec, errors.New("Infinity can't be converted to decimal")
|
||||
}
|
||||
dec.positive = f >= 0
|
||||
if !dec.positive {
|
||||
f = math.Abs(f)
|
||||
}
|
||||
if f > 3.402823669209385e+38 {
|
||||
return dec, errors.New("Float value is out of range")
|
||||
}
|
||||
dec.prec = 20
|
||||
var integer float64
|
||||
for dec.scale = 0; dec.scale <= scale; dec.scale++ {
|
||||
integer = f * scaletblflt64[dec.scale]
|
||||
_, frac := math.Modf(integer)
|
||||
if frac == 0 && scale == autoScale {
|
||||
break
|
||||
}
|
||||
}
|
||||
for i := 0; i < 4; i++ {
|
||||
mod := math.Mod(integer, 0x100000000)
|
||||
integer -= mod
|
||||
integer /= 0x100000000
|
||||
dec.integer[i] = uint32(mod)
|
||||
}
|
||||
return dec, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
var acc float64 = 1
|
||||
for i := 0; i <= 38; i++ {
|
||||
scaletblflt64[i] = acc
|
||||
acc *= 10
|
||||
}
|
||||
}
|
||||
|
||||
func (d Decimal) BigInt() big.Int {
|
||||
bytes := make([]byte, 16)
|
||||
binary.BigEndian.PutUint32(bytes[0:4], d.integer[3])
|
||||
binary.BigEndian.PutUint32(bytes[4:8], d.integer[2])
|
||||
binary.BigEndian.PutUint32(bytes[8:12], d.integer[1])
|
||||
binary.BigEndian.PutUint32(bytes[12:16], d.integer[0])
|
||||
var x big.Int
|
||||
x.SetBytes(bytes)
|
||||
if !d.positive {
|
||||
x.Neg(&x)
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
func (d Decimal) Bytes() []byte {
|
||||
x := d.BigInt()
|
||||
return scaleBytes(x.String(), d.scale)
|
||||
}
|
||||
|
||||
func (d Decimal) UnscaledBytes() []byte {
|
||||
x := d.BigInt()
|
||||
return x.Bytes()
|
||||
}
|
||||
|
||||
func scaleBytes(s string, scale uint8) []byte {
|
||||
z := make([]byte, 0, len(s)+1)
|
||||
if s[0] == '-' || s[0] == '+' {
|
||||
z = append(z, byte(s[0]))
|
||||
s = s[1:]
|
||||
}
|
||||
pos := len(s) - int(scale)
|
||||
if pos <= 0 {
|
||||
z = append(z, byte('0'))
|
||||
} else if pos > 0 {
|
||||
z = append(z, []byte(s[:pos])...)
|
||||
}
|
||||
if scale > 0 {
|
||||
z = append(z, byte('.'))
|
||||
for pos < 0 {
|
||||
z = append(z, byte('0'))
|
||||
pos++
|
||||
}
|
||||
z = append(z, []byte(s[pos:])...)
|
||||
}
|
||||
return z
|
||||
}
|
||||
|
||||
func (d Decimal) String() string {
|
||||
return string(d.Bytes())
|
||||
}
|
14
vendor/github.com/denisenkom/go-mssqldb/doc.go
generated
vendored
Normal file
14
vendor/github.com/denisenkom/go-mssqldb/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
// package mssql implements the TDS protocol used to connect to MS SQL Server (sqlserver)
|
||||
// database servers.
|
||||
//
|
||||
// This package registers the driver:
|
||||
// sqlserver: uses native "@" parameter placeholder names and does no pre-processing.
|
||||
//
|
||||
// If the ordinal position is used for query parameters, identifiers will be named
|
||||
// "@p1", "@p2", ... "@pN".
|
||||
//
|
||||
// Please refer to the README for the format of the DSN. There are multiple DSN
|
||||
// formats accepted: ADO style, ODBC style, and URL style. The following is an
|
||||
// example of a URL style DSN:
|
||||
// sqlserver://sa:mypass@localhost:1234?database=master&connection+timeout=30
|
||||
package mssql
|
73
vendor/github.com/denisenkom/go-mssqldb/error.go
generated
vendored
Normal file
73
vendor/github.com/denisenkom/go-mssqldb/error.go
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Error represents an SQL Server error. This
|
||||
// type includes methods for reading the contents
|
||||
// of the struct, which allows calling programs
|
||||
// to check for specific error conditions without
|
||||
// having to import this package directly.
|
||||
type Error struct {
|
||||
Number int32
|
||||
State uint8
|
||||
Class uint8
|
||||
Message string
|
||||
ServerName string
|
||||
ProcName string
|
||||
LineNo int32
|
||||
}
|
||||
|
||||
func (e Error) Error() string {
|
||||
return "mssql: " + e.Message
|
||||
}
|
||||
|
||||
// SQLErrorNumber returns the SQL Server error number.
|
||||
func (e Error) SQLErrorNumber() int32 {
|
||||
return e.Number
|
||||
}
|
||||
|
||||
func (e Error) SQLErrorState() uint8 {
|
||||
return e.State
|
||||
}
|
||||
|
||||
func (e Error) SQLErrorClass() uint8 {
|
||||
return e.Class
|
||||
}
|
||||
|
||||
func (e Error) SQLErrorMessage() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
func (e Error) SQLErrorServerName() string {
|
||||
return e.ServerName
|
||||
}
|
||||
|
||||
func (e Error) SQLErrorProcName() string {
|
||||
return e.ProcName
|
||||
}
|
||||
|
||||
func (e Error) SQLErrorLineNo() int32 {
|
||||
return e.LineNo
|
||||
}
|
||||
|
||||
type StreamError struct {
|
||||
Message string
|
||||
}
|
||||
|
||||
func (e StreamError) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
func streamErrorf(format string, v ...interface{}) StreamError {
|
||||
return StreamError{"Invalid TDS stream: " + fmt.Sprintf(format, v...)}
|
||||
}
|
||||
|
||||
func badStreamPanic(err error) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
func badStreamPanicf(format string, v ...interface{}) {
|
||||
panic(streamErrorf(format, v...))
|
||||
}
|
113
vendor/github.com/denisenkom/go-mssqldb/internal/cp/charset.go
generated
vendored
Normal file
113
vendor/github.com/denisenkom/go-mssqldb/internal/cp/charset.go
generated
vendored
Normal file
|
@ -0,0 +1,113 @@
|
|||
package cp
|
||||
|
||||
type charsetMap struct {
|
||||
sb [256]rune // single byte runes, -1 for a double byte character lead byte
|
||||
db map[int]rune // double byte runes
|
||||
}
|
||||
|
||||
func collation2charset(col Collation) *charsetMap {
|
||||
// http://msdn.microsoft.com/en-us/library/ms144250.aspx
|
||||
// http://msdn.microsoft.com/en-us/library/ms144250(v=sql.105).aspx
|
||||
switch col.SortId {
|
||||
case 30, 31, 32, 33, 34:
|
||||
return cp437
|
||||
case 40, 41, 42, 44, 49, 55, 56, 57, 58, 59, 60, 61:
|
||||
return cp850
|
||||
case 50, 51, 52, 53, 54, 71, 72, 73, 74, 75:
|
||||
return cp1252
|
||||
case 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96:
|
||||
return cp1250
|
||||
case 104, 105, 106, 107, 108:
|
||||
return cp1251
|
||||
case 112, 113, 114, 121, 124:
|
||||
return cp1253
|
||||
case 128, 129, 130:
|
||||
return cp1254
|
||||
case 136, 137, 138:
|
||||
return cp1255
|
||||
case 144, 145, 146:
|
||||
return cp1256
|
||||
case 152, 153, 154, 155, 156, 157, 158, 159, 160:
|
||||
return cp1257
|
||||
case 183, 184, 185, 186:
|
||||
return cp1252
|
||||
case 192, 193:
|
||||
return cp932
|
||||
case 194, 195:
|
||||
return cp949
|
||||
case 196, 197:
|
||||
return cp950
|
||||
case 198, 199:
|
||||
return cp936
|
||||
case 200:
|
||||
return cp932
|
||||
case 201:
|
||||
return cp949
|
||||
case 202:
|
||||
return cp950
|
||||
case 203:
|
||||
return cp936
|
||||
case 204, 205, 206:
|
||||
return cp874
|
||||
case 210, 211, 212, 213, 214, 215, 216, 217:
|
||||
return cp1252
|
||||
}
|
||||
// http://technet.microsoft.com/en-us/library/aa176553(v=sql.80).aspx
|
||||
switch col.getLcid() {
|
||||
case 0x001e, 0x041e:
|
||||
return cp874
|
||||
case 0x0411, 0x10411:
|
||||
return cp932
|
||||
case 0x0804, 0x1004, 0x20804:
|
||||
return cp936
|
||||
case 0x0012, 0x0412:
|
||||
return cp949
|
||||
case 0x0404, 0x1404, 0x0c04, 0x7c04, 0x30404:
|
||||
return cp950
|
||||
case 0x041c, 0x041a, 0x0405, 0x040e, 0x104e, 0x0415, 0x0418, 0x041b, 0x0424, 0x1040e:
|
||||
return cp1250
|
||||
case 0x0423, 0x0402, 0x042f, 0x0419, 0x081a, 0x0c1a, 0x0422, 0x043f, 0x0444, 0x082c:
|
||||
return cp1251
|
||||
case 0x0408:
|
||||
return cp1253
|
||||
case 0x041f, 0x042c, 0x0443:
|
||||
return cp1254
|
||||
case 0x040d:
|
||||
return cp1255
|
||||
case 0x0401, 0x0801, 0xc01, 0x1001, 0x1401, 0x1801, 0x1c01, 0x2001, 0x2401, 0x2801, 0x2c01, 0x3001, 0x3401, 0x3801, 0x3c01, 0x4001, 0x0429, 0x0420:
|
||||
return cp1256
|
||||
case 0x0425, 0x0426, 0x0427, 0x0827:
|
||||
return cp1257
|
||||
case 0x042a:
|
||||
return cp1258
|
||||
case 0x0439, 0x045a, 0x0465:
|
||||
return nil
|
||||
}
|
||||
return cp1252
|
||||
}
|
||||
|
||||
func CharsetToUTF8(col Collation, s []byte) string {
|
||||
cm := collation2charset(col)
|
||||
if cm == nil {
|
||||
return string(s)
|
||||
}
|
||||
buf := make([]rune, 0, len(s))
|
||||
for i := 0; i < len(s); i++ {
|
||||
ch := cm.sb[s[i]]
|
||||
if ch == -1 {
|
||||
if i+1 == len(s) {
|
||||
ch = 0xfffd
|
||||
} else {
|
||||
n := int(s[i+1]) + (int(s[i]) << 8)
|
||||
i++
|
||||
var ok bool
|
||||
ch, ok = cm.db[n]
|
||||
if !ok {
|
||||
ch = 0xfffd
|
||||
}
|
||||
}
|
||||
}
|
||||
buf = append(buf, ch)
|
||||
}
|
||||
return string(buf)
|
||||
}
|
20
vendor/github.com/denisenkom/go-mssqldb/internal/cp/collation.go
generated
vendored
Normal file
20
vendor/github.com/denisenkom/go-mssqldb/internal/cp/collation.go
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
package cp
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd340437.aspx
|
||||
|
||||
type Collation struct {
|
||||
LcidAndFlags uint32
|
||||
SortId uint8
|
||||
}
|
||||
|
||||
func (c Collation) getLcid() uint32 {
|
||||
return c.LcidAndFlags & 0x000fffff
|
||||
}
|
||||
|
||||
func (c Collation) getFlags() uint32 {
|
||||
return (c.LcidAndFlags & 0x0ff00000) >> 20
|
||||
}
|
||||
|
||||
func (c Collation) getVersion() uint32 {
|
||||
return (c.LcidAndFlags & 0xf0000000) >> 28
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1250.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1250.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp1250 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000A, //LINE FEED
|
||||
0x000B, //VERTICAL TABULATION
|
||||
0x000C, //FORM FEED
|
||||
0x000D, //CARRIAGE RETURN
|
||||
0x000E, //SHIFT OUT
|
||||
0x000F, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001A, //SUBSTITUTE
|
||||
0x001B, //ESCAPE
|
||||
0x001C, //FILE SEPARATOR
|
||||
0x001D, //GROUP SEPARATOR
|
||||
0x001E, //RECORD SEPARATOR
|
||||
0x001F, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002A, //ASTERISK
|
||||
0x002B, //PLUS SIGN
|
||||
0x002C, //COMMA
|
||||
0x002D, //HYPHEN-MINUS
|
||||
0x002E, //FULL STOP
|
||||
0x002F, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003A, //COLON
|
||||
0x003B, //SEMICOLON
|
||||
0x003C, //LESS-THAN SIGN
|
||||
0x003D, //EQUALS SIGN
|
||||
0x003E, //GREATER-THAN SIGN
|
||||
0x003F, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
||||
0x005B, //LEFT SQUARE BRACKET
|
||||
0x005C, //REVERSE SOLIDUS
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
||||
0x005F, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006A, //LATIN SMALL LETTER J
|
||||
0x006B, //LATIN SMALL LETTER K
|
||||
0x006C, //LATIN SMALL LETTER L
|
||||
0x006D, //LATIN SMALL LETTER M
|
||||
0x006E, //LATIN SMALL LETTER N
|
||||
0x006F, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007A, //LATIN SMALL LETTER Z
|
||||
0x007B, //LEFT CURLY BRACKET
|
||||
0x007C, //VERTICAL LINE
|
||||
0x007D, //RIGHT CURLY BRACKET
|
||||
0x007E, //TILDE
|
||||
0x007F, //DELETE
|
||||
0x20AC, //EURO SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
||||
0xFFFD, //UNDEFINED
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
||||
0x2020, //DAGGER
|
||||
0x2021, //DOUBLE DAGGER
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2030, //PER MILLE SIGN
|
||||
0x0160, //LATIN CAPITAL LETTER S WITH CARON
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||
0x015A, //LATIN CAPITAL LETTER S WITH ACUTE
|
||||
0x0164, //LATIN CAPITAL LETTER T WITH CARON
|
||||
0x017D, //LATIN CAPITAL LETTER Z WITH CARON
|
||||
0x0179, //LATIN CAPITAL LETTER Z WITH ACUTE
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
||||
0x2022, //BULLET
|
||||
0x2013, //EN DASH
|
||||
0x2014, //EM DASH
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2122, //TRADE MARK SIGN
|
||||
0x0161, //LATIN SMALL LETTER S WITH CARON
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||
0x015B, //LATIN SMALL LETTER S WITH ACUTE
|
||||
0x0165, //LATIN SMALL LETTER T WITH CARON
|
||||
0x017E, //LATIN SMALL LETTER Z WITH CARON
|
||||
0x017A, //LATIN SMALL LETTER Z WITH ACUTE
|
||||
0x00A0, //NO-BREAK SPACE
|
||||
0x02C7, //CARON
|
||||
0x02D8, //BREVE
|
||||
0x0141, //LATIN CAPITAL LETTER L WITH STROKE
|
||||
0x00A4, //CURRENCY SIGN
|
||||
0x0104, //LATIN CAPITAL LETTER A WITH OGONEK
|
||||
0x00A6, //BROKEN BAR
|
||||
0x00A7, //SECTION SIGN
|
||||
0x00A8, //DIAERESIS
|
||||
0x00A9, //COPYRIGHT SIGN
|
||||
0x015E, //LATIN CAPITAL LETTER S WITH CEDILLA
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00AC, //NOT SIGN
|
||||
0x00AD, //SOFT HYPHEN
|
||||
0x00AE, //REGISTERED SIGN
|
||||
0x017B, //LATIN CAPITAL LETTER Z WITH DOT ABOVE
|
||||
0x00B0, //DEGREE SIGN
|
||||
0x00B1, //PLUS-MINUS SIGN
|
||||
0x02DB, //OGONEK
|
||||
0x0142, //LATIN SMALL LETTER L WITH STROKE
|
||||
0x00B4, //ACUTE ACCENT
|
||||
0x00B5, //MICRO SIGN
|
||||
0x00B6, //PILCROW SIGN
|
||||
0x00B7, //MIDDLE DOT
|
||||
0x00B8, //CEDILLA
|
||||
0x0105, //LATIN SMALL LETTER A WITH OGONEK
|
||||
0x015F, //LATIN SMALL LETTER S WITH CEDILLA
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x013D, //LATIN CAPITAL LETTER L WITH CARON
|
||||
0x02DD, //DOUBLE ACUTE ACCENT
|
||||
0x013E, //LATIN SMALL LETTER L WITH CARON
|
||||
0x017C, //LATIN SMALL LETTER Z WITH DOT ABOVE
|
||||
0x0154, //LATIN CAPITAL LETTER R WITH ACUTE
|
||||
0x00C1, //LATIN CAPITAL LETTER A WITH ACUTE
|
||||
0x00C2, //LATIN CAPITAL LETTER A WITH CIRCUMFLEX
|
||||
0x0102, //LATIN CAPITAL LETTER A WITH BREVE
|
||||
0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
||||
0x0139, //LATIN CAPITAL LETTER L WITH ACUTE
|
||||
0x0106, //LATIN CAPITAL LETTER C WITH ACUTE
|
||||
0x00C7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
||||
0x010C, //LATIN CAPITAL LETTER C WITH CARON
|
||||
0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE
|
||||
0x0118, //LATIN CAPITAL LETTER E WITH OGONEK
|
||||
0x00CB, //LATIN CAPITAL LETTER E WITH DIAERESIS
|
||||
0x011A, //LATIN CAPITAL LETTER E WITH CARON
|
||||
0x00CD, //LATIN CAPITAL LETTER I WITH ACUTE
|
||||
0x00CE, //LATIN CAPITAL LETTER I WITH CIRCUMFLEX
|
||||
0x010E, //LATIN CAPITAL LETTER D WITH CARON
|
||||
0x0110, //LATIN CAPITAL LETTER D WITH STROKE
|
||||
0x0143, //LATIN CAPITAL LETTER N WITH ACUTE
|
||||
0x0147, //LATIN CAPITAL LETTER N WITH CARON
|
||||
0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE
|
||||
0x00D4, //LATIN CAPITAL LETTER O WITH CIRCUMFLEX
|
||||
0x0150, //LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
|
||||
0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
0x00D7, //MULTIPLICATION SIGN
|
||||
0x0158, //LATIN CAPITAL LETTER R WITH CARON
|
||||
0x016E, //LATIN CAPITAL LETTER U WITH RING ABOVE
|
||||
0x00DA, //LATIN CAPITAL LETTER U WITH ACUTE
|
||||
0x0170, //LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
|
||||
0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
||||
0x00DD, //LATIN CAPITAL LETTER Y WITH ACUTE
|
||||
0x0162, //LATIN CAPITAL LETTER T WITH CEDILLA
|
||||
0x00DF, //LATIN SMALL LETTER SHARP S
|
||||
0x0155, //LATIN SMALL LETTER R WITH ACUTE
|
||||
0x00E1, //LATIN SMALL LETTER A WITH ACUTE
|
||||
0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
||||
0x0103, //LATIN SMALL LETTER A WITH BREVE
|
||||
0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS
|
||||
0x013A, //LATIN SMALL LETTER L WITH ACUTE
|
||||
0x0107, //LATIN SMALL LETTER C WITH ACUTE
|
||||
0x00E7, //LATIN SMALL LETTER C WITH CEDILLA
|
||||
0x010D, //LATIN SMALL LETTER C WITH CARON
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
||||
0x0119, //LATIN SMALL LETTER E WITH OGONEK
|
||||
0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS
|
||||
0x011B, //LATIN SMALL LETTER E WITH CARON
|
||||
0x00ED, //LATIN SMALL LETTER I WITH ACUTE
|
||||
0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
||||
0x010F, //LATIN SMALL LETTER D WITH CARON
|
||||
0x0111, //LATIN SMALL LETTER D WITH STROKE
|
||||
0x0144, //LATIN SMALL LETTER N WITH ACUTE
|
||||
0x0148, //LATIN SMALL LETTER N WITH CARON
|
||||
0x00F3, //LATIN SMALL LETTER O WITH ACUTE
|
||||
0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
||||
0x0151, //LATIN SMALL LETTER O WITH DOUBLE ACUTE
|
||||
0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS
|
||||
0x00F7, //DIVISION SIGN
|
||||
0x0159, //LATIN SMALL LETTER R WITH CARON
|
||||
0x016F, //LATIN SMALL LETTER U WITH RING ABOVE
|
||||
0x00FA, //LATIN SMALL LETTER U WITH ACUTE
|
||||
0x0171, //LATIN SMALL LETTER U WITH DOUBLE ACUTE
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
||||
0x00FD, //LATIN SMALL LETTER Y WITH ACUTE
|
||||
0x0163, //LATIN SMALL LETTER T WITH CEDILLA
|
||||
0x02D9, //DOT ABOVE
|
||||
},
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1251.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1251.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp1251 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000A, //LINE FEED
|
||||
0x000B, //VERTICAL TABULATION
|
||||
0x000C, //FORM FEED
|
||||
0x000D, //CARRIAGE RETURN
|
||||
0x000E, //SHIFT OUT
|
||||
0x000F, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001A, //SUBSTITUTE
|
||||
0x001B, //ESCAPE
|
||||
0x001C, //FILE SEPARATOR
|
||||
0x001D, //GROUP SEPARATOR
|
||||
0x001E, //RECORD SEPARATOR
|
||||
0x001F, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002A, //ASTERISK
|
||||
0x002B, //PLUS SIGN
|
||||
0x002C, //COMMA
|
||||
0x002D, //HYPHEN-MINUS
|
||||
0x002E, //FULL STOP
|
||||
0x002F, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003A, //COLON
|
||||
0x003B, //SEMICOLON
|
||||
0x003C, //LESS-THAN SIGN
|
||||
0x003D, //EQUALS SIGN
|
||||
0x003E, //GREATER-THAN SIGN
|
||||
0x003F, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
||||
0x005B, //LEFT SQUARE BRACKET
|
||||
0x005C, //REVERSE SOLIDUS
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
||||
0x005F, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006A, //LATIN SMALL LETTER J
|
||||
0x006B, //LATIN SMALL LETTER K
|
||||
0x006C, //LATIN SMALL LETTER L
|
||||
0x006D, //LATIN SMALL LETTER M
|
||||
0x006E, //LATIN SMALL LETTER N
|
||||
0x006F, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007A, //LATIN SMALL LETTER Z
|
||||
0x007B, //LEFT CURLY BRACKET
|
||||
0x007C, //VERTICAL LINE
|
||||
0x007D, //RIGHT CURLY BRACKET
|
||||
0x007E, //TILDE
|
||||
0x007F, //DELETE
|
||||
0x0402, //CYRILLIC CAPITAL LETTER DJE
|
||||
0x0403, //CYRILLIC CAPITAL LETTER GJE
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
||||
0x0453, //CYRILLIC SMALL LETTER GJE
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
||||
0x2020, //DAGGER
|
||||
0x2021, //DOUBLE DAGGER
|
||||
0x20AC, //EURO SIGN
|
||||
0x2030, //PER MILLE SIGN
|
||||
0x0409, //CYRILLIC CAPITAL LETTER LJE
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||
0x040A, //CYRILLIC CAPITAL LETTER NJE
|
||||
0x040C, //CYRILLIC CAPITAL LETTER KJE
|
||||
0x040B, //CYRILLIC CAPITAL LETTER TSHE
|
||||
0x040F, //CYRILLIC CAPITAL LETTER DZHE
|
||||
0x0452, //CYRILLIC SMALL LETTER DJE
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
||||
0x2022, //BULLET
|
||||
0x2013, //EN DASH
|
||||
0x2014, //EM DASH
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2122, //TRADE MARK SIGN
|
||||
0x0459, //CYRILLIC SMALL LETTER LJE
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||
0x045A, //CYRILLIC SMALL LETTER NJE
|
||||
0x045C, //CYRILLIC SMALL LETTER KJE
|
||||
0x045B, //CYRILLIC SMALL LETTER TSHE
|
||||
0x045F, //CYRILLIC SMALL LETTER DZHE
|
||||
0x00A0, //NO-BREAK SPACE
|
||||
0x040E, //CYRILLIC CAPITAL LETTER SHORT U
|
||||
0x045E, //CYRILLIC SMALL LETTER SHORT U
|
||||
0x0408, //CYRILLIC CAPITAL LETTER JE
|
||||
0x00A4, //CURRENCY SIGN
|
||||
0x0490, //CYRILLIC CAPITAL LETTER GHE WITH UPTURN
|
||||
0x00A6, //BROKEN BAR
|
||||
0x00A7, //SECTION SIGN
|
||||
0x0401, //CYRILLIC CAPITAL LETTER IO
|
||||
0x00A9, //COPYRIGHT SIGN
|
||||
0x0404, //CYRILLIC CAPITAL LETTER UKRAINIAN IE
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00AC, //NOT SIGN
|
||||
0x00AD, //SOFT HYPHEN
|
||||
0x00AE, //REGISTERED SIGN
|
||||
0x0407, //CYRILLIC CAPITAL LETTER YI
|
||||
0x00B0, //DEGREE SIGN
|
||||
0x00B1, //PLUS-MINUS SIGN
|
||||
0x0406, //CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
|
||||
0x0456, //CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
|
||||
0x0491, //CYRILLIC SMALL LETTER GHE WITH UPTURN
|
||||
0x00B5, //MICRO SIGN
|
||||
0x00B6, //PILCROW SIGN
|
||||
0x00B7, //MIDDLE DOT
|
||||
0x0451, //CYRILLIC SMALL LETTER IO
|
||||
0x2116, //NUMERO SIGN
|
||||
0x0454, //CYRILLIC SMALL LETTER UKRAINIAN IE
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x0458, //CYRILLIC SMALL LETTER JE
|
||||
0x0405, //CYRILLIC CAPITAL LETTER DZE
|
||||
0x0455, //CYRILLIC SMALL LETTER DZE
|
||||
0x0457, //CYRILLIC SMALL LETTER YI
|
||||
0x0410, //CYRILLIC CAPITAL LETTER A
|
||||
0x0411, //CYRILLIC CAPITAL LETTER BE
|
||||
0x0412, //CYRILLIC CAPITAL LETTER VE
|
||||
0x0413, //CYRILLIC CAPITAL LETTER GHE
|
||||
0x0414, //CYRILLIC CAPITAL LETTER DE
|
||||
0x0415, //CYRILLIC CAPITAL LETTER IE
|
||||
0x0416, //CYRILLIC CAPITAL LETTER ZHE
|
||||
0x0417, //CYRILLIC CAPITAL LETTER ZE
|
||||
0x0418, //CYRILLIC CAPITAL LETTER I
|
||||
0x0419, //CYRILLIC CAPITAL LETTER SHORT I
|
||||
0x041A, //CYRILLIC CAPITAL LETTER KA
|
||||
0x041B, //CYRILLIC CAPITAL LETTER EL
|
||||
0x041C, //CYRILLIC CAPITAL LETTER EM
|
||||
0x041D, //CYRILLIC CAPITAL LETTER EN
|
||||
0x041E, //CYRILLIC CAPITAL LETTER O
|
||||
0x041F, //CYRILLIC CAPITAL LETTER PE
|
||||
0x0420, //CYRILLIC CAPITAL LETTER ER
|
||||
0x0421, //CYRILLIC CAPITAL LETTER ES
|
||||
0x0422, //CYRILLIC CAPITAL LETTER TE
|
||||
0x0423, //CYRILLIC CAPITAL LETTER U
|
||||
0x0424, //CYRILLIC CAPITAL LETTER EF
|
||||
0x0425, //CYRILLIC CAPITAL LETTER HA
|
||||
0x0426, //CYRILLIC CAPITAL LETTER TSE
|
||||
0x0427, //CYRILLIC CAPITAL LETTER CHE
|
||||
0x0428, //CYRILLIC CAPITAL LETTER SHA
|
||||
0x0429, //CYRILLIC CAPITAL LETTER SHCHA
|
||||
0x042A, //CYRILLIC CAPITAL LETTER HARD SIGN
|
||||
0x042B, //CYRILLIC CAPITAL LETTER YERU
|
||||
0x042C, //CYRILLIC CAPITAL LETTER SOFT SIGN
|
||||
0x042D, //CYRILLIC CAPITAL LETTER E
|
||||
0x042E, //CYRILLIC CAPITAL LETTER YU
|
||||
0x042F, //CYRILLIC CAPITAL LETTER YA
|
||||
0x0430, //CYRILLIC SMALL LETTER A
|
||||
0x0431, //CYRILLIC SMALL LETTER BE
|
||||
0x0432, //CYRILLIC SMALL LETTER VE
|
||||
0x0433, //CYRILLIC SMALL LETTER GHE
|
||||
0x0434, //CYRILLIC SMALL LETTER DE
|
||||
0x0435, //CYRILLIC SMALL LETTER IE
|
||||
0x0436, //CYRILLIC SMALL LETTER ZHE
|
||||
0x0437, //CYRILLIC SMALL LETTER ZE
|
||||
0x0438, //CYRILLIC SMALL LETTER I
|
||||
0x0439, //CYRILLIC SMALL LETTER SHORT I
|
||||
0x043A, //CYRILLIC SMALL LETTER KA
|
||||
0x043B, //CYRILLIC SMALL LETTER EL
|
||||
0x043C, //CYRILLIC SMALL LETTER EM
|
||||
0x043D, //CYRILLIC SMALL LETTER EN
|
||||
0x043E, //CYRILLIC SMALL LETTER O
|
||||
0x043F, //CYRILLIC SMALL LETTER PE
|
||||
0x0440, //CYRILLIC SMALL LETTER ER
|
||||
0x0441, //CYRILLIC SMALL LETTER ES
|
||||
0x0442, //CYRILLIC SMALL LETTER TE
|
||||
0x0443, //CYRILLIC SMALL LETTER U
|
||||
0x0444, //CYRILLIC SMALL LETTER EF
|
||||
0x0445, //CYRILLIC SMALL LETTER HA
|
||||
0x0446, //CYRILLIC SMALL LETTER TSE
|
||||
0x0447, //CYRILLIC SMALL LETTER CHE
|
||||
0x0448, //CYRILLIC SMALL LETTER SHA
|
||||
0x0449, //CYRILLIC SMALL LETTER SHCHA
|
||||
0x044A, //CYRILLIC SMALL LETTER HARD SIGN
|
||||
0x044B, //CYRILLIC SMALL LETTER YERU
|
||||
0x044C, //CYRILLIC SMALL LETTER SOFT SIGN
|
||||
0x044D, //CYRILLIC SMALL LETTER E
|
||||
0x044E, //CYRILLIC SMALL LETTER YU
|
||||
0x044F, //CYRILLIC SMALL LETTER YA
|
||||
},
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1252.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1252.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp1252 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000A, //LINE FEED
|
||||
0x000B, //VERTICAL TABULATION
|
||||
0x000C, //FORM FEED
|
||||
0x000D, //CARRIAGE RETURN
|
||||
0x000E, //SHIFT OUT
|
||||
0x000F, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001A, //SUBSTITUTE
|
||||
0x001B, //ESCAPE
|
||||
0x001C, //FILE SEPARATOR
|
||||
0x001D, //GROUP SEPARATOR
|
||||
0x001E, //RECORD SEPARATOR
|
||||
0x001F, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002A, //ASTERISK
|
||||
0x002B, //PLUS SIGN
|
||||
0x002C, //COMMA
|
||||
0x002D, //HYPHEN-MINUS
|
||||
0x002E, //FULL STOP
|
||||
0x002F, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003A, //COLON
|
||||
0x003B, //SEMICOLON
|
||||
0x003C, //LESS-THAN SIGN
|
||||
0x003D, //EQUALS SIGN
|
||||
0x003E, //GREATER-THAN SIGN
|
||||
0x003F, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
||||
0x005B, //LEFT SQUARE BRACKET
|
||||
0x005C, //REVERSE SOLIDUS
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
||||
0x005F, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006A, //LATIN SMALL LETTER J
|
||||
0x006B, //LATIN SMALL LETTER K
|
||||
0x006C, //LATIN SMALL LETTER L
|
||||
0x006D, //LATIN SMALL LETTER M
|
||||
0x006E, //LATIN SMALL LETTER N
|
||||
0x006F, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007A, //LATIN SMALL LETTER Z
|
||||
0x007B, //LEFT CURLY BRACKET
|
||||
0x007C, //VERTICAL LINE
|
||||
0x007D, //RIGHT CURLY BRACKET
|
||||
0x007E, //TILDE
|
||||
0x007F, //DELETE
|
||||
0x20AC, //EURO SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
||||
0x2020, //DAGGER
|
||||
0x2021, //DOUBLE DAGGER
|
||||
0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT
|
||||
0x2030, //PER MILLE SIGN
|
||||
0x0160, //LATIN CAPITAL LETTER S WITH CARON
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||
0x0152, //LATIN CAPITAL LIGATURE OE
|
||||
0xFFFD, //UNDEFINED
|
||||
0x017D, //LATIN CAPITAL LETTER Z WITH CARON
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
||||
0x2022, //BULLET
|
||||
0x2013, //EN DASH
|
||||
0x2014, //EM DASH
|
||||
0x02DC, //SMALL TILDE
|
||||
0x2122, //TRADE MARK SIGN
|
||||
0x0161, //LATIN SMALL LETTER S WITH CARON
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||
0x0153, //LATIN SMALL LIGATURE OE
|
||||
0xFFFD, //UNDEFINED
|
||||
0x017E, //LATIN SMALL LETTER Z WITH CARON
|
||||
0x0178, //LATIN CAPITAL LETTER Y WITH DIAERESIS
|
||||
0x00A0, //NO-BREAK SPACE
|
||||
0x00A1, //INVERTED EXCLAMATION MARK
|
||||
0x00A2, //CENT SIGN
|
||||
0x00A3, //POUND SIGN
|
||||
0x00A4, //CURRENCY SIGN
|
||||
0x00A5, //YEN SIGN
|
||||
0x00A6, //BROKEN BAR
|
||||
0x00A7, //SECTION SIGN
|
||||
0x00A8, //DIAERESIS
|
||||
0x00A9, //COPYRIGHT SIGN
|
||||
0x00AA, //FEMININE ORDINAL INDICATOR
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00AC, //NOT SIGN
|
||||
0x00AD, //SOFT HYPHEN
|
||||
0x00AE, //REGISTERED SIGN
|
||||
0x00AF, //MACRON
|
||||
0x00B0, //DEGREE SIGN
|
||||
0x00B1, //PLUS-MINUS SIGN
|
||||
0x00B2, //SUPERSCRIPT TWO
|
||||
0x00B3, //SUPERSCRIPT THREE
|
||||
0x00B4, //ACUTE ACCENT
|
||||
0x00B5, //MICRO SIGN
|
||||
0x00B6, //PILCROW SIGN
|
||||
0x00B7, //MIDDLE DOT
|
||||
0x00B8, //CEDILLA
|
||||
0x00B9, //SUPERSCRIPT ONE
|
||||
0x00BA, //MASCULINE ORDINAL INDICATOR
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
||||
0x00BF, //INVERTED QUESTION MARK
|
||||
0x00C0, //LATIN CAPITAL LETTER A WITH GRAVE
|
||||
0x00C1, //LATIN CAPITAL LETTER A WITH ACUTE
|
||||
0x00C2, //LATIN CAPITAL LETTER A WITH CIRCUMFLEX
|
||||
0x00C3, //LATIN CAPITAL LETTER A WITH TILDE
|
||||
0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
||||
0x00C5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
||||
0x00C6, //LATIN CAPITAL LETTER AE
|
||||
0x00C7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
||||
0x00C8, //LATIN CAPITAL LETTER E WITH GRAVE
|
||||
0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE
|
||||
0x00CA, //LATIN CAPITAL LETTER E WITH CIRCUMFLEX
|
||||
0x00CB, //LATIN CAPITAL LETTER E WITH DIAERESIS
|
||||
0x00CC, //LATIN CAPITAL LETTER I WITH GRAVE
|
||||
0x00CD, //LATIN CAPITAL LETTER I WITH ACUTE
|
||||
0x00CE, //LATIN CAPITAL LETTER I WITH CIRCUMFLEX
|
||||
0x00CF, //LATIN CAPITAL LETTER I WITH DIAERESIS
|
||||
0x00D0, //LATIN CAPITAL LETTER ETH
|
||||
0x00D1, //LATIN CAPITAL LETTER N WITH TILDE
|
||||
0x00D2, //LATIN CAPITAL LETTER O WITH GRAVE
|
||||
0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE
|
||||
0x00D4, //LATIN CAPITAL LETTER O WITH CIRCUMFLEX
|
||||
0x00D5, //LATIN CAPITAL LETTER O WITH TILDE
|
||||
0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
0x00D7, //MULTIPLICATION SIGN
|
||||
0x00D8, //LATIN CAPITAL LETTER O WITH STROKE
|
||||
0x00D9, //LATIN CAPITAL LETTER U WITH GRAVE
|
||||
0x00DA, //LATIN CAPITAL LETTER U WITH ACUTE
|
||||
0x00DB, //LATIN CAPITAL LETTER U WITH CIRCUMFLEX
|
||||
0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
||||
0x00DD, //LATIN CAPITAL LETTER Y WITH ACUTE
|
||||
0x00DE, //LATIN CAPITAL LETTER THORN
|
||||
0x00DF, //LATIN SMALL LETTER SHARP S
|
||||
0x00E0, //LATIN SMALL LETTER A WITH GRAVE
|
||||
0x00E1, //LATIN SMALL LETTER A WITH ACUTE
|
||||
0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
||||
0x00E3, //LATIN SMALL LETTER A WITH TILDE
|
||||
0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS
|
||||
0x00E5, //LATIN SMALL LETTER A WITH RING ABOVE
|
||||
0x00E6, //LATIN SMALL LETTER AE
|
||||
0x00E7, //LATIN SMALL LETTER C WITH CEDILLA
|
||||
0x00E8, //LATIN SMALL LETTER E WITH GRAVE
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
||||
0x00EA, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
||||
0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS
|
||||
0x00EC, //LATIN SMALL LETTER I WITH GRAVE
|
||||
0x00ED, //LATIN SMALL LETTER I WITH ACUTE
|
||||
0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
||||
0x00EF, //LATIN SMALL LETTER I WITH DIAERESIS
|
||||
0x00F0, //LATIN SMALL LETTER ETH
|
||||
0x00F1, //LATIN SMALL LETTER N WITH TILDE
|
||||
0x00F2, //LATIN SMALL LETTER O WITH GRAVE
|
||||
0x00F3, //LATIN SMALL LETTER O WITH ACUTE
|
||||
0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
||||
0x00F5, //LATIN SMALL LETTER O WITH TILDE
|
||||
0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS
|
||||
0x00F7, //DIVISION SIGN
|
||||
0x00F8, //LATIN SMALL LETTER O WITH STROKE
|
||||
0x00F9, //LATIN SMALL LETTER U WITH GRAVE
|
||||
0x00FA, //LATIN SMALL LETTER U WITH ACUTE
|
||||
0x00FB, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
||||
0x00FD, //LATIN SMALL LETTER Y WITH ACUTE
|
||||
0x00FE, //LATIN SMALL LETTER THORN
|
||||
0x00FF, //LATIN SMALL LETTER Y WITH DIAERESIS
|
||||
},
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1253.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1253.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp1253 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000A, //LINE FEED
|
||||
0x000B, //VERTICAL TABULATION
|
||||
0x000C, //FORM FEED
|
||||
0x000D, //CARRIAGE RETURN
|
||||
0x000E, //SHIFT OUT
|
||||
0x000F, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001A, //SUBSTITUTE
|
||||
0x001B, //ESCAPE
|
||||
0x001C, //FILE SEPARATOR
|
||||
0x001D, //GROUP SEPARATOR
|
||||
0x001E, //RECORD SEPARATOR
|
||||
0x001F, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002A, //ASTERISK
|
||||
0x002B, //PLUS SIGN
|
||||
0x002C, //COMMA
|
||||
0x002D, //HYPHEN-MINUS
|
||||
0x002E, //FULL STOP
|
||||
0x002F, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003A, //COLON
|
||||
0x003B, //SEMICOLON
|
||||
0x003C, //LESS-THAN SIGN
|
||||
0x003D, //EQUALS SIGN
|
||||
0x003E, //GREATER-THAN SIGN
|
||||
0x003F, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
||||
0x005B, //LEFT SQUARE BRACKET
|
||||
0x005C, //REVERSE SOLIDUS
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
||||
0x005F, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006A, //LATIN SMALL LETTER J
|
||||
0x006B, //LATIN SMALL LETTER K
|
||||
0x006C, //LATIN SMALL LETTER L
|
||||
0x006D, //LATIN SMALL LETTER M
|
||||
0x006E, //LATIN SMALL LETTER N
|
||||
0x006F, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007A, //LATIN SMALL LETTER Z
|
||||
0x007B, //LEFT CURLY BRACKET
|
||||
0x007C, //VERTICAL LINE
|
||||
0x007D, //RIGHT CURLY BRACKET
|
||||
0x007E, //TILDE
|
||||
0x007F, //DELETE
|
||||
0x20AC, //EURO SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
||||
0x2020, //DAGGER
|
||||
0x2021, //DOUBLE DAGGER
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2030, //PER MILLE SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
||||
0x2022, //BULLET
|
||||
0x2013, //EN DASH
|
||||
0x2014, //EM DASH
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2122, //TRADE MARK SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x00A0, //NO-BREAK SPACE
|
||||
0x0385, //GREEK DIALYTIKA TONOS
|
||||
0x0386, //GREEK CAPITAL LETTER ALPHA WITH TONOS
|
||||
0x00A3, //POUND SIGN
|
||||
0x00A4, //CURRENCY SIGN
|
||||
0x00A5, //YEN SIGN
|
||||
0x00A6, //BROKEN BAR
|
||||
0x00A7, //SECTION SIGN
|
||||
0x00A8, //DIAERESIS
|
||||
0x00A9, //COPYRIGHT SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00AC, //NOT SIGN
|
||||
0x00AD, //SOFT HYPHEN
|
||||
0x00AE, //REGISTERED SIGN
|
||||
0x2015, //HORIZONTAL BAR
|
||||
0x00B0, //DEGREE SIGN
|
||||
0x00B1, //PLUS-MINUS SIGN
|
||||
0x00B2, //SUPERSCRIPT TWO
|
||||
0x00B3, //SUPERSCRIPT THREE
|
||||
0x0384, //GREEK TONOS
|
||||
0x00B5, //MICRO SIGN
|
||||
0x00B6, //PILCROW SIGN
|
||||
0x00B7, //MIDDLE DOT
|
||||
0x0388, //GREEK CAPITAL LETTER EPSILON WITH TONOS
|
||||
0x0389, //GREEK CAPITAL LETTER ETA WITH TONOS
|
||||
0x038A, //GREEK CAPITAL LETTER IOTA WITH TONOS
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x038C, //GREEK CAPITAL LETTER OMICRON WITH TONOS
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
||||
0x038E, //GREEK CAPITAL LETTER UPSILON WITH TONOS
|
||||
0x038F, //GREEK CAPITAL LETTER OMEGA WITH TONOS
|
||||
0x0390, //GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
|
||||
0x0391, //GREEK CAPITAL LETTER ALPHA
|
||||
0x0392, //GREEK CAPITAL LETTER BETA
|
||||
0x0393, //GREEK CAPITAL LETTER GAMMA
|
||||
0x0394, //GREEK CAPITAL LETTER DELTA
|
||||
0x0395, //GREEK CAPITAL LETTER EPSILON
|
||||
0x0396, //GREEK CAPITAL LETTER ZETA
|
||||
0x0397, //GREEK CAPITAL LETTER ETA
|
||||
0x0398, //GREEK CAPITAL LETTER THETA
|
||||
0x0399, //GREEK CAPITAL LETTER IOTA
|
||||
0x039A, //GREEK CAPITAL LETTER KAPPA
|
||||
0x039B, //GREEK CAPITAL LETTER LAMDA
|
||||
0x039C, //GREEK CAPITAL LETTER MU
|
||||
0x039D, //GREEK CAPITAL LETTER NU
|
||||
0x039E, //GREEK CAPITAL LETTER XI
|
||||
0x039F, //GREEK CAPITAL LETTER OMICRON
|
||||
0x03A0, //GREEK CAPITAL LETTER PI
|
||||
0x03A1, //GREEK CAPITAL LETTER RHO
|
||||
0xFFFD, //UNDEFINED
|
||||
0x03A3, //GREEK CAPITAL LETTER SIGMA
|
||||
0x03A4, //GREEK CAPITAL LETTER TAU
|
||||
0x03A5, //GREEK CAPITAL LETTER UPSILON
|
||||
0x03A6, //GREEK CAPITAL LETTER PHI
|
||||
0x03A7, //GREEK CAPITAL LETTER CHI
|
||||
0x03A8, //GREEK CAPITAL LETTER PSI
|
||||
0x03A9, //GREEK CAPITAL LETTER OMEGA
|
||||
0x03AA, //GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
|
||||
0x03AB, //GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
|
||||
0x03AC, //GREEK SMALL LETTER ALPHA WITH TONOS
|
||||
0x03AD, //GREEK SMALL LETTER EPSILON WITH TONOS
|
||||
0x03AE, //GREEK SMALL LETTER ETA WITH TONOS
|
||||
0x03AF, //GREEK SMALL LETTER IOTA WITH TONOS
|
||||
0x03B0, //GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
|
||||
0x03B1, //GREEK SMALL LETTER ALPHA
|
||||
0x03B2, //GREEK SMALL LETTER BETA
|
||||
0x03B3, //GREEK SMALL LETTER GAMMA
|
||||
0x03B4, //GREEK SMALL LETTER DELTA
|
||||
0x03B5, //GREEK SMALL LETTER EPSILON
|
||||
0x03B6, //GREEK SMALL LETTER ZETA
|
||||
0x03B7, //GREEK SMALL LETTER ETA
|
||||
0x03B8, //GREEK SMALL LETTER THETA
|
||||
0x03B9, //GREEK SMALL LETTER IOTA
|
||||
0x03BA, //GREEK SMALL LETTER KAPPA
|
||||
0x03BB, //GREEK SMALL LETTER LAMDA
|
||||
0x03BC, //GREEK SMALL LETTER MU
|
||||
0x03BD, //GREEK SMALL LETTER NU
|
||||
0x03BE, //GREEK SMALL LETTER XI
|
||||
0x03BF, //GREEK SMALL LETTER OMICRON
|
||||
0x03C0, //GREEK SMALL LETTER PI
|
||||
0x03C1, //GREEK SMALL LETTER RHO
|
||||
0x03C2, //GREEK SMALL LETTER FINAL SIGMA
|
||||
0x03C3, //GREEK SMALL LETTER SIGMA
|
||||
0x03C4, //GREEK SMALL LETTER TAU
|
||||
0x03C5, //GREEK SMALL LETTER UPSILON
|
||||
0x03C6, //GREEK SMALL LETTER PHI
|
||||
0x03C7, //GREEK SMALL LETTER CHI
|
||||
0x03C8, //GREEK SMALL LETTER PSI
|
||||
0x03C9, //GREEK SMALL LETTER OMEGA
|
||||
0x03CA, //GREEK SMALL LETTER IOTA WITH DIALYTIKA
|
||||
0x03CB, //GREEK SMALL LETTER UPSILON WITH DIALYTIKA
|
||||
0x03CC, //GREEK SMALL LETTER OMICRON WITH TONOS
|
||||
0x03CD, //GREEK SMALL LETTER UPSILON WITH TONOS
|
||||
0x03CE, //GREEK SMALL LETTER OMEGA WITH TONOS
|
||||
0xFFFD, //UNDEFINED
|
||||
},
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1254.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1254.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp1254 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000A, //LINE FEED
|
||||
0x000B, //VERTICAL TABULATION
|
||||
0x000C, //FORM FEED
|
||||
0x000D, //CARRIAGE RETURN
|
||||
0x000E, //SHIFT OUT
|
||||
0x000F, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001A, //SUBSTITUTE
|
||||
0x001B, //ESCAPE
|
||||
0x001C, //FILE SEPARATOR
|
||||
0x001D, //GROUP SEPARATOR
|
||||
0x001E, //RECORD SEPARATOR
|
||||
0x001F, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002A, //ASTERISK
|
||||
0x002B, //PLUS SIGN
|
||||
0x002C, //COMMA
|
||||
0x002D, //HYPHEN-MINUS
|
||||
0x002E, //FULL STOP
|
||||
0x002F, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003A, //COLON
|
||||
0x003B, //SEMICOLON
|
||||
0x003C, //LESS-THAN SIGN
|
||||
0x003D, //EQUALS SIGN
|
||||
0x003E, //GREATER-THAN SIGN
|
||||
0x003F, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
||||
0x005B, //LEFT SQUARE BRACKET
|
||||
0x005C, //REVERSE SOLIDUS
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
||||
0x005F, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006A, //LATIN SMALL LETTER J
|
||||
0x006B, //LATIN SMALL LETTER K
|
||||
0x006C, //LATIN SMALL LETTER L
|
||||
0x006D, //LATIN SMALL LETTER M
|
||||
0x006E, //LATIN SMALL LETTER N
|
||||
0x006F, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007A, //LATIN SMALL LETTER Z
|
||||
0x007B, //LEFT CURLY BRACKET
|
||||
0x007C, //VERTICAL LINE
|
||||
0x007D, //RIGHT CURLY BRACKET
|
||||
0x007E, //TILDE
|
||||
0x007F, //DELETE
|
||||
0x20AC, //EURO SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
||||
0x2020, //DAGGER
|
||||
0x2021, //DOUBLE DAGGER
|
||||
0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT
|
||||
0x2030, //PER MILLE SIGN
|
||||
0x0160, //LATIN CAPITAL LETTER S WITH CARON
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||
0x0152, //LATIN CAPITAL LIGATURE OE
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
||||
0x2022, //BULLET
|
||||
0x2013, //EN DASH
|
||||
0x2014, //EM DASH
|
||||
0x02DC, //SMALL TILDE
|
||||
0x2122, //TRADE MARK SIGN
|
||||
0x0161, //LATIN SMALL LETTER S WITH CARON
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||
0x0153, //LATIN SMALL LIGATURE OE
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x0178, //LATIN CAPITAL LETTER Y WITH DIAERESIS
|
||||
0x00A0, //NO-BREAK SPACE
|
||||
0x00A1, //INVERTED EXCLAMATION MARK
|
||||
0x00A2, //CENT SIGN
|
||||
0x00A3, //POUND SIGN
|
||||
0x00A4, //CURRENCY SIGN
|
||||
0x00A5, //YEN SIGN
|
||||
0x00A6, //BROKEN BAR
|
||||
0x00A7, //SECTION SIGN
|
||||
0x00A8, //DIAERESIS
|
||||
0x00A9, //COPYRIGHT SIGN
|
||||
0x00AA, //FEMININE ORDINAL INDICATOR
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00AC, //NOT SIGN
|
||||
0x00AD, //SOFT HYPHEN
|
||||
0x00AE, //REGISTERED SIGN
|
||||
0x00AF, //MACRON
|
||||
0x00B0, //DEGREE SIGN
|
||||
0x00B1, //PLUS-MINUS SIGN
|
||||
0x00B2, //SUPERSCRIPT TWO
|
||||
0x00B3, //SUPERSCRIPT THREE
|
||||
0x00B4, //ACUTE ACCENT
|
||||
0x00B5, //MICRO SIGN
|
||||
0x00B6, //PILCROW SIGN
|
||||
0x00B7, //MIDDLE DOT
|
||||
0x00B8, //CEDILLA
|
||||
0x00B9, //SUPERSCRIPT ONE
|
||||
0x00BA, //MASCULINE ORDINAL INDICATOR
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
||||
0x00BF, //INVERTED QUESTION MARK
|
||||
0x00C0, //LATIN CAPITAL LETTER A WITH GRAVE
|
||||
0x00C1, //LATIN CAPITAL LETTER A WITH ACUTE
|
||||
0x00C2, //LATIN CAPITAL LETTER A WITH CIRCUMFLEX
|
||||
0x00C3, //LATIN CAPITAL LETTER A WITH TILDE
|
||||
0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
||||
0x00C5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
||||
0x00C6, //LATIN CAPITAL LETTER AE
|
||||
0x00C7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
||||
0x00C8, //LATIN CAPITAL LETTER E WITH GRAVE
|
||||
0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE
|
||||
0x00CA, //LATIN CAPITAL LETTER E WITH CIRCUMFLEX
|
||||
0x00CB, //LATIN CAPITAL LETTER E WITH DIAERESIS
|
||||
0x00CC, //LATIN CAPITAL LETTER I WITH GRAVE
|
||||
0x00CD, //LATIN CAPITAL LETTER I WITH ACUTE
|
||||
0x00CE, //LATIN CAPITAL LETTER I WITH CIRCUMFLEX
|
||||
0x00CF, //LATIN CAPITAL LETTER I WITH DIAERESIS
|
||||
0x011E, //LATIN CAPITAL LETTER G WITH BREVE
|
||||
0x00D1, //LATIN CAPITAL LETTER N WITH TILDE
|
||||
0x00D2, //LATIN CAPITAL LETTER O WITH GRAVE
|
||||
0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE
|
||||
0x00D4, //LATIN CAPITAL LETTER O WITH CIRCUMFLEX
|
||||
0x00D5, //LATIN CAPITAL LETTER O WITH TILDE
|
||||
0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
0x00D7, //MULTIPLICATION SIGN
|
||||
0x00D8, //LATIN CAPITAL LETTER O WITH STROKE
|
||||
0x00D9, //LATIN CAPITAL LETTER U WITH GRAVE
|
||||
0x00DA, //LATIN CAPITAL LETTER U WITH ACUTE
|
||||
0x00DB, //LATIN CAPITAL LETTER U WITH CIRCUMFLEX
|
||||
0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
||||
0x0130, //LATIN CAPITAL LETTER I WITH DOT ABOVE
|
||||
0x015E, //LATIN CAPITAL LETTER S WITH CEDILLA
|
||||
0x00DF, //LATIN SMALL LETTER SHARP S
|
||||
0x00E0, //LATIN SMALL LETTER A WITH GRAVE
|
||||
0x00E1, //LATIN SMALL LETTER A WITH ACUTE
|
||||
0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
||||
0x00E3, //LATIN SMALL LETTER A WITH TILDE
|
||||
0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS
|
||||
0x00E5, //LATIN SMALL LETTER A WITH RING ABOVE
|
||||
0x00E6, //LATIN SMALL LETTER AE
|
||||
0x00E7, //LATIN SMALL LETTER C WITH CEDILLA
|
||||
0x00E8, //LATIN SMALL LETTER E WITH GRAVE
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
||||
0x00EA, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
||||
0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS
|
||||
0x00EC, //LATIN SMALL LETTER I WITH GRAVE
|
||||
0x00ED, //LATIN SMALL LETTER I WITH ACUTE
|
||||
0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
||||
0x00EF, //LATIN SMALL LETTER I WITH DIAERESIS
|
||||
0x011F, //LATIN SMALL LETTER G WITH BREVE
|
||||
0x00F1, //LATIN SMALL LETTER N WITH TILDE
|
||||
0x00F2, //LATIN SMALL LETTER O WITH GRAVE
|
||||
0x00F3, //LATIN SMALL LETTER O WITH ACUTE
|
||||
0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
||||
0x00F5, //LATIN SMALL LETTER O WITH TILDE
|
||||
0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS
|
||||
0x00F7, //DIVISION SIGN
|
||||
0x00F8, //LATIN SMALL LETTER O WITH STROKE
|
||||
0x00F9, //LATIN SMALL LETTER U WITH GRAVE
|
||||
0x00FA, //LATIN SMALL LETTER U WITH ACUTE
|
||||
0x00FB, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
||||
0x0131, //LATIN SMALL LETTER DOTLESS I
|
||||
0x015F, //LATIN SMALL LETTER S WITH CEDILLA
|
||||
0x00FF, //LATIN SMALL LETTER Y WITH DIAERESIS
|
||||
},
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1255.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1255.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp1255 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000A, //LINE FEED
|
||||
0x000B, //VERTICAL TABULATION
|
||||
0x000C, //FORM FEED
|
||||
0x000D, //CARRIAGE RETURN
|
||||
0x000E, //SHIFT OUT
|
||||
0x000F, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001A, //SUBSTITUTE
|
||||
0x001B, //ESCAPE
|
||||
0x001C, //FILE SEPARATOR
|
||||
0x001D, //GROUP SEPARATOR
|
||||
0x001E, //RECORD SEPARATOR
|
||||
0x001F, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002A, //ASTERISK
|
||||
0x002B, //PLUS SIGN
|
||||
0x002C, //COMMA
|
||||
0x002D, //HYPHEN-MINUS
|
||||
0x002E, //FULL STOP
|
||||
0x002F, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003A, //COLON
|
||||
0x003B, //SEMICOLON
|
||||
0x003C, //LESS-THAN SIGN
|
||||
0x003D, //EQUALS SIGN
|
||||
0x003E, //GREATER-THAN SIGN
|
||||
0x003F, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
||||
0x005B, //LEFT SQUARE BRACKET
|
||||
0x005C, //REVERSE SOLIDUS
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
||||
0x005F, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006A, //LATIN SMALL LETTER J
|
||||
0x006B, //LATIN SMALL LETTER K
|
||||
0x006C, //LATIN SMALL LETTER L
|
||||
0x006D, //LATIN SMALL LETTER M
|
||||
0x006E, //LATIN SMALL LETTER N
|
||||
0x006F, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007A, //LATIN SMALL LETTER Z
|
||||
0x007B, //LEFT CURLY BRACKET
|
||||
0x007C, //VERTICAL LINE
|
||||
0x007D, //RIGHT CURLY BRACKET
|
||||
0x007E, //TILDE
|
||||
0x007F, //DELETE
|
||||
0x20AC, //EURO SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
||||
0x2020, //DAGGER
|
||||
0x2021, //DOUBLE DAGGER
|
||||
0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT
|
||||
0x2030, //PER MILLE SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
||||
0x2022, //BULLET
|
||||
0x2013, //EN DASH
|
||||
0x2014, //EM DASH
|
||||
0x02DC, //SMALL TILDE
|
||||
0x2122, //TRADE MARK SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x00A0, //NO-BREAK SPACE
|
||||
0x00A1, //INVERTED EXCLAMATION MARK
|
||||
0x00A2, //CENT SIGN
|
||||
0x00A3, //POUND SIGN
|
||||
0x20AA, //NEW SHEQEL SIGN
|
||||
0x00A5, //YEN SIGN
|
||||
0x00A6, //BROKEN BAR
|
||||
0x00A7, //SECTION SIGN
|
||||
0x00A8, //DIAERESIS
|
||||
0x00A9, //COPYRIGHT SIGN
|
||||
0x00D7, //MULTIPLICATION SIGN
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00AC, //NOT SIGN
|
||||
0x00AD, //SOFT HYPHEN
|
||||
0x00AE, //REGISTERED SIGN
|
||||
0x00AF, //MACRON
|
||||
0x00B0, //DEGREE SIGN
|
||||
0x00B1, //PLUS-MINUS SIGN
|
||||
0x00B2, //SUPERSCRIPT TWO
|
||||
0x00B3, //SUPERSCRIPT THREE
|
||||
0x00B4, //ACUTE ACCENT
|
||||
0x00B5, //MICRO SIGN
|
||||
0x00B6, //PILCROW SIGN
|
||||
0x00B7, //MIDDLE DOT
|
||||
0x00B8, //CEDILLA
|
||||
0x00B9, //SUPERSCRIPT ONE
|
||||
0x00F7, //DIVISION SIGN
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
||||
0x00BF, //INVERTED QUESTION MARK
|
||||
0x05B0, //HEBREW POINT SHEVA
|
||||
0x05B1, //HEBREW POINT HATAF SEGOL
|
||||
0x05B2, //HEBREW POINT HATAF PATAH
|
||||
0x05B3, //HEBREW POINT HATAF QAMATS
|
||||
0x05B4, //HEBREW POINT HIRIQ
|
||||
0x05B5, //HEBREW POINT TSERE
|
||||
0x05B6, //HEBREW POINT SEGOL
|
||||
0x05B7, //HEBREW POINT PATAH
|
||||
0x05B8, //HEBREW POINT QAMATS
|
||||
0x05B9, //HEBREW POINT HOLAM
|
||||
0xFFFD, //UNDEFINED
|
||||
0x05BB, //HEBREW POINT QUBUTS
|
||||
0x05BC, //HEBREW POINT DAGESH OR MAPIQ
|
||||
0x05BD, //HEBREW POINT METEG
|
||||
0x05BE, //HEBREW PUNCTUATION MAQAF
|
||||
0x05BF, //HEBREW POINT RAFE
|
||||
0x05C0, //HEBREW PUNCTUATION PASEQ
|
||||
0x05C1, //HEBREW POINT SHIN DOT
|
||||
0x05C2, //HEBREW POINT SIN DOT
|
||||
0x05C3, //HEBREW PUNCTUATION SOF PASUQ
|
||||
0x05F0, //HEBREW LIGATURE YIDDISH DOUBLE VAV
|
||||
0x05F1, //HEBREW LIGATURE YIDDISH VAV YOD
|
||||
0x05F2, //HEBREW LIGATURE YIDDISH DOUBLE YOD
|
||||
0x05F3, //HEBREW PUNCTUATION GERESH
|
||||
0x05F4, //HEBREW PUNCTUATION GERSHAYIM
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x05D0, //HEBREW LETTER ALEF
|
||||
0x05D1, //HEBREW LETTER BET
|
||||
0x05D2, //HEBREW LETTER GIMEL
|
||||
0x05D3, //HEBREW LETTER DALET
|
||||
0x05D4, //HEBREW LETTER HE
|
||||
0x05D5, //HEBREW LETTER VAV
|
||||
0x05D6, //HEBREW LETTER ZAYIN
|
||||
0x05D7, //HEBREW LETTER HET
|
||||
0x05D8, //HEBREW LETTER TET
|
||||
0x05D9, //HEBREW LETTER YOD
|
||||
0x05DA, //HEBREW LETTER FINAL KAF
|
||||
0x05DB, //HEBREW LETTER KAF
|
||||
0x05DC, //HEBREW LETTER LAMED
|
||||
0x05DD, //HEBREW LETTER FINAL MEM
|
||||
0x05DE, //HEBREW LETTER MEM
|
||||
0x05DF, //HEBREW LETTER FINAL NUN
|
||||
0x05E0, //HEBREW LETTER NUN
|
||||
0x05E1, //HEBREW LETTER SAMEKH
|
||||
0x05E2, //HEBREW LETTER AYIN
|
||||
0x05E3, //HEBREW LETTER FINAL PE
|
||||
0x05E4, //HEBREW LETTER PE
|
||||
0x05E5, //HEBREW LETTER FINAL TSADI
|
||||
0x05E6, //HEBREW LETTER TSADI
|
||||
0x05E7, //HEBREW LETTER QOF
|
||||
0x05E8, //HEBREW LETTER RESH
|
||||
0x05E9, //HEBREW LETTER SHIN
|
||||
0x05EA, //HEBREW LETTER TAV
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x200E, //LEFT-TO-RIGHT MARK
|
||||
0x200F, //RIGHT-TO-LEFT MARK
|
||||
0xFFFD, //UNDEFINED
|
||||
},
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1256.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1256.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp1256 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000A, //LINE FEED
|
||||
0x000B, //VERTICAL TABULATION
|
||||
0x000C, //FORM FEED
|
||||
0x000D, //CARRIAGE RETURN
|
||||
0x000E, //SHIFT OUT
|
||||
0x000F, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001A, //SUBSTITUTE
|
||||
0x001B, //ESCAPE
|
||||
0x001C, //FILE SEPARATOR
|
||||
0x001D, //GROUP SEPARATOR
|
||||
0x001E, //RECORD SEPARATOR
|
||||
0x001F, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002A, //ASTERISK
|
||||
0x002B, //PLUS SIGN
|
||||
0x002C, //COMMA
|
||||
0x002D, //HYPHEN-MINUS
|
||||
0x002E, //FULL STOP
|
||||
0x002F, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003A, //COLON
|
||||
0x003B, //SEMICOLON
|
||||
0x003C, //LESS-THAN SIGN
|
||||
0x003D, //EQUALS SIGN
|
||||
0x003E, //GREATER-THAN SIGN
|
||||
0x003F, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
||||
0x005B, //LEFT SQUARE BRACKET
|
||||
0x005C, //REVERSE SOLIDUS
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
||||
0x005F, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006A, //LATIN SMALL LETTER J
|
||||
0x006B, //LATIN SMALL LETTER K
|
||||
0x006C, //LATIN SMALL LETTER L
|
||||
0x006D, //LATIN SMALL LETTER M
|
||||
0x006E, //LATIN SMALL LETTER N
|
||||
0x006F, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007A, //LATIN SMALL LETTER Z
|
||||
0x007B, //LEFT CURLY BRACKET
|
||||
0x007C, //VERTICAL LINE
|
||||
0x007D, //RIGHT CURLY BRACKET
|
||||
0x007E, //TILDE
|
||||
0x007F, //DELETE
|
||||
0x20AC, //EURO SIGN
|
||||
0x067E, //ARABIC LETTER PEH
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
||||
0x2020, //DAGGER
|
||||
0x2021, //DOUBLE DAGGER
|
||||
0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT
|
||||
0x2030, //PER MILLE SIGN
|
||||
0x0679, //ARABIC LETTER TTEH
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||
0x0152, //LATIN CAPITAL LIGATURE OE
|
||||
0x0686, //ARABIC LETTER TCHEH
|
||||
0x0698, //ARABIC LETTER JEH
|
||||
0x0688, //ARABIC LETTER DDAL
|
||||
0x06AF, //ARABIC LETTER GAF
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
||||
0x2022, //BULLET
|
||||
0x2013, //EN DASH
|
||||
0x2014, //EM DASH
|
||||
0x06A9, //ARABIC LETTER KEHEH
|
||||
0x2122, //TRADE MARK SIGN
|
||||
0x0691, //ARABIC LETTER RREH
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||
0x0153, //LATIN SMALL LIGATURE OE
|
||||
0x200C, //ZERO WIDTH NON-JOINER
|
||||
0x200D, //ZERO WIDTH JOINER
|
||||
0x06BA, //ARABIC LETTER NOON GHUNNA
|
||||
0x00A0, //NO-BREAK SPACE
|
||||
0x060C, //ARABIC COMMA
|
||||
0x00A2, //CENT SIGN
|
||||
0x00A3, //POUND SIGN
|
||||
0x00A4, //CURRENCY SIGN
|
||||
0x00A5, //YEN SIGN
|
||||
0x00A6, //BROKEN BAR
|
||||
0x00A7, //SECTION SIGN
|
||||
0x00A8, //DIAERESIS
|
||||
0x00A9, //COPYRIGHT SIGN
|
||||
0x06BE, //ARABIC LETTER HEH DOACHASHMEE
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00AC, //NOT SIGN
|
||||
0x00AD, //SOFT HYPHEN
|
||||
0x00AE, //REGISTERED SIGN
|
||||
0x00AF, //MACRON
|
||||
0x00B0, //DEGREE SIGN
|
||||
0x00B1, //PLUS-MINUS SIGN
|
||||
0x00B2, //SUPERSCRIPT TWO
|
||||
0x00B3, //SUPERSCRIPT THREE
|
||||
0x00B4, //ACUTE ACCENT
|
||||
0x00B5, //MICRO SIGN
|
||||
0x00B6, //PILCROW SIGN
|
||||
0x00B7, //MIDDLE DOT
|
||||
0x00B8, //CEDILLA
|
||||
0x00B9, //SUPERSCRIPT ONE
|
||||
0x061B, //ARABIC SEMICOLON
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
||||
0x061F, //ARABIC QUESTION MARK
|
||||
0x06C1, //ARABIC LETTER HEH GOAL
|
||||
0x0621, //ARABIC LETTER HAMZA
|
||||
0x0622, //ARABIC LETTER ALEF WITH MADDA ABOVE
|
||||
0x0623, //ARABIC LETTER ALEF WITH HAMZA ABOVE
|
||||
0x0624, //ARABIC LETTER WAW WITH HAMZA ABOVE
|
||||
0x0625, //ARABIC LETTER ALEF WITH HAMZA BELOW
|
||||
0x0626, //ARABIC LETTER YEH WITH HAMZA ABOVE
|
||||
0x0627, //ARABIC LETTER ALEF
|
||||
0x0628, //ARABIC LETTER BEH
|
||||
0x0629, //ARABIC LETTER TEH MARBUTA
|
||||
0x062A, //ARABIC LETTER TEH
|
||||
0x062B, //ARABIC LETTER THEH
|
||||
0x062C, //ARABIC LETTER JEEM
|
||||
0x062D, //ARABIC LETTER HAH
|
||||
0x062E, //ARABIC LETTER KHAH
|
||||
0x062F, //ARABIC LETTER DAL
|
||||
0x0630, //ARABIC LETTER THAL
|
||||
0x0631, //ARABIC LETTER REH
|
||||
0x0632, //ARABIC LETTER ZAIN
|
||||
0x0633, //ARABIC LETTER SEEN
|
||||
0x0634, //ARABIC LETTER SHEEN
|
||||
0x0635, //ARABIC LETTER SAD
|
||||
0x0636, //ARABIC LETTER DAD
|
||||
0x00D7, //MULTIPLICATION SIGN
|
||||
0x0637, //ARABIC LETTER TAH
|
||||
0x0638, //ARABIC LETTER ZAH
|
||||
0x0639, //ARABIC LETTER AIN
|
||||
0x063A, //ARABIC LETTER GHAIN
|
||||
0x0640, //ARABIC TATWEEL
|
||||
0x0641, //ARABIC LETTER FEH
|
||||
0x0642, //ARABIC LETTER QAF
|
||||
0x0643, //ARABIC LETTER KAF
|
||||
0x00E0, //LATIN SMALL LETTER A WITH GRAVE
|
||||
0x0644, //ARABIC LETTER LAM
|
||||
0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
||||
0x0645, //ARABIC LETTER MEEM
|
||||
0x0646, //ARABIC LETTER NOON
|
||||
0x0647, //ARABIC LETTER HEH
|
||||
0x0648, //ARABIC LETTER WAW
|
||||
0x00E7, //LATIN SMALL LETTER C WITH CEDILLA
|
||||
0x00E8, //LATIN SMALL LETTER E WITH GRAVE
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
||||
0x00EA, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
||||
0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS
|
||||
0x0649, //ARABIC LETTER ALEF MAKSURA
|
||||
0x064A, //ARABIC LETTER YEH
|
||||
0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
||||
0x00EF, //LATIN SMALL LETTER I WITH DIAERESIS
|
||||
0x064B, //ARABIC FATHATAN
|
||||
0x064C, //ARABIC DAMMATAN
|
||||
0x064D, //ARABIC KASRATAN
|
||||
0x064E, //ARABIC FATHA
|
||||
0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
||||
0x064F, //ARABIC DAMMA
|
||||
0x0650, //ARABIC KASRA
|
||||
0x00F7, //DIVISION SIGN
|
||||
0x0651, //ARABIC SHADDA
|
||||
0x00F9, //LATIN SMALL LETTER U WITH GRAVE
|
||||
0x0652, //ARABIC SUKUN
|
||||
0x00FB, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
||||
0x200E, //LEFT-TO-RIGHT MARK
|
||||
0x200F, //RIGHT-TO-LEFT MARK
|
||||
0x06D2, //ARABIC LETTER YEH BARREE
|
||||
},
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1257.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1257.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp1257 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000A, //LINE FEED
|
||||
0x000B, //VERTICAL TABULATION
|
||||
0x000C, //FORM FEED
|
||||
0x000D, //CARRIAGE RETURN
|
||||
0x000E, //SHIFT OUT
|
||||
0x000F, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001A, //SUBSTITUTE
|
||||
0x001B, //ESCAPE
|
||||
0x001C, //FILE SEPARATOR
|
||||
0x001D, //GROUP SEPARATOR
|
||||
0x001E, //RECORD SEPARATOR
|
||||
0x001F, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002A, //ASTERISK
|
||||
0x002B, //PLUS SIGN
|
||||
0x002C, //COMMA
|
||||
0x002D, //HYPHEN-MINUS
|
||||
0x002E, //FULL STOP
|
||||
0x002F, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003A, //COLON
|
||||
0x003B, //SEMICOLON
|
||||
0x003C, //LESS-THAN SIGN
|
||||
0x003D, //EQUALS SIGN
|
||||
0x003E, //GREATER-THAN SIGN
|
||||
0x003F, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
||||
0x005B, //LEFT SQUARE BRACKET
|
||||
0x005C, //REVERSE SOLIDUS
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
||||
0x005F, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006A, //LATIN SMALL LETTER J
|
||||
0x006B, //LATIN SMALL LETTER K
|
||||
0x006C, //LATIN SMALL LETTER L
|
||||
0x006D, //LATIN SMALL LETTER M
|
||||
0x006E, //LATIN SMALL LETTER N
|
||||
0x006F, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007A, //LATIN SMALL LETTER Z
|
||||
0x007B, //LEFT CURLY BRACKET
|
||||
0x007C, //VERTICAL LINE
|
||||
0x007D, //RIGHT CURLY BRACKET
|
||||
0x007E, //TILDE
|
||||
0x007F, //DELETE
|
||||
0x20AC, //EURO SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
||||
0xFFFD, //UNDEFINED
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
||||
0x2020, //DAGGER
|
||||
0x2021, //DOUBLE DAGGER
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2030, //PER MILLE SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||
0xFFFD, //UNDEFINED
|
||||
0x00A8, //DIAERESIS
|
||||
0x02C7, //CARON
|
||||
0x00B8, //CEDILLA
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
||||
0x2022, //BULLET
|
||||
0x2013, //EN DASH
|
||||
0x2014, //EM DASH
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2122, //TRADE MARK SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||
0xFFFD, //UNDEFINED
|
||||
0x00AF, //MACRON
|
||||
0x02DB, //OGONEK
|
||||
0xFFFD, //UNDEFINED
|
||||
0x00A0, //NO-BREAK SPACE
|
||||
0xFFFD, //UNDEFINED
|
||||
0x00A2, //CENT SIGN
|
||||
0x00A3, //POUND SIGN
|
||||
0x00A4, //CURRENCY SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x00A6, //BROKEN BAR
|
||||
0x00A7, //SECTION SIGN
|
||||
0x00D8, //LATIN CAPITAL LETTER O WITH STROKE
|
||||
0x00A9, //COPYRIGHT SIGN
|
||||
0x0156, //LATIN CAPITAL LETTER R WITH CEDILLA
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00AC, //NOT SIGN
|
||||
0x00AD, //SOFT HYPHEN
|
||||
0x00AE, //REGISTERED SIGN
|
||||
0x00C6, //LATIN CAPITAL LETTER AE
|
||||
0x00B0, //DEGREE SIGN
|
||||
0x00B1, //PLUS-MINUS SIGN
|
||||
0x00B2, //SUPERSCRIPT TWO
|
||||
0x00B3, //SUPERSCRIPT THREE
|
||||
0x00B4, //ACUTE ACCENT
|
||||
0x00B5, //MICRO SIGN
|
||||
0x00B6, //PILCROW SIGN
|
||||
0x00B7, //MIDDLE DOT
|
||||
0x00F8, //LATIN SMALL LETTER O WITH STROKE
|
||||
0x00B9, //SUPERSCRIPT ONE
|
||||
0x0157, //LATIN SMALL LETTER R WITH CEDILLA
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
||||
0x00E6, //LATIN SMALL LETTER AE
|
||||
0x0104, //LATIN CAPITAL LETTER A WITH OGONEK
|
||||
0x012E, //LATIN CAPITAL LETTER I WITH OGONEK
|
||||
0x0100, //LATIN CAPITAL LETTER A WITH MACRON
|
||||
0x0106, //LATIN CAPITAL LETTER C WITH ACUTE
|
||||
0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
||||
0x00C5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
||||
0x0118, //LATIN CAPITAL LETTER E WITH OGONEK
|
||||
0x0112, //LATIN CAPITAL LETTER E WITH MACRON
|
||||
0x010C, //LATIN CAPITAL LETTER C WITH CARON
|
||||
0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE
|
||||
0x0179, //LATIN CAPITAL LETTER Z WITH ACUTE
|
||||
0x0116, //LATIN CAPITAL LETTER E WITH DOT ABOVE
|
||||
0x0122, //LATIN CAPITAL LETTER G WITH CEDILLA
|
||||
0x0136, //LATIN CAPITAL LETTER K WITH CEDILLA
|
||||
0x012A, //LATIN CAPITAL LETTER I WITH MACRON
|
||||
0x013B, //LATIN CAPITAL LETTER L WITH CEDILLA
|
||||
0x0160, //LATIN CAPITAL LETTER S WITH CARON
|
||||
0x0143, //LATIN CAPITAL LETTER N WITH ACUTE
|
||||
0x0145, //LATIN CAPITAL LETTER N WITH CEDILLA
|
||||
0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE
|
||||
0x014C, //LATIN CAPITAL LETTER O WITH MACRON
|
||||
0x00D5, //LATIN CAPITAL LETTER O WITH TILDE
|
||||
0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
0x00D7, //MULTIPLICATION SIGN
|
||||
0x0172, //LATIN CAPITAL LETTER U WITH OGONEK
|
||||
0x0141, //LATIN CAPITAL LETTER L WITH STROKE
|
||||
0x015A, //LATIN CAPITAL LETTER S WITH ACUTE
|
||||
0x016A, //LATIN CAPITAL LETTER U WITH MACRON
|
||||
0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
||||
0x017B, //LATIN CAPITAL LETTER Z WITH DOT ABOVE
|
||||
0x017D, //LATIN CAPITAL LETTER Z WITH CARON
|
||||
0x00DF, //LATIN SMALL LETTER SHARP S
|
||||
0x0105, //LATIN SMALL LETTER A WITH OGONEK
|
||||
0x012F, //LATIN SMALL LETTER I WITH OGONEK
|
||||
0x0101, //LATIN SMALL LETTER A WITH MACRON
|
||||
0x0107, //LATIN SMALL LETTER C WITH ACUTE
|
||||
0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS
|
||||
0x00E5, //LATIN SMALL LETTER A WITH RING ABOVE
|
||||
0x0119, //LATIN SMALL LETTER E WITH OGONEK
|
||||
0x0113, //LATIN SMALL LETTER E WITH MACRON
|
||||
0x010D, //LATIN SMALL LETTER C WITH CARON
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
||||
0x017A, //LATIN SMALL LETTER Z WITH ACUTE
|
||||
0x0117, //LATIN SMALL LETTER E WITH DOT ABOVE
|
||||
0x0123, //LATIN SMALL LETTER G WITH CEDILLA
|
||||
0x0137, //LATIN SMALL LETTER K WITH CEDILLA
|
||||
0x012B, //LATIN SMALL LETTER I WITH MACRON
|
||||
0x013C, //LATIN SMALL LETTER L WITH CEDILLA
|
||||
0x0161, //LATIN SMALL LETTER S WITH CARON
|
||||
0x0144, //LATIN SMALL LETTER N WITH ACUTE
|
||||
0x0146, //LATIN SMALL LETTER N WITH CEDILLA
|
||||
0x00F3, //LATIN SMALL LETTER O WITH ACUTE
|
||||
0x014D, //LATIN SMALL LETTER O WITH MACRON
|
||||
0x00F5, //LATIN SMALL LETTER O WITH TILDE
|
||||
0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS
|
||||
0x00F7, //DIVISION SIGN
|
||||
0x0173, //LATIN SMALL LETTER U WITH OGONEK
|
||||
0x0142, //LATIN SMALL LETTER L WITH STROKE
|
||||
0x015B, //LATIN SMALL LETTER S WITH ACUTE
|
||||
0x016B, //LATIN SMALL LETTER U WITH MACRON
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
||||
0x017C, //LATIN SMALL LETTER Z WITH DOT ABOVE
|
||||
0x017E, //LATIN SMALL LETTER Z WITH CARON
|
||||
0x02D9, //DOT ABOVE
|
||||
},
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1258.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1258.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp1258 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000A, //LINE FEED
|
||||
0x000B, //VERTICAL TABULATION
|
||||
0x000C, //FORM FEED
|
||||
0x000D, //CARRIAGE RETURN
|
||||
0x000E, //SHIFT OUT
|
||||
0x000F, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001A, //SUBSTITUTE
|
||||
0x001B, //ESCAPE
|
||||
0x001C, //FILE SEPARATOR
|
||||
0x001D, //GROUP SEPARATOR
|
||||
0x001E, //RECORD SEPARATOR
|
||||
0x001F, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002A, //ASTERISK
|
||||
0x002B, //PLUS SIGN
|
||||
0x002C, //COMMA
|
||||
0x002D, //HYPHEN-MINUS
|
||||
0x002E, //FULL STOP
|
||||
0x002F, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003A, //COLON
|
||||
0x003B, //SEMICOLON
|
||||
0x003C, //LESS-THAN SIGN
|
||||
0x003D, //EQUALS SIGN
|
||||
0x003E, //GREATER-THAN SIGN
|
||||
0x003F, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
||||
0x005B, //LEFT SQUARE BRACKET
|
||||
0x005C, //REVERSE SOLIDUS
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
||||
0x005F, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006A, //LATIN SMALL LETTER J
|
||||
0x006B, //LATIN SMALL LETTER K
|
||||
0x006C, //LATIN SMALL LETTER L
|
||||
0x006D, //LATIN SMALL LETTER M
|
||||
0x006E, //LATIN SMALL LETTER N
|
||||
0x006F, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007A, //LATIN SMALL LETTER Z
|
||||
0x007B, //LEFT CURLY BRACKET
|
||||
0x007C, //VERTICAL LINE
|
||||
0x007D, //RIGHT CURLY BRACKET
|
||||
0x007E, //TILDE
|
||||
0x007F, //DELETE
|
||||
0x20AC, //EURO SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
||||
0x2020, //DAGGER
|
||||
0x2021, //DOUBLE DAGGER
|
||||
0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT
|
||||
0x2030, //PER MILLE SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||
0x0152, //LATIN CAPITAL LIGATURE OE
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
||||
0x2022, //BULLET
|
||||
0x2013, //EN DASH
|
||||
0x2014, //EM DASH
|
||||
0x02DC, //SMALL TILDE
|
||||
0x2122, //TRADE MARK SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||
0x0153, //LATIN SMALL LIGATURE OE
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x0178, //LATIN CAPITAL LETTER Y WITH DIAERESIS
|
||||
0x00A0, //NO-BREAK SPACE
|
||||
0x00A1, //INVERTED EXCLAMATION MARK
|
||||
0x00A2, //CENT SIGN
|
||||
0x00A3, //POUND SIGN
|
||||
0x00A4, //CURRENCY SIGN
|
||||
0x00A5, //YEN SIGN
|
||||
0x00A6, //BROKEN BAR
|
||||
0x00A7, //SECTION SIGN
|
||||
0x00A8, //DIAERESIS
|
||||
0x00A9, //COPYRIGHT SIGN
|
||||
0x00AA, //FEMININE ORDINAL INDICATOR
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00AC, //NOT SIGN
|
||||
0x00AD, //SOFT HYPHEN
|
||||
0x00AE, //REGISTERED SIGN
|
||||
0x00AF, //MACRON
|
||||
0x00B0, //DEGREE SIGN
|
||||
0x00B1, //PLUS-MINUS SIGN
|
||||
0x00B2, //SUPERSCRIPT TWO
|
||||
0x00B3, //SUPERSCRIPT THREE
|
||||
0x00B4, //ACUTE ACCENT
|
||||
0x00B5, //MICRO SIGN
|
||||
0x00B6, //PILCROW SIGN
|
||||
0x00B7, //MIDDLE DOT
|
||||
0x00B8, //CEDILLA
|
||||
0x00B9, //SUPERSCRIPT ONE
|
||||
0x00BA, //MASCULINE ORDINAL INDICATOR
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
||||
0x00BF, //INVERTED QUESTION MARK
|
||||
0x00C0, //LATIN CAPITAL LETTER A WITH GRAVE
|
||||
0x00C1, //LATIN CAPITAL LETTER A WITH ACUTE
|
||||
0x00C2, //LATIN CAPITAL LETTER A WITH CIRCUMFLEX
|
||||
0x0102, //LATIN CAPITAL LETTER A WITH BREVE
|
||||
0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
||||
0x00C5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
||||
0x00C6, //LATIN CAPITAL LETTER AE
|
||||
0x00C7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
||||
0x00C8, //LATIN CAPITAL LETTER E WITH GRAVE
|
||||
0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE
|
||||
0x00CA, //LATIN CAPITAL LETTER E WITH CIRCUMFLEX
|
||||
0x00CB, //LATIN CAPITAL LETTER E WITH DIAERESIS
|
||||
0x0300, //COMBINING GRAVE ACCENT
|
||||
0x00CD, //LATIN CAPITAL LETTER I WITH ACUTE
|
||||
0x00CE, //LATIN CAPITAL LETTER I WITH CIRCUMFLEX
|
||||
0x00CF, //LATIN CAPITAL LETTER I WITH DIAERESIS
|
||||
0x0110, //LATIN CAPITAL LETTER D WITH STROKE
|
||||
0x00D1, //LATIN CAPITAL LETTER N WITH TILDE
|
||||
0x0309, //COMBINING HOOK ABOVE
|
||||
0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE
|
||||
0x00D4, //LATIN CAPITAL LETTER O WITH CIRCUMFLEX
|
||||
0x01A0, //LATIN CAPITAL LETTER O WITH HORN
|
||||
0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
0x00D7, //MULTIPLICATION SIGN
|
||||
0x00D8, //LATIN CAPITAL LETTER O WITH STROKE
|
||||
0x00D9, //LATIN CAPITAL LETTER U WITH GRAVE
|
||||
0x00DA, //LATIN CAPITAL LETTER U WITH ACUTE
|
||||
0x00DB, //LATIN CAPITAL LETTER U WITH CIRCUMFLEX
|
||||
0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
||||
0x01AF, //LATIN CAPITAL LETTER U WITH HORN
|
||||
0x0303, //COMBINING TILDE
|
||||
0x00DF, //LATIN SMALL LETTER SHARP S
|
||||
0x00E0, //LATIN SMALL LETTER A WITH GRAVE
|
||||
0x00E1, //LATIN SMALL LETTER A WITH ACUTE
|
||||
0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
||||
0x0103, //LATIN SMALL LETTER A WITH BREVE
|
||||
0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS
|
||||
0x00E5, //LATIN SMALL LETTER A WITH RING ABOVE
|
||||
0x00E6, //LATIN SMALL LETTER AE
|
||||
0x00E7, //LATIN SMALL LETTER C WITH CEDILLA
|
||||
0x00E8, //LATIN SMALL LETTER E WITH GRAVE
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
||||
0x00EA, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
||||
0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS
|
||||
0x0301, //COMBINING ACUTE ACCENT
|
||||
0x00ED, //LATIN SMALL LETTER I WITH ACUTE
|
||||
0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
||||
0x00EF, //LATIN SMALL LETTER I WITH DIAERESIS
|
||||
0x0111, //LATIN SMALL LETTER D WITH STROKE
|
||||
0x00F1, //LATIN SMALL LETTER N WITH TILDE
|
||||
0x0323, //COMBINING DOT BELOW
|
||||
0x00F3, //LATIN SMALL LETTER O WITH ACUTE
|
||||
0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
||||
0x01A1, //LATIN SMALL LETTER O WITH HORN
|
||||
0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS
|
||||
0x00F7, //DIVISION SIGN
|
||||
0x00F8, //LATIN SMALL LETTER O WITH STROKE
|
||||
0x00F9, //LATIN SMALL LETTER U WITH GRAVE
|
||||
0x00FA, //LATIN SMALL LETTER U WITH ACUTE
|
||||
0x00FB, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
||||
0x01B0, //LATIN SMALL LETTER U WITH HORN
|
||||
0x20AB, //DONG SIGN
|
||||
0x00FF, //LATIN SMALL LETTER Y WITH DIAERESIS
|
||||
},
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp437.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp437.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp437 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000a, //LINE FEED
|
||||
0x000b, //VERTICAL TABULATION
|
||||
0x000c, //FORM FEED
|
||||
0x000d, //CARRIAGE RETURN
|
||||
0x000e, //SHIFT OUT
|
||||
0x000f, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001a, //SUBSTITUTE
|
||||
0x001b, //ESCAPE
|
||||
0x001c, //FILE SEPARATOR
|
||||
0x001d, //GROUP SEPARATOR
|
||||
0x001e, //RECORD SEPARATOR
|
||||
0x001f, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002a, //ASTERISK
|
||||
0x002b, //PLUS SIGN
|
||||
0x002c, //COMMA
|
||||
0x002d, //HYPHEN-MINUS
|
||||
0x002e, //FULL STOP
|
||||
0x002f, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003a, //COLON
|
||||
0x003b, //SEMICOLON
|
||||
0x003c, //LESS-THAN SIGN
|
||||
0x003d, //EQUALS SIGN
|
||||
0x003e, //GREATER-THAN SIGN
|
||||
0x003f, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004a, //LATIN CAPITAL LETTER J
|
||||
0x004b, //LATIN CAPITAL LETTER K
|
||||
0x004c, //LATIN CAPITAL LETTER L
|
||||
0x004d, //LATIN CAPITAL LETTER M
|
||||
0x004e, //LATIN CAPITAL LETTER N
|
||||
0x004f, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005a, //LATIN CAPITAL LETTER Z
|
||||
0x005b, //LEFT SQUARE BRACKET
|
||||
0x005c, //REVERSE SOLIDUS
|
||||
0x005d, //RIGHT SQUARE BRACKET
|
||||
0x005e, //CIRCUMFLEX ACCENT
|
||||
0x005f, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006a, //LATIN SMALL LETTER J
|
||||
0x006b, //LATIN SMALL LETTER K
|
||||
0x006c, //LATIN SMALL LETTER L
|
||||
0x006d, //LATIN SMALL LETTER M
|
||||
0x006e, //LATIN SMALL LETTER N
|
||||
0x006f, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007a, //LATIN SMALL LETTER Z
|
||||
0x007b, //LEFT CURLY BRACKET
|
||||
0x007c, //VERTICAL LINE
|
||||
0x007d, //RIGHT CURLY BRACKET
|
||||
0x007e, //TILDE
|
||||
0x007f, //DELETE
|
||||
0x00c7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
||||
0x00fc, //LATIN SMALL LETTER U WITH DIAERESIS
|
||||
0x00e9, //LATIN SMALL LETTER E WITH ACUTE
|
||||
0x00e2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
||||
0x00e4, //LATIN SMALL LETTER A WITH DIAERESIS
|
||||
0x00e0, //LATIN SMALL LETTER A WITH GRAVE
|
||||
0x00e5, //LATIN SMALL LETTER A WITH RING ABOVE
|
||||
0x00e7, //LATIN SMALL LETTER C WITH CEDILLA
|
||||
0x00ea, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
||||
0x00eb, //LATIN SMALL LETTER E WITH DIAERESIS
|
||||
0x00e8, //LATIN SMALL LETTER E WITH GRAVE
|
||||
0x00ef, //LATIN SMALL LETTER I WITH DIAERESIS
|
||||
0x00ee, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
||||
0x00ec, //LATIN SMALL LETTER I WITH GRAVE
|
||||
0x00c4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
||||
0x00c5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
||||
0x00c9, //LATIN CAPITAL LETTER E WITH ACUTE
|
||||
0x00e6, //LATIN SMALL LIGATURE AE
|
||||
0x00c6, //LATIN CAPITAL LIGATURE AE
|
||||
0x00f4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
||||
0x00f6, //LATIN SMALL LETTER O WITH DIAERESIS
|
||||
0x00f2, //LATIN SMALL LETTER O WITH GRAVE
|
||||
0x00fb, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
||||
0x00f9, //LATIN SMALL LETTER U WITH GRAVE
|
||||
0x00ff, //LATIN SMALL LETTER Y WITH DIAERESIS
|
||||
0x00d6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
0x00dc, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
||||
0x00a2, //CENT SIGN
|
||||
0x00a3, //POUND SIGN
|
||||
0x00a5, //YEN SIGN
|
||||
0x20a7, //PESETA SIGN
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
||||
0x00e1, //LATIN SMALL LETTER A WITH ACUTE
|
||||
0x00ed, //LATIN SMALL LETTER I WITH ACUTE
|
||||
0x00f3, //LATIN SMALL LETTER O WITH ACUTE
|
||||
0x00fa, //LATIN SMALL LETTER U WITH ACUTE
|
||||
0x00f1, //LATIN SMALL LETTER N WITH TILDE
|
||||
0x00d1, //LATIN CAPITAL LETTER N WITH TILDE
|
||||
0x00aa, //FEMININE ORDINAL INDICATOR
|
||||
0x00ba, //MASCULINE ORDINAL INDICATOR
|
||||
0x00bf, //INVERTED QUESTION MARK
|
||||
0x2310, //REVERSED NOT SIGN
|
||||
0x00ac, //NOT SIGN
|
||||
0x00bd, //VULGAR FRACTION ONE HALF
|
||||
0x00bc, //VULGAR FRACTION ONE QUARTER
|
||||
0x00a1, //INVERTED EXCLAMATION MARK
|
||||
0x00ab, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00bb, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x2591, //LIGHT SHADE
|
||||
0x2592, //MEDIUM SHADE
|
||||
0x2593, //DARK SHADE
|
||||
0x2502, //BOX DRAWINGS LIGHT VERTICAL
|
||||
0x2524, //BOX DRAWINGS LIGHT VERTICAL AND LEFT
|
||||
0x2561, //BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
|
||||
0x2562, //BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
|
||||
0x2556, //BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
|
||||
0x2555, //BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
|
||||
0x2563, //BOX DRAWINGS DOUBLE VERTICAL AND LEFT
|
||||
0x2551, //BOX DRAWINGS DOUBLE VERTICAL
|
||||
0x2557, //BOX DRAWINGS DOUBLE DOWN AND LEFT
|
||||
0x255d, //BOX DRAWINGS DOUBLE UP AND LEFT
|
||||
0x255c, //BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
|
||||
0x255b, //BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
|
||||
0x2510, //BOX DRAWINGS LIGHT DOWN AND LEFT
|
||||
0x2514, //BOX DRAWINGS LIGHT UP AND RIGHT
|
||||
0x2534, //BOX DRAWINGS LIGHT UP AND HORIZONTAL
|
||||
0x252c, //BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
|
||||
0x251c, //BOX DRAWINGS LIGHT VERTICAL AND RIGHT
|
||||
0x2500, //BOX DRAWINGS LIGHT HORIZONTAL
|
||||
0x253c, //BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
|
||||
0x255e, //BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
|
||||
0x255f, //BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
|
||||
0x255a, //BOX DRAWINGS DOUBLE UP AND RIGHT
|
||||
0x2554, //BOX DRAWINGS DOUBLE DOWN AND RIGHT
|
||||
0x2569, //BOX DRAWINGS DOUBLE UP AND HORIZONTAL
|
||||
0x2566, //BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
|
||||
0x2560, //BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
|
||||
0x2550, //BOX DRAWINGS DOUBLE HORIZONTAL
|
||||
0x256c, //BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
|
||||
0x2567, //BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
|
||||
0x2568, //BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
|
||||
0x2564, //BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
|
||||
0x2565, //BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
|
||||
0x2559, //BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
|
||||
0x2558, //BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
|
||||
0x2552, //BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
|
||||
0x2553, //BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
|
||||
0x256b, //BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
|
||||
0x256a, //BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
|
||||
0x2518, //BOX DRAWINGS LIGHT UP AND LEFT
|
||||
0x250c, //BOX DRAWINGS LIGHT DOWN AND RIGHT
|
||||
0x2588, //FULL BLOCK
|
||||
0x2584, //LOWER HALF BLOCK
|
||||
0x258c, //LEFT HALF BLOCK
|
||||
0x2590, //RIGHT HALF BLOCK
|
||||
0x2580, //UPPER HALF BLOCK
|
||||
0x03b1, //GREEK SMALL LETTER ALPHA
|
||||
0x00df, //LATIN SMALL LETTER SHARP S
|
||||
0x0393, //GREEK CAPITAL LETTER GAMMA
|
||||
0x03c0, //GREEK SMALL LETTER PI
|
||||
0x03a3, //GREEK CAPITAL LETTER SIGMA
|
||||
0x03c3, //GREEK SMALL LETTER SIGMA
|
||||
0x00b5, //MICRO SIGN
|
||||
0x03c4, //GREEK SMALL LETTER TAU
|
||||
0x03a6, //GREEK CAPITAL LETTER PHI
|
||||
0x0398, //GREEK CAPITAL LETTER THETA
|
||||
0x03a9, //GREEK CAPITAL LETTER OMEGA
|
||||
0x03b4, //GREEK SMALL LETTER DELTA
|
||||
0x221e, //INFINITY
|
||||
0x03c6, //GREEK SMALL LETTER PHI
|
||||
0x03b5, //GREEK SMALL LETTER EPSILON
|
||||
0x2229, //INTERSECTION
|
||||
0x2261, //IDENTICAL TO
|
||||
0x00b1, //PLUS-MINUS SIGN
|
||||
0x2265, //GREATER-THAN OR EQUAL TO
|
||||
0x2264, //LESS-THAN OR EQUAL TO
|
||||
0x2320, //TOP HALF INTEGRAL
|
||||
0x2321, //BOTTOM HALF INTEGRAL
|
||||
0x00f7, //DIVISION SIGN
|
||||
0x2248, //ALMOST EQUAL TO
|
||||
0x00b0, //DEGREE SIGN
|
||||
0x2219, //BULLET OPERATOR
|
||||
0x00b7, //MIDDLE DOT
|
||||
0x221a, //SQUARE ROOT
|
||||
0x207f, //SUPERSCRIPT LATIN SMALL LETTER N
|
||||
0x00b2, //SUPERSCRIPT TWO
|
||||
0x25a0, //BLACK SQUARE
|
||||
0x00a0, //NO-BREAK SPACE
|
||||
},
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp850.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp850.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp850 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000a, //LINE FEED
|
||||
0x000b, //VERTICAL TABULATION
|
||||
0x000c, //FORM FEED
|
||||
0x000d, //CARRIAGE RETURN
|
||||
0x000e, //SHIFT OUT
|
||||
0x000f, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001a, //SUBSTITUTE
|
||||
0x001b, //ESCAPE
|
||||
0x001c, //FILE SEPARATOR
|
||||
0x001d, //GROUP SEPARATOR
|
||||
0x001e, //RECORD SEPARATOR
|
||||
0x001f, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002a, //ASTERISK
|
||||
0x002b, //PLUS SIGN
|
||||
0x002c, //COMMA
|
||||
0x002d, //HYPHEN-MINUS
|
||||
0x002e, //FULL STOP
|
||||
0x002f, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003a, //COLON
|
||||
0x003b, //SEMICOLON
|
||||
0x003c, //LESS-THAN SIGN
|
||||
0x003d, //EQUALS SIGN
|
||||
0x003e, //GREATER-THAN SIGN
|
||||
0x003f, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004a, //LATIN CAPITAL LETTER J
|
||||
0x004b, //LATIN CAPITAL LETTER K
|
||||
0x004c, //LATIN CAPITAL LETTER L
|
||||
0x004d, //LATIN CAPITAL LETTER M
|
||||
0x004e, //LATIN CAPITAL LETTER N
|
||||
0x004f, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005a, //LATIN CAPITAL LETTER Z
|
||||
0x005b, //LEFT SQUARE BRACKET
|
||||
0x005c, //REVERSE SOLIDUS
|
||||
0x005d, //RIGHT SQUARE BRACKET
|
||||
0x005e, //CIRCUMFLEX ACCENT
|
||||
0x005f, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006a, //LATIN SMALL LETTER J
|
||||
0x006b, //LATIN SMALL LETTER K
|
||||
0x006c, //LATIN SMALL LETTER L
|
||||
0x006d, //LATIN SMALL LETTER M
|
||||
0x006e, //LATIN SMALL LETTER N
|
||||
0x006f, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007a, //LATIN SMALL LETTER Z
|
||||
0x007b, //LEFT CURLY BRACKET
|
||||
0x007c, //VERTICAL LINE
|
||||
0x007d, //RIGHT CURLY BRACKET
|
||||
0x007e, //TILDE
|
||||
0x007f, //DELETE
|
||||
0x00c7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
||||
0x00fc, //LATIN SMALL LETTER U WITH DIAERESIS
|
||||
0x00e9, //LATIN SMALL LETTER E WITH ACUTE
|
||||
0x00e2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
||||
0x00e4, //LATIN SMALL LETTER A WITH DIAERESIS
|
||||
0x00e0, //LATIN SMALL LETTER A WITH GRAVE
|
||||
0x00e5, //LATIN SMALL LETTER A WITH RING ABOVE
|
||||
0x00e7, //LATIN SMALL LETTER C WITH CEDILLA
|
||||
0x00ea, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
||||
0x00eb, //LATIN SMALL LETTER E WITH DIAERESIS
|
||||
0x00e8, //LATIN SMALL LETTER E WITH GRAVE
|
||||
0x00ef, //LATIN SMALL LETTER I WITH DIAERESIS
|
||||
0x00ee, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
||||
0x00ec, //LATIN SMALL LETTER I WITH GRAVE
|
||||
0x00c4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
||||
0x00c5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
||||
0x00c9, //LATIN CAPITAL LETTER E WITH ACUTE
|
||||
0x00e6, //LATIN SMALL LIGATURE AE
|
||||
0x00c6, //LATIN CAPITAL LIGATURE AE
|
||||
0x00f4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
||||
0x00f6, //LATIN SMALL LETTER O WITH DIAERESIS
|
||||
0x00f2, //LATIN SMALL LETTER O WITH GRAVE
|
||||
0x00fb, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
||||
0x00f9, //LATIN SMALL LETTER U WITH GRAVE
|
||||
0x00ff, //LATIN SMALL LETTER Y WITH DIAERESIS
|
||||
0x00d6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
0x00dc, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
||||
0x00f8, //LATIN SMALL LETTER O WITH STROKE
|
||||
0x00a3, //POUND SIGN
|
||||
0x00d8, //LATIN CAPITAL LETTER O WITH STROKE
|
||||
0x00d7, //MULTIPLICATION SIGN
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
||||
0x00e1, //LATIN SMALL LETTER A WITH ACUTE
|
||||
0x00ed, //LATIN SMALL LETTER I WITH ACUTE
|
||||
0x00f3, //LATIN SMALL LETTER O WITH ACUTE
|
||||
0x00fa, //LATIN SMALL LETTER U WITH ACUTE
|
||||
0x00f1, //LATIN SMALL LETTER N WITH TILDE
|
||||
0x00d1, //LATIN CAPITAL LETTER N WITH TILDE
|
||||
0x00aa, //FEMININE ORDINAL INDICATOR
|
||||
0x00ba, //MASCULINE ORDINAL INDICATOR
|
||||
0x00bf, //INVERTED QUESTION MARK
|
||||
0x00ae, //REGISTERED SIGN
|
||||
0x00ac, //NOT SIGN
|
||||
0x00bd, //VULGAR FRACTION ONE HALF
|
||||
0x00bc, //VULGAR FRACTION ONE QUARTER
|
||||
0x00a1, //INVERTED EXCLAMATION MARK
|
||||
0x00ab, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x00bb, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x2591, //LIGHT SHADE
|
||||
0x2592, //MEDIUM SHADE
|
||||
0x2593, //DARK SHADE
|
||||
0x2502, //BOX DRAWINGS LIGHT VERTICAL
|
||||
0x2524, //BOX DRAWINGS LIGHT VERTICAL AND LEFT
|
||||
0x00c1, //LATIN CAPITAL LETTER A WITH ACUTE
|
||||
0x00c2, //LATIN CAPITAL LETTER A WITH CIRCUMFLEX
|
||||
0x00c0, //LATIN CAPITAL LETTER A WITH GRAVE
|
||||
0x00a9, //COPYRIGHT SIGN
|
||||
0x2563, //BOX DRAWINGS DOUBLE VERTICAL AND LEFT
|
||||
0x2551, //BOX DRAWINGS DOUBLE VERTICAL
|
||||
0x2557, //BOX DRAWINGS DOUBLE DOWN AND LEFT
|
||||
0x255d, //BOX DRAWINGS DOUBLE UP AND LEFT
|
||||
0x00a2, //CENT SIGN
|
||||
0x00a5, //YEN SIGN
|
||||
0x2510, //BOX DRAWINGS LIGHT DOWN AND LEFT
|
||||
0x2514, //BOX DRAWINGS LIGHT UP AND RIGHT
|
||||
0x2534, //BOX DRAWINGS LIGHT UP AND HORIZONTAL
|
||||
0x252c, //BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
|
||||
0x251c, //BOX DRAWINGS LIGHT VERTICAL AND RIGHT
|
||||
0x2500, //BOX DRAWINGS LIGHT HORIZONTAL
|
||||
0x253c, //BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
|
||||
0x00e3, //LATIN SMALL LETTER A WITH TILDE
|
||||
0x00c3, //LATIN CAPITAL LETTER A WITH TILDE
|
||||
0x255a, //BOX DRAWINGS DOUBLE UP AND RIGHT
|
||||
0x2554, //BOX DRAWINGS DOUBLE DOWN AND RIGHT
|
||||
0x2569, //BOX DRAWINGS DOUBLE UP AND HORIZONTAL
|
||||
0x2566, //BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
|
||||
0x2560, //BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
|
||||
0x2550, //BOX DRAWINGS DOUBLE HORIZONTAL
|
||||
0x256c, //BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
|
||||
0x00a4, //CURRENCY SIGN
|
||||
0x00f0, //LATIN SMALL LETTER ETH
|
||||
0x00d0, //LATIN CAPITAL LETTER ETH
|
||||
0x00ca, //LATIN CAPITAL LETTER E WITH CIRCUMFLEX
|
||||
0x00cb, //LATIN CAPITAL LETTER E WITH DIAERESIS
|
||||
0x00c8, //LATIN CAPITAL LETTER E WITH GRAVE
|
||||
0x0131, //LATIN SMALL LETTER DOTLESS I
|
||||
0x00cd, //LATIN CAPITAL LETTER I WITH ACUTE
|
||||
0x00ce, //LATIN CAPITAL LETTER I WITH CIRCUMFLEX
|
||||
0x00cf, //LATIN CAPITAL LETTER I WITH DIAERESIS
|
||||
0x2518, //BOX DRAWINGS LIGHT UP AND LEFT
|
||||
0x250c, //BOX DRAWINGS LIGHT DOWN AND RIGHT
|
||||
0x2588, //FULL BLOCK
|
||||
0x2584, //LOWER HALF BLOCK
|
||||
0x00a6, //BROKEN BAR
|
||||
0x00cc, //LATIN CAPITAL LETTER I WITH GRAVE
|
||||
0x2580, //UPPER HALF BLOCK
|
||||
0x00d3, //LATIN CAPITAL LETTER O WITH ACUTE
|
||||
0x00df, //LATIN SMALL LETTER SHARP S
|
||||
0x00d4, //LATIN CAPITAL LETTER O WITH CIRCUMFLEX
|
||||
0x00d2, //LATIN CAPITAL LETTER O WITH GRAVE
|
||||
0x00f5, //LATIN SMALL LETTER O WITH TILDE
|
||||
0x00d5, //LATIN CAPITAL LETTER O WITH TILDE
|
||||
0x00b5, //MICRO SIGN
|
||||
0x00fe, //LATIN SMALL LETTER THORN
|
||||
0x00de, //LATIN CAPITAL LETTER THORN
|
||||
0x00da, //LATIN CAPITAL LETTER U WITH ACUTE
|
||||
0x00db, //LATIN CAPITAL LETTER U WITH CIRCUMFLEX
|
||||
0x00d9, //LATIN CAPITAL LETTER U WITH GRAVE
|
||||
0x00fd, //LATIN SMALL LETTER Y WITH ACUTE
|
||||
0x00dd, //LATIN CAPITAL LETTER Y WITH ACUTE
|
||||
0x00af, //MACRON
|
||||
0x00b4, //ACUTE ACCENT
|
||||
0x00ad, //SOFT HYPHEN
|
||||
0x00b1, //PLUS-MINUS SIGN
|
||||
0x2017, //DOUBLE LOW LINE
|
||||
0x00be, //VULGAR FRACTION THREE QUARTERS
|
||||
0x00b6, //PILCROW SIGN
|
||||
0x00a7, //SECTION SIGN
|
||||
0x00f7, //DIVISION SIGN
|
||||
0x00b8, //CEDILLA
|
||||
0x00b0, //DEGREE SIGN
|
||||
0x00a8, //DIAERESIS
|
||||
0x00b7, //MIDDLE DOT
|
||||
0x00b9, //SUPERSCRIPT ONE
|
||||
0x00b3, //SUPERSCRIPT THREE
|
||||
0x00b2, //SUPERSCRIPT TWO
|
||||
0x25a0, //BLACK SQUARE
|
||||
0x00a0, //NO-BREAK SPACE
|
||||
},
|
||||
}
|
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp874.go
generated
vendored
Normal file
262
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp874.go
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
package cp
|
||||
|
||||
var cp874 *charsetMap = &charsetMap{
|
||||
sb: [256]rune{
|
||||
0x0000, //NULL
|
||||
0x0001, //START OF HEADING
|
||||
0x0002, //START OF TEXT
|
||||
0x0003, //END OF TEXT
|
||||
0x0004, //END OF TRANSMISSION
|
||||
0x0005, //ENQUIRY
|
||||
0x0006, //ACKNOWLEDGE
|
||||
0x0007, //BELL
|
||||
0x0008, //BACKSPACE
|
||||
0x0009, //HORIZONTAL TABULATION
|
||||
0x000A, //LINE FEED
|
||||
0x000B, //VERTICAL TABULATION
|
||||
0x000C, //FORM FEED
|
||||
0x000D, //CARRIAGE RETURN
|
||||
0x000E, //SHIFT OUT
|
||||
0x000F, //SHIFT IN
|
||||
0x0010, //DATA LINK ESCAPE
|
||||
0x0011, //DEVICE CONTROL ONE
|
||||
0x0012, //DEVICE CONTROL TWO
|
||||
0x0013, //DEVICE CONTROL THREE
|
||||
0x0014, //DEVICE CONTROL FOUR
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
||||
0x0016, //SYNCHRONOUS IDLE
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
||||
0x0018, //CANCEL
|
||||
0x0019, //END OF MEDIUM
|
||||
0x001A, //SUBSTITUTE
|
||||
0x001B, //ESCAPE
|
||||
0x001C, //FILE SEPARATOR
|
||||
0x001D, //GROUP SEPARATOR
|
||||
0x001E, //RECORD SEPARATOR
|
||||
0x001F, //UNIT SEPARATOR
|
||||
0x0020, //SPACE
|
||||
0x0021, //EXCLAMATION MARK
|
||||
0x0022, //QUOTATION MARK
|
||||
0x0023, //NUMBER SIGN
|
||||
0x0024, //DOLLAR SIGN
|
||||
0x0025, //PERCENT SIGN
|
||||
0x0026, //AMPERSAND
|
||||
0x0027, //APOSTROPHE
|
||||
0x0028, //LEFT PARENTHESIS
|
||||
0x0029, //RIGHT PARENTHESIS
|
||||
0x002A, //ASTERISK
|
||||
0x002B, //PLUS SIGN
|
||||
0x002C, //COMMA
|
||||
0x002D, //HYPHEN-MINUS
|
||||
0x002E, //FULL STOP
|
||||
0x002F, //SOLIDUS
|
||||
0x0030, //DIGIT ZERO
|
||||
0x0031, //DIGIT ONE
|
||||
0x0032, //DIGIT TWO
|
||||
0x0033, //DIGIT THREE
|
||||
0x0034, //DIGIT FOUR
|
||||
0x0035, //DIGIT FIVE
|
||||
0x0036, //DIGIT SIX
|
||||
0x0037, //DIGIT SEVEN
|
||||
0x0038, //DIGIT EIGHT
|
||||
0x0039, //DIGIT NINE
|
||||
0x003A, //COLON
|
||||
0x003B, //SEMICOLON
|
||||
0x003C, //LESS-THAN SIGN
|
||||
0x003D, //EQUALS SIGN
|
||||
0x003E, //GREATER-THAN SIGN
|
||||
0x003F, //QUESTION MARK
|
||||
0x0040, //COMMERCIAL AT
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
||||
0x005B, //LEFT SQUARE BRACKET
|
||||
0x005C, //REVERSE SOLIDUS
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
||||
0x005F, //LOW LINE
|
||||
0x0060, //GRAVE ACCENT
|
||||
0x0061, //LATIN SMALL LETTER A
|
||||
0x0062, //LATIN SMALL LETTER B
|
||||
0x0063, //LATIN SMALL LETTER C
|
||||
0x0064, //LATIN SMALL LETTER D
|
||||
0x0065, //LATIN SMALL LETTER E
|
||||
0x0066, //LATIN SMALL LETTER F
|
||||
0x0067, //LATIN SMALL LETTER G
|
||||
0x0068, //LATIN SMALL LETTER H
|
||||
0x0069, //LATIN SMALL LETTER I
|
||||
0x006A, //LATIN SMALL LETTER J
|
||||
0x006B, //LATIN SMALL LETTER K
|
||||
0x006C, //LATIN SMALL LETTER L
|
||||
0x006D, //LATIN SMALL LETTER M
|
||||
0x006E, //LATIN SMALL LETTER N
|
||||
0x006F, //LATIN SMALL LETTER O
|
||||
0x0070, //LATIN SMALL LETTER P
|
||||
0x0071, //LATIN SMALL LETTER Q
|
||||
0x0072, //LATIN SMALL LETTER R
|
||||
0x0073, //LATIN SMALL LETTER S
|
||||
0x0074, //LATIN SMALL LETTER T
|
||||
0x0075, //LATIN SMALL LETTER U
|
||||
0x0076, //LATIN SMALL LETTER V
|
||||
0x0077, //LATIN SMALL LETTER W
|
||||
0x0078, //LATIN SMALL LETTER X
|
||||
0x0079, //LATIN SMALL LETTER Y
|
||||
0x007A, //LATIN SMALL LETTER Z
|
||||
0x007B, //LEFT CURLY BRACKET
|
||||
0x007C, //VERTICAL LINE
|
||||
0x007D, //RIGHT CURLY BRACKET
|
||||
0x007E, //TILDE
|
||||
0x007F, //DELETE
|
||||
0x20AC, //EURO SIGN
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
||||
0x2022, //BULLET
|
||||
0x2013, //EN DASH
|
||||
0x2014, //EM DASH
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x00A0, //NO-BREAK SPACE
|
||||
0x0E01, //THAI CHARACTER KO KAI
|
||||
0x0E02, //THAI CHARACTER KHO KHAI
|
||||
0x0E03, //THAI CHARACTER KHO KHUAT
|
||||
0x0E04, //THAI CHARACTER KHO KHWAI
|
||||
0x0E05, //THAI CHARACTER KHO KHON
|
||||
0x0E06, //THAI CHARACTER KHO RAKHANG
|
||||
0x0E07, //THAI CHARACTER NGO NGU
|
||||
0x0E08, //THAI CHARACTER CHO CHAN
|
||||
0x0E09, //THAI CHARACTER CHO CHING
|
||||
0x0E0A, //THAI CHARACTER CHO CHANG
|
||||
0x0E0B, //THAI CHARACTER SO SO
|
||||
0x0E0C, //THAI CHARACTER CHO CHOE
|
||||
0x0E0D, //THAI CHARACTER YO YING
|
||||
0x0E0E, //THAI CHARACTER DO CHADA
|
||||
0x0E0F, //THAI CHARACTER TO PATAK
|
||||
0x0E10, //THAI CHARACTER THO THAN
|
||||
0x0E11, //THAI CHARACTER THO NANGMONTHO
|
||||
0x0E12, //THAI CHARACTER THO PHUTHAO
|
||||
0x0E13, //THAI CHARACTER NO NEN
|
||||
0x0E14, //THAI CHARACTER DO DEK
|
||||
0x0E15, //THAI CHARACTER TO TAO
|
||||
0x0E16, //THAI CHARACTER THO THUNG
|
||||
0x0E17, //THAI CHARACTER THO THAHAN
|
||||
0x0E18, //THAI CHARACTER THO THONG
|
||||
0x0E19, //THAI CHARACTER NO NU
|
||||
0x0E1A, //THAI CHARACTER BO BAIMAI
|
||||
0x0E1B, //THAI CHARACTER PO PLA
|
||||
0x0E1C, //THAI CHARACTER PHO PHUNG
|
||||
0x0E1D, //THAI CHARACTER FO FA
|
||||
0x0E1E, //THAI CHARACTER PHO PHAN
|
||||
0x0E1F, //THAI CHARACTER FO FAN
|
||||
0x0E20, //THAI CHARACTER PHO SAMPHAO
|
||||
0x0E21, //THAI CHARACTER MO MA
|
||||
0x0E22, //THAI CHARACTER YO YAK
|
||||
0x0E23, //THAI CHARACTER RO RUA
|
||||
0x0E24, //THAI CHARACTER RU
|
||||
0x0E25, //THAI CHARACTER LO LING
|
||||
0x0E26, //THAI CHARACTER LU
|
||||
0x0E27, //THAI CHARACTER WO WAEN
|
||||
0x0E28, //THAI CHARACTER SO SALA
|
||||
0x0E29, //THAI CHARACTER SO RUSI
|
||||
0x0E2A, //THAI CHARACTER SO SUA
|
||||
0x0E2B, //THAI CHARACTER HO HIP
|
||||
0x0E2C, //THAI CHARACTER LO CHULA
|
||||
0x0E2D, //THAI CHARACTER O ANG
|
||||
0x0E2E, //THAI CHARACTER HO NOKHUK
|
||||
0x0E2F, //THAI CHARACTER PAIYANNOI
|
||||
0x0E30, //THAI CHARACTER SARA A
|
||||
0x0E31, //THAI CHARACTER MAI HAN-AKAT
|
||||
0x0E32, //THAI CHARACTER SARA AA
|
||||
0x0E33, //THAI CHARACTER SARA AM
|
||||
0x0E34, //THAI CHARACTER SARA I
|
||||
0x0E35, //THAI CHARACTER SARA II
|
||||
0x0E36, //THAI CHARACTER SARA UE
|
||||
0x0E37, //THAI CHARACTER SARA UEE
|
||||
0x0E38, //THAI CHARACTER SARA U
|
||||
0x0E39, //THAI CHARACTER SARA UU
|
||||
0x0E3A, //THAI CHARACTER PHINTHU
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0x0E3F, //THAI CURRENCY SYMBOL BAHT
|
||||
0x0E40, //THAI CHARACTER SARA E
|
||||
0x0E41, //THAI CHARACTER SARA AE
|
||||
0x0E42, //THAI CHARACTER SARA O
|
||||
0x0E43, //THAI CHARACTER SARA AI MAIMUAN
|
||||
0x0E44, //THAI CHARACTER SARA AI MAIMALAI
|
||||
0x0E45, //THAI CHARACTER LAKKHANGYAO
|
||||
0x0E46, //THAI CHARACTER MAIYAMOK
|
||||
0x0E47, //THAI CHARACTER MAITAIKHU
|
||||
0x0E48, //THAI CHARACTER MAI EK
|
||||
0x0E49, //THAI CHARACTER MAI THO
|
||||
0x0E4A, //THAI CHARACTER MAI TRI
|
||||
0x0E4B, //THAI CHARACTER MAI CHATTAWA
|
||||
0x0E4C, //THAI CHARACTER THANTHAKHAT
|
||||
0x0E4D, //THAI CHARACTER NIKHAHIT
|
||||
0x0E4E, //THAI CHARACTER YAMAKKAN
|
||||
0x0E4F, //THAI CHARACTER FONGMAN
|
||||
0x0E50, //THAI DIGIT ZERO
|
||||
0x0E51, //THAI DIGIT ONE
|
||||
0x0E52, //THAI DIGIT TWO
|
||||
0x0E53, //THAI DIGIT THREE
|
||||
0x0E54, //THAI DIGIT FOUR
|
||||
0x0E55, //THAI DIGIT FIVE
|
||||
0x0E56, //THAI DIGIT SIX
|
||||
0x0E57, //THAI DIGIT SEVEN
|
||||
0x0E58, //THAI DIGIT EIGHT
|
||||
0x0E59, //THAI DIGIT NINE
|
||||
0x0E5A, //THAI CHARACTER ANGKHANKHU
|
||||
0x0E5B, //THAI CHARACTER KHOMUT
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
0xFFFD, //UNDEFINED
|
||||
},
|
||||
}
|
7988
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp932.go
generated
vendored
Normal file
7988
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp932.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
22055
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp936.go
generated
vendored
Normal file
22055
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp936.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
17312
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp949.go
generated
vendored
Normal file
17312
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp949.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
13767
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp950.go
generated
vendored
Normal file
13767
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp950.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
30
vendor/github.com/denisenkom/go-mssqldb/log.go
generated
vendored
Normal file
30
vendor/github.com/denisenkom/go-mssqldb/log.go
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
type Logger interface {
|
||||
Printf(format string, v ...interface{})
|
||||
Println(v ...interface{})
|
||||
}
|
||||
|
||||
type optionalLogger struct {
|
||||
logger Logger
|
||||
}
|
||||
|
||||
func (o optionalLogger) Printf(format string, v ...interface{}) {
|
||||
if o.logger != nil {
|
||||
o.logger.Printf(format, v...)
|
||||
} else {
|
||||
log.Printf(format, v...)
|
||||
}
|
||||
}
|
||||
|
||||
func (o optionalLogger) Println(v ...interface{}) {
|
||||
if o.logger != nil {
|
||||
o.logger.Println(v...)
|
||||
} else {
|
||||
log.Println(v...)
|
||||
}
|
||||
}
|
973
vendor/github.com/denisenkom/go-mssqldb/mssql.go
generated
vendored
Normal file
973
vendor/github.com/denisenkom/go-mssqldb/mssql.go
generated
vendored
Normal file
|
@ -0,0 +1,973 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"net"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// ReturnStatus may be used to return the return value from a proc.
|
||||
//
|
||||
// var rs mssql.ReturnStatus
|
||||
// _, err := db.Exec("theproc", &rs)
|
||||
// log.Printf("return status = %d", rs)
|
||||
type ReturnStatus int32
|
||||
|
||||
var driverInstance = &Driver{processQueryText: true}
|
||||
var driverInstanceNoProcess = &Driver{processQueryText: false}
|
||||
|
||||
func init() {
|
||||
sql.Register("mssql", driverInstance)
|
||||
sql.Register("sqlserver", driverInstanceNoProcess)
|
||||
createDialer = func(p *connectParams) Dialer {
|
||||
return netDialer{&net.Dialer{KeepAlive: p.keepAlive}}
|
||||
}
|
||||
}
|
||||
|
||||
var createDialer func(p *connectParams) Dialer
|
||||
|
||||
type netDialer struct {
|
||||
nd *net.Dialer
|
||||
}
|
||||
|
||||
func (d netDialer) DialContext(ctx context.Context, network string, addr string) (net.Conn, error) {
|
||||
return d.nd.DialContext(ctx, network, addr)
|
||||
}
|
||||
|
||||
type Driver struct {
|
||||
log optionalLogger
|
||||
|
||||
processQueryText bool
|
||||
}
|
||||
|
||||
// OpenConnector opens a new connector. Useful to dial with a context.
|
||||
func (d *Driver) OpenConnector(dsn string) (*Connector, error) {
|
||||
params, err := parseConnectParams(dsn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Connector{
|
||||
params: params,
|
||||
driver: d,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *Driver) Open(dsn string) (driver.Conn, error) {
|
||||
return d.open(context.Background(), dsn)
|
||||
}
|
||||
|
||||
func SetLogger(logger Logger) {
|
||||
driverInstance.SetLogger(logger)
|
||||
driverInstanceNoProcess.SetLogger(logger)
|
||||
}
|
||||
|
||||
func (d *Driver) SetLogger(logger Logger) {
|
||||
d.log = optionalLogger{logger}
|
||||
}
|
||||
|
||||
// NewConnector creates a new connector from a DSN.
|
||||
// The returned connector may be used with sql.OpenDB.
|
||||
func NewConnector(dsn string) (*Connector, error) {
|
||||
params, err := parseConnectParams(dsn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c := &Connector{
|
||||
params: params,
|
||||
driver: driverInstanceNoProcess,
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Connector holds the parsed DSN and is ready to make a new connection
|
||||
// at any time.
|
||||
//
|
||||
// In the future, settings that cannot be passed through a string DSN
|
||||
// may be set directly on the connector.
|
||||
type Connector struct {
|
||||
params connectParams
|
||||
driver *Driver
|
||||
|
||||
// SessionInitSQL is executed after marking a given session to be reset.
|
||||
// When not present, the next query will still reset the session to the
|
||||
// database defaults.
|
||||
//
|
||||
// When present the connection will immediately mark the session to
|
||||
// be reset, then execute the SessionInitSQL text to setup the session
|
||||
// that may be different from the base database defaults.
|
||||
//
|
||||
// For Example, the application relies on the following defaults
|
||||
// but is not allowed to set them at the database system level.
|
||||
//
|
||||
// SET XACT_ABORT ON;
|
||||
// SET TEXTSIZE -1;
|
||||
// SET ANSI_NULLS ON;
|
||||
// SET LOCK_TIMEOUT 10000;
|
||||
//
|
||||
// SessionInitSQL should not attempt to manually call sp_reset_connection.
|
||||
// This will happen at the TDS layer.
|
||||
//
|
||||
// SessionInitSQL is optional. The session will be reset even if
|
||||
// SessionInitSQL is empty.
|
||||
SessionInitSQL string
|
||||
|
||||
// Dialer sets a custom dialer for all network operations.
|
||||
// If Dialer is not set, normal net dialers are used.
|
||||
Dialer Dialer
|
||||
}
|
||||
|
||||
type Dialer interface {
|
||||
DialContext(ctx context.Context, network string, addr string) (net.Conn, error)
|
||||
}
|
||||
|
||||
func (c *Connector) getDialer(p *connectParams) Dialer {
|
||||
if c != nil && c.Dialer != nil {
|
||||
return c.Dialer
|
||||
}
|
||||
return createDialer(p)
|
||||
}
|
||||
|
||||
type Conn struct {
|
||||
connector *Connector
|
||||
sess *tdsSession
|
||||
transactionCtx context.Context
|
||||
resetSession bool
|
||||
|
||||
processQueryText bool
|
||||
connectionGood bool
|
||||
|
||||
outs map[string]interface{}
|
||||
returnStatus *ReturnStatus
|
||||
}
|
||||
|
||||
func (c *Conn) setReturnStatus(s ReturnStatus) {
|
||||
if c.returnStatus == nil {
|
||||
return
|
||||
}
|
||||
*c.returnStatus = s
|
||||
}
|
||||
|
||||
func (c *Conn) checkBadConn(err error) error {
|
||||
// this is a hack to address Issue #275
|
||||
// we set connectionGood flag to false if
|
||||
// error indicates that connection is not usable
|
||||
// but we return actual error instead of ErrBadConn
|
||||
// this will cause connection to stay in a pool
|
||||
// but next request to this connection will return ErrBadConn
|
||||
|
||||
// it might be possible to revise this hack after
|
||||
// https://github.com/golang/go/issues/20807
|
||||
// is implemented
|
||||
switch err {
|
||||
case nil:
|
||||
return nil
|
||||
case io.EOF:
|
||||
c.connectionGood = false
|
||||
return driver.ErrBadConn
|
||||
case driver.ErrBadConn:
|
||||
// It is an internal programming error if driver.ErrBadConn
|
||||
// is ever passed to this function. driver.ErrBadConn should
|
||||
// only ever be returned in response to a *mssql.Conn.connectionGood == false
|
||||
// check in the external facing API.
|
||||
panic("driver.ErrBadConn in checkBadConn. This should not happen.")
|
||||
}
|
||||
|
||||
switch err.(type) {
|
||||
case net.Error:
|
||||
c.connectionGood = false
|
||||
return err
|
||||
case StreamError:
|
||||
c.connectionGood = false
|
||||
return err
|
||||
default:
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Conn) clearOuts() {
|
||||
c.outs = nil
|
||||
}
|
||||
|
||||
func (c *Conn) simpleProcessResp(ctx context.Context) error {
|
||||
tokchan := make(chan tokenStruct, 5)
|
||||
go processResponse(ctx, c.sess, tokchan, c.outs)
|
||||
c.clearOuts()
|
||||
for tok := range tokchan {
|
||||
switch token := tok.(type) {
|
||||
case doneStruct:
|
||||
if token.isError() {
|
||||
return c.checkBadConn(token.getError())
|
||||
}
|
||||
case error:
|
||||
return c.checkBadConn(token)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Conn) Commit() error {
|
||||
if !c.connectionGood {
|
||||
return driver.ErrBadConn
|
||||
}
|
||||
if err := c.sendCommitRequest(); err != nil {
|
||||
return c.checkBadConn(err)
|
||||
}
|
||||
return c.simpleProcessResp(c.transactionCtx)
|
||||
}
|
||||
|
||||
func (c *Conn) sendCommitRequest() error {
|
||||
headers := []headerStruct{
|
||||
{hdrtype: dataStmHdrTransDescr,
|
||||
data: transDescrHdr{c.sess.tranid, 1}.pack()},
|
||||
}
|
||||
reset := c.resetSession
|
||||
c.resetSession = false
|
||||
if err := sendCommitXact(c.sess.buf, headers, "", 0, 0, "", reset); err != nil {
|
||||
if c.sess.logFlags&logErrors != 0 {
|
||||
c.sess.log.Printf("Failed to send CommitXact with %v", err)
|
||||
}
|
||||
c.connectionGood = false
|
||||
return fmt.Errorf("Faild to send CommitXact: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Conn) Rollback() error {
|
||||
if !c.connectionGood {
|
||||
return driver.ErrBadConn
|
||||
}
|
||||
if err := c.sendRollbackRequest(); err != nil {
|
||||
return c.checkBadConn(err)
|
||||
}
|
||||
return c.simpleProcessResp(c.transactionCtx)
|
||||
}
|
||||
|
||||
func (c *Conn) sendRollbackRequest() error {
|
||||
headers := []headerStruct{
|
||||
{hdrtype: dataStmHdrTransDescr,
|
||||
data: transDescrHdr{c.sess.tranid, 1}.pack()},
|
||||
}
|
||||
reset := c.resetSession
|
||||
c.resetSession = false
|
||||
if err := sendRollbackXact(c.sess.buf, headers, "", 0, 0, "", reset); err != nil {
|
||||
if c.sess.logFlags&logErrors != 0 {
|
||||
c.sess.log.Printf("Failed to send RollbackXact with %v", err)
|
||||
}
|
||||
c.connectionGood = false
|
||||
return fmt.Errorf("Failed to send RollbackXact: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Conn) Begin() (driver.Tx, error) {
|
||||
return c.begin(context.Background(), isolationUseCurrent)
|
||||
}
|
||||
|
||||
func (c *Conn) begin(ctx context.Context, tdsIsolation isoLevel) (tx driver.Tx, err error) {
|
||||
if !c.connectionGood {
|
||||
return nil, driver.ErrBadConn
|
||||
}
|
||||
err = c.sendBeginRequest(ctx, tdsIsolation)
|
||||
if err != nil {
|
||||
return nil, c.checkBadConn(err)
|
||||
}
|
||||
tx, err = c.processBeginResponse(ctx)
|
||||
if err != nil {
|
||||
return nil, c.checkBadConn(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Conn) sendBeginRequest(ctx context.Context, tdsIsolation isoLevel) error {
|
||||
c.transactionCtx = ctx
|
||||
headers := []headerStruct{
|
||||
{hdrtype: dataStmHdrTransDescr,
|
||||
data: transDescrHdr{0, 1}.pack()},
|
||||
}
|
||||
reset := c.resetSession
|
||||
c.resetSession = false
|
||||
if err := sendBeginXact(c.sess.buf, headers, tdsIsolation, "", reset); err != nil {
|
||||
if c.sess.logFlags&logErrors != 0 {
|
||||
c.sess.log.Printf("Failed to send BeginXact with %v", err)
|
||||
}
|
||||
c.connectionGood = false
|
||||
return fmt.Errorf("Failed to send BeginXact: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Conn) processBeginResponse(ctx context.Context) (driver.Tx, error) {
|
||||
if err := c.simpleProcessResp(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// successful BEGINXACT request will return sess.tranid
|
||||
// for started transaction
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (d *Driver) open(ctx context.Context, dsn string) (*Conn, error) {
|
||||
params, err := parseConnectParams(dsn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return d.connect(ctx, nil, params)
|
||||
}
|
||||
|
||||
// connect to the server, using the provided context for dialing only.
|
||||
func (d *Driver) connect(ctx context.Context, c *Connector, params connectParams) (*Conn, error) {
|
||||
sess, err := connect(ctx, c, d.log, params)
|
||||
if err != nil {
|
||||
// main server failed, try fail-over partner
|
||||
if params.failOverPartner == "" {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
params.host = params.failOverPartner
|
||||
if params.failOverPort != 0 {
|
||||
params.port = params.failOverPort
|
||||
}
|
||||
|
||||
sess, err = connect(ctx, c, d.log, params)
|
||||
if err != nil {
|
||||
// fail-over partner also failed, now fail
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
conn := &Conn{
|
||||
connector: c,
|
||||
sess: sess,
|
||||
transactionCtx: context.Background(),
|
||||
processQueryText: d.processQueryText,
|
||||
connectionGood: true,
|
||||
}
|
||||
conn.sess.log = d.log
|
||||
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func (c *Conn) Close() error {
|
||||
return c.sess.buf.transport.Close()
|
||||
}
|
||||
|
||||
type Stmt struct {
|
||||
c *Conn
|
||||
query string
|
||||
paramCount int
|
||||
notifSub *queryNotifSub
|
||||
}
|
||||
|
||||
type queryNotifSub struct {
|
||||
msgText string
|
||||
options string
|
||||
timeout uint32
|
||||
}
|
||||
|
||||
func (c *Conn) Prepare(query string) (driver.Stmt, error) {
|
||||
if !c.connectionGood {
|
||||
return nil, driver.ErrBadConn
|
||||
}
|
||||
if len(query) > 10 && strings.EqualFold(query[:10], "INSERTBULK") {
|
||||
return c.prepareCopyIn(context.Background(), query)
|
||||
}
|
||||
return c.prepareContext(context.Background(), query)
|
||||
}
|
||||
|
||||
func (c *Conn) prepareContext(ctx context.Context, query string) (*Stmt, error) {
|
||||
paramCount := -1
|
||||
if c.processQueryText {
|
||||
query, paramCount = parseParams(query)
|
||||
}
|
||||
return &Stmt{c, query, paramCount, nil}, nil
|
||||
}
|
||||
|
||||
func (s *Stmt) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Stmt) SetQueryNotification(id, options string, timeout time.Duration) {
|
||||
to := uint32(timeout / time.Second)
|
||||
if to < 1 {
|
||||
to = 1
|
||||
}
|
||||
s.notifSub = &queryNotifSub{id, options, to}
|
||||
}
|
||||
|
||||
func (s *Stmt) NumInput() int {
|
||||
return s.paramCount
|
||||
}
|
||||
|
||||
func (s *Stmt) sendQuery(args []namedValue) (err error) {
|
||||
headers := []headerStruct{
|
||||
{hdrtype: dataStmHdrTransDescr,
|
||||
data: transDescrHdr{s.c.sess.tranid, 1}.pack()},
|
||||
}
|
||||
|
||||
if s.notifSub != nil {
|
||||
headers = append(headers,
|
||||
headerStruct{
|
||||
hdrtype: dataStmHdrQueryNotif,
|
||||
data: queryNotifHdr{
|
||||
s.notifSub.msgText,
|
||||
s.notifSub.options,
|
||||
s.notifSub.timeout,
|
||||
}.pack(),
|
||||
})
|
||||
}
|
||||
|
||||
conn := s.c
|
||||
|
||||
// no need to check number of parameters here, it is checked by database/sql
|
||||
if conn.sess.logFlags&logSQL != 0 {
|
||||
conn.sess.log.Println(s.query)
|
||||
}
|
||||
if conn.sess.logFlags&logParams != 0 && len(args) > 0 {
|
||||
for i := 0; i < len(args); i++ {
|
||||
if len(args[i].Name) > 0 {
|
||||
s.c.sess.log.Printf("\t@%s\t%v\n", args[i].Name, args[i].Value)
|
||||
} else {
|
||||
s.c.sess.log.Printf("\t@p%d\t%v\n", i+1, args[i].Value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reset := conn.resetSession
|
||||
conn.resetSession = false
|
||||
if len(args) == 0 {
|
||||
if err = sendSqlBatch72(conn.sess.buf, s.query, headers, reset); err != nil {
|
||||
if conn.sess.logFlags&logErrors != 0 {
|
||||
conn.sess.log.Printf("Failed to send SqlBatch with %v", err)
|
||||
}
|
||||
conn.connectionGood = false
|
||||
return fmt.Errorf("failed to send SQL Batch: %v", err)
|
||||
}
|
||||
} else {
|
||||
proc := sp_ExecuteSql
|
||||
var params []param
|
||||
if isProc(s.query) {
|
||||
proc.name = s.query
|
||||
params, _, err = s.makeRPCParams(args, 0)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
var decls []string
|
||||
params, decls, err = s.makeRPCParams(args, 2)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
params[0] = makeStrParam(s.query)
|
||||
params[1] = makeStrParam(strings.Join(decls, ","))
|
||||
}
|
||||
if err = sendRpc(conn.sess.buf, headers, proc, 0, params, reset); err != nil {
|
||||
if conn.sess.logFlags&logErrors != 0 {
|
||||
conn.sess.log.Printf("Failed to send Rpc with %v", err)
|
||||
}
|
||||
conn.connectionGood = false
|
||||
return fmt.Errorf("Failed to send RPC: %v", err)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// isProc takes the query text in s and determines if it is a stored proc name
|
||||
// or SQL text.
|
||||
func isProc(s string) bool {
|
||||
if len(s) == 0 {
|
||||
return false
|
||||
}
|
||||
const (
|
||||
outside = iota
|
||||
text
|
||||
escaped
|
||||
)
|
||||
st := outside
|
||||
var rn1, rPrev rune
|
||||
for _, r := range s {
|
||||
rPrev = rn1
|
||||
rn1 = r
|
||||
switch r {
|
||||
// No newlines or string sequences.
|
||||
case '\n', '\r', '\'', ';':
|
||||
return false
|
||||
}
|
||||
switch st {
|
||||
case outside:
|
||||
switch {
|
||||
case unicode.IsSpace(r):
|
||||
return false
|
||||
case r == '[':
|
||||
st = escaped
|
||||
continue
|
||||
case r == ']' && rPrev == ']':
|
||||
st = escaped
|
||||
continue
|
||||
case unicode.IsLetter(r):
|
||||
st = text
|
||||
}
|
||||
case text:
|
||||
switch {
|
||||
case r == '.':
|
||||
st = outside
|
||||
continue
|
||||
case unicode.IsSpace(r):
|
||||
return false
|
||||
}
|
||||
case escaped:
|
||||
switch {
|
||||
case r == ']':
|
||||
st = outside
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *Stmt) makeRPCParams(args []namedValue, offset int) ([]param, []string, error) {
|
||||
var err error
|
||||
params := make([]param, len(args)+offset)
|
||||
decls := make([]string, len(args))
|
||||
for i, val := range args {
|
||||
params[i+offset], err = s.makeParam(val.Value)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
var name string
|
||||
if len(val.Name) > 0 {
|
||||
name = "@" + val.Name
|
||||
} else {
|
||||
name = fmt.Sprintf("@p%d", val.Ordinal)
|
||||
}
|
||||
params[i+offset].Name = name
|
||||
decls[i] = fmt.Sprintf("%s %s", name, makeDecl(params[i+offset].ti))
|
||||
}
|
||||
return params, decls, nil
|
||||
}
|
||||
|
||||
type namedValue struct {
|
||||
Name string
|
||||
Ordinal int
|
||||
Value driver.Value
|
||||
}
|
||||
|
||||
func convertOldArgs(args []driver.Value) []namedValue {
|
||||
list := make([]namedValue, len(args))
|
||||
for i, v := range args {
|
||||
list[i] = namedValue{
|
||||
Ordinal: i + 1,
|
||||
Value: v,
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
func (s *Stmt) Query(args []driver.Value) (driver.Rows, error) {
|
||||
return s.queryContext(context.Background(), convertOldArgs(args))
|
||||
}
|
||||
|
||||
func (s *Stmt) queryContext(ctx context.Context, args []namedValue) (rows driver.Rows, err error) {
|
||||
if !s.c.connectionGood {
|
||||
return nil, driver.ErrBadConn
|
||||
}
|
||||
if err = s.sendQuery(args); err != nil {
|
||||
return nil, s.c.checkBadConn(err)
|
||||
}
|
||||
return s.processQueryResponse(ctx)
|
||||
}
|
||||
|
||||
func (s *Stmt) processQueryResponse(ctx context.Context) (res driver.Rows, err error) {
|
||||
tokchan := make(chan tokenStruct, 5)
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
go processResponse(ctx, s.c.sess, tokchan, s.c.outs)
|
||||
s.c.clearOuts()
|
||||
// process metadata
|
||||
var cols []columnStruct
|
||||
loop:
|
||||
for tok := range tokchan {
|
||||
switch token := tok.(type) {
|
||||
// By ignoring DONE token we effectively
|
||||
// skip empty result-sets.
|
||||
// This improves results in queries like that:
|
||||
// set nocount on; select 1
|
||||
// see TestIgnoreEmptyResults test
|
||||
//case doneStruct:
|
||||
//break loop
|
||||
case []columnStruct:
|
||||
cols = token
|
||||
break loop
|
||||
case doneStruct:
|
||||
if token.isError() {
|
||||
return nil, s.c.checkBadConn(token.getError())
|
||||
}
|
||||
case ReturnStatus:
|
||||
s.c.setReturnStatus(token)
|
||||
case error:
|
||||
return nil, s.c.checkBadConn(token)
|
||||
}
|
||||
}
|
||||
res = &Rows{stmt: s, tokchan: tokchan, cols: cols, cancel: cancel}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Stmt) Exec(args []driver.Value) (driver.Result, error) {
|
||||
return s.exec(context.Background(), convertOldArgs(args))
|
||||
}
|
||||
|
||||
func (s *Stmt) exec(ctx context.Context, args []namedValue) (res driver.Result, err error) {
|
||||
if !s.c.connectionGood {
|
||||
return nil, driver.ErrBadConn
|
||||
}
|
||||
if err = s.sendQuery(args); err != nil {
|
||||
return nil, s.c.checkBadConn(err)
|
||||
}
|
||||
if res, err = s.processExec(ctx); err != nil {
|
||||
return nil, s.c.checkBadConn(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Stmt) processExec(ctx context.Context) (res driver.Result, err error) {
|
||||
tokchan := make(chan tokenStruct, 5)
|
||||
go processResponse(ctx, s.c.sess, tokchan, s.c.outs)
|
||||
s.c.clearOuts()
|
||||
var rowCount int64
|
||||
for token := range tokchan {
|
||||
switch token := token.(type) {
|
||||
case doneInProcStruct:
|
||||
if token.Status&doneCount != 0 {
|
||||
rowCount += int64(token.RowCount)
|
||||
}
|
||||
case doneStruct:
|
||||
if token.Status&doneCount != 0 {
|
||||
rowCount += int64(token.RowCount)
|
||||
}
|
||||
if token.isError() {
|
||||
return nil, token.getError()
|
||||
}
|
||||
case ReturnStatus:
|
||||
s.c.setReturnStatus(token)
|
||||
case error:
|
||||
return nil, token
|
||||
}
|
||||
}
|
||||
return &Result{s.c, rowCount}, nil
|
||||
}
|
||||
|
||||
type Rows struct {
|
||||
stmt *Stmt
|
||||
cols []columnStruct
|
||||
tokchan chan tokenStruct
|
||||
|
||||
nextCols []columnStruct
|
||||
|
||||
cancel func()
|
||||
}
|
||||
|
||||
func (rc *Rows) Close() error {
|
||||
rc.cancel()
|
||||
for _ = range rc.tokchan {
|
||||
}
|
||||
rc.tokchan = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rc *Rows) Columns() (res []string) {
|
||||
res = make([]string, len(rc.cols))
|
||||
for i, col := range rc.cols {
|
||||
res[i] = col.ColName
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (rc *Rows) Next(dest []driver.Value) error {
|
||||
if !rc.stmt.c.connectionGood {
|
||||
return driver.ErrBadConn
|
||||
}
|
||||
if rc.nextCols != nil {
|
||||
return io.EOF
|
||||
}
|
||||
for tok := range rc.tokchan {
|
||||
switch tokdata := tok.(type) {
|
||||
case []columnStruct:
|
||||
rc.nextCols = tokdata
|
||||
return io.EOF
|
||||
case []interface{}:
|
||||
for i := range dest {
|
||||
dest[i] = tokdata[i]
|
||||
}
|
||||
return nil
|
||||
case doneStruct:
|
||||
if tokdata.isError() {
|
||||
return rc.stmt.c.checkBadConn(tokdata.getError())
|
||||
}
|
||||
case error:
|
||||
return rc.stmt.c.checkBadConn(tokdata)
|
||||
}
|
||||
}
|
||||
return io.EOF
|
||||
}
|
||||
|
||||
func (rc *Rows) HasNextResultSet() bool {
|
||||
return rc.nextCols != nil
|
||||
}
|
||||
|
||||
func (rc *Rows) NextResultSet() error {
|
||||
rc.cols = rc.nextCols
|
||||
rc.nextCols = nil
|
||||
if rc.cols == nil {
|
||||
return io.EOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// It should return
|
||||
// the value type that can be used to scan types into. For example, the database
|
||||
// column type "bigint" this should return "reflect.TypeOf(int64(0))".
|
||||
func (r *Rows) ColumnTypeScanType(index int) reflect.Type {
|
||||
return makeGoLangScanType(r.cols[index].ti)
|
||||
}
|
||||
|
||||
// RowsColumnTypeDatabaseTypeName may be implemented by Rows. It should return the
|
||||
// database system type name without the length. Type names should be uppercase.
|
||||
// Examples of returned types: "VARCHAR", "NVARCHAR", "VARCHAR2", "CHAR", "TEXT",
|
||||
// "DECIMAL", "SMALLINT", "INT", "BIGINT", "BOOL", "[]BIGINT", "JSONB", "XML",
|
||||
// "TIMESTAMP".
|
||||
func (r *Rows) ColumnTypeDatabaseTypeName(index int) string {
|
||||
return makeGoLangTypeName(r.cols[index].ti)
|
||||
}
|
||||
|
||||
// RowsColumnTypeLength may be implemented by Rows. It should return the length
|
||||
// of the column type if the column is a variable length type. If the column is
|
||||
// not a variable length type ok should return false.
|
||||
// If length is not limited other than system limits, it should return math.MaxInt64.
|
||||
// The following are examples of returned values for various types:
|
||||
// TEXT (math.MaxInt64, true)
|
||||
// varchar(10) (10, true)
|
||||
// nvarchar(10) (10, true)
|
||||
// decimal (0, false)
|
||||
// int (0, false)
|
||||
// bytea(30) (30, true)
|
||||
func (r *Rows) ColumnTypeLength(index int) (int64, bool) {
|
||||
return makeGoLangTypeLength(r.cols[index].ti)
|
||||
}
|
||||
|
||||
// It should return
|
||||
// the precision and scale for decimal types. If not applicable, ok should be false.
|
||||
// The following are examples of returned values for various types:
|
||||
// decimal(38, 4) (38, 4, true)
|
||||
// int (0, 0, false)
|
||||
// decimal (math.MaxInt64, math.MaxInt64, true)
|
||||
func (r *Rows) ColumnTypePrecisionScale(index int) (int64, int64, bool) {
|
||||
return makeGoLangTypePrecisionScale(r.cols[index].ti)
|
||||
}
|
||||
|
||||
// The nullable value should
|
||||
// be true if it is known the column may be null, or false if the column is known
|
||||
// to be not nullable.
|
||||
// If the column nullability is unknown, ok should be false.
|
||||
func (r *Rows) ColumnTypeNullable(index int) (nullable, ok bool) {
|
||||
nullable = r.cols[index].Flags&colFlagNullable != 0
|
||||
ok = true
|
||||
return
|
||||
}
|
||||
|
||||
func makeStrParam(val string) (res param) {
|
||||
res.ti.TypeId = typeNVarChar
|
||||
res.buffer = str2ucs2(val)
|
||||
res.ti.Size = len(res.buffer)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Stmt) makeParam(val driver.Value) (res param, err error) {
|
||||
if val == nil {
|
||||
res.ti.TypeId = typeNull
|
||||
res.buffer = nil
|
||||
res.ti.Size = 0
|
||||
return
|
||||
}
|
||||
switch val := val.(type) {
|
||||
case int64:
|
||||
res.ti.TypeId = typeIntN
|
||||
res.buffer = make([]byte, 8)
|
||||
res.ti.Size = 8
|
||||
binary.LittleEndian.PutUint64(res.buffer, uint64(val))
|
||||
case sql.NullInt64:
|
||||
// only null values should be getting here
|
||||
res.ti.TypeId = typeIntN
|
||||
res.ti.Size = 8
|
||||
res.buffer = []byte{}
|
||||
|
||||
case float64:
|
||||
res.ti.TypeId = typeFltN
|
||||
res.ti.Size = 8
|
||||
res.buffer = make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(res.buffer, math.Float64bits(val))
|
||||
case sql.NullFloat64:
|
||||
// only null values should be getting here
|
||||
res.ti.TypeId = typeFltN
|
||||
res.ti.Size = 8
|
||||
res.buffer = []byte{}
|
||||
|
||||
case []byte:
|
||||
res.ti.TypeId = typeBigVarBin
|
||||
res.ti.Size = len(val)
|
||||
res.buffer = val
|
||||
case string:
|
||||
res = makeStrParam(val)
|
||||
case sql.NullString:
|
||||
// only null values should be getting here
|
||||
res.ti.TypeId = typeNVarChar
|
||||
res.buffer = nil
|
||||
res.ti.Size = 8000
|
||||
case bool:
|
||||
res.ti.TypeId = typeBitN
|
||||
res.ti.Size = 1
|
||||
res.buffer = make([]byte, 1)
|
||||
if val {
|
||||
res.buffer[0] = 1
|
||||
}
|
||||
case sql.NullBool:
|
||||
// only null values should be getting here
|
||||
res.ti.TypeId = typeBitN
|
||||
res.ti.Size = 1
|
||||
res.buffer = []byte{}
|
||||
|
||||
case time.Time:
|
||||
if s.c.sess.loginAck.TDSVersion >= verTDS73 {
|
||||
res.ti.TypeId = typeDateTimeOffsetN
|
||||
res.ti.Scale = 7
|
||||
res.buffer = encodeDateTimeOffset(val, int(res.ti.Scale))
|
||||
res.ti.Size = len(res.buffer)
|
||||
} else {
|
||||
res.ti.TypeId = typeDateTimeN
|
||||
res.buffer = encodeDateTime(val)
|
||||
res.ti.Size = len(res.buffer)
|
||||
}
|
||||
default:
|
||||
return s.makeParamExtra(val)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
c *Conn
|
||||
rowsAffected int64
|
||||
}
|
||||
|
||||
func (r *Result) RowsAffected() (int64, error) {
|
||||
return r.rowsAffected, nil
|
||||
}
|
||||
|
||||
func (r *Result) LastInsertId() (int64, error) {
|
||||
s, err := r.c.Prepare("select cast(@@identity as bigint)")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer s.Close()
|
||||
rows, err := s.Query(nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer rows.Close()
|
||||
dest := make([]driver.Value, 1)
|
||||
err = rows.Next(dest)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if dest[0] == nil {
|
||||
return -1, errors.New("There is no generated identity value")
|
||||
}
|
||||
lastInsertId := dest[0].(int64)
|
||||
return lastInsertId, nil
|
||||
}
|
||||
|
||||
var _ driver.Pinger = &Conn{}
|
||||
|
||||
// Ping is used to check if the remote server is available and satisfies the Pinger interface.
|
||||
func (c *Conn) Ping(ctx context.Context) error {
|
||||
if !c.connectionGood {
|
||||
return driver.ErrBadConn
|
||||
}
|
||||
stmt := &Stmt{c, `select 1;`, 0, nil}
|
||||
_, err := stmt.ExecContext(ctx, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
var _ driver.ConnBeginTx = &Conn{}
|
||||
|
||||
// BeginTx satisfies ConnBeginTx.
|
||||
func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
|
||||
if !c.connectionGood {
|
||||
return nil, driver.ErrBadConn
|
||||
}
|
||||
if opts.ReadOnly {
|
||||
return nil, errors.New("Read-only transactions are not supported")
|
||||
}
|
||||
|
||||
var tdsIsolation isoLevel
|
||||
switch sql.IsolationLevel(opts.Isolation) {
|
||||
case sql.LevelDefault:
|
||||
tdsIsolation = isolationUseCurrent
|
||||
case sql.LevelReadUncommitted:
|
||||
tdsIsolation = isolationReadUncommited
|
||||
case sql.LevelReadCommitted:
|
||||
tdsIsolation = isolationReadCommited
|
||||
case sql.LevelWriteCommitted:
|
||||
return nil, errors.New("LevelWriteCommitted isolation level is not supported")
|
||||
case sql.LevelRepeatableRead:
|
||||
tdsIsolation = isolationRepeatableRead
|
||||
case sql.LevelSnapshot:
|
||||
tdsIsolation = isolationSnapshot
|
||||
case sql.LevelSerializable:
|
||||
tdsIsolation = isolationSerializable
|
||||
case sql.LevelLinearizable:
|
||||
return nil, errors.New("LevelLinearizable isolation level is not supported")
|
||||
default:
|
||||
return nil, errors.New("Isolation level is not supported or unknown")
|
||||
}
|
||||
return c.begin(ctx, tdsIsolation)
|
||||
}
|
||||
|
||||
func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
|
||||
if !c.connectionGood {
|
||||
return nil, driver.ErrBadConn
|
||||
}
|
||||
if len(query) > 10 && strings.EqualFold(query[:10], "INSERTBULK") {
|
||||
return c.prepareCopyIn(ctx, query)
|
||||
}
|
||||
|
||||
return c.prepareContext(ctx, query)
|
||||
}
|
||||
|
||||
func (s *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
|
||||
if !s.c.connectionGood {
|
||||
return nil, driver.ErrBadConn
|
||||
}
|
||||
list := make([]namedValue, len(args))
|
||||
for i, nv := range args {
|
||||
list[i] = namedValue(nv)
|
||||
}
|
||||
return s.queryContext(ctx, list)
|
||||
}
|
||||
|
||||
func (s *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
|
||||
if !s.c.connectionGood {
|
||||
return nil, driver.ErrBadConn
|
||||
}
|
||||
list := make([]namedValue, len(args))
|
||||
for i, nv := range args {
|
||||
list[i] = namedValue(nv)
|
||||
}
|
||||
return s.exec(ctx, list)
|
||||
}
|
47
vendor/github.com/denisenkom/go-mssqldb/mssql_go110.go
generated
vendored
Normal file
47
vendor/github.com/denisenkom/go-mssqldb/mssql_go110.go
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// +build go1.10
|
||||
|
||||
package mssql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
)
|
||||
|
||||
var _ driver.Connector = &Connector{}
|
||||
var _ driver.SessionResetter = &Conn{}
|
||||
|
||||
func (c *Conn) ResetSession(ctx context.Context) error {
|
||||
if !c.connectionGood {
|
||||
return driver.ErrBadConn
|
||||
}
|
||||
c.resetSession = true
|
||||
|
||||
if c.connector == nil || len(c.connector.SessionInitSQL) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
s, err := c.prepareContext(ctx, c.connector.SessionInitSQL)
|
||||
if err != nil {
|
||||
return driver.ErrBadConn
|
||||
}
|
||||
_, err = s.exec(ctx, nil)
|
||||
if err != nil {
|
||||
return driver.ErrBadConn
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Connect to the server and return a TDS connection.
|
||||
func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) {
|
||||
conn, err := c.driver.connect(ctx, c, c.params)
|
||||
if err == nil {
|
||||
err = conn.ResetSession(ctx)
|
||||
}
|
||||
return conn, err
|
||||
}
|
||||
|
||||
// Driver underlying the Connector.
|
||||
func (c *Connector) Driver() driver.Driver {
|
||||
return c.driver
|
||||
}
|
184
vendor/github.com/denisenkom/go-mssqldb/mssql_go19.go
generated
vendored
Normal file
184
vendor/github.com/denisenkom/go-mssqldb/mssql_go19.go
generated
vendored
Normal file
|
@ -0,0 +1,184 @@
|
|||
// +build go1.9
|
||||
|
||||
package mssql
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
// "github.com/cockroachdb/apd"
|
||||
"cloud.google.com/go/civil"
|
||||
)
|
||||
|
||||
// Type alias provided for compatibility.
|
||||
|
||||
type MssqlDriver = Driver // Deprecated: users should transition to the new name when possible.
|
||||
type MssqlBulk = Bulk // Deprecated: users should transition to the new name when possible.
|
||||
type MssqlBulkOptions = BulkOptions // Deprecated: users should transition to the new name when possible.
|
||||
type MssqlConn = Conn // Deprecated: users should transition to the new name when possible.
|
||||
type MssqlResult = Result // Deprecated: users should transition to the new name when possible.
|
||||
type MssqlRows = Rows // Deprecated: users should transition to the new name when possible.
|
||||
type MssqlStmt = Stmt // Deprecated: users should transition to the new name when possible.
|
||||
|
||||
var _ driver.NamedValueChecker = &Conn{}
|
||||
|
||||
// VarChar parameter types.
|
||||
type VarChar string
|
||||
|
||||
type NVarCharMax string
|
||||
type VarCharMax string
|
||||
|
||||
// DateTime1 encodes parameters to original DateTime SQL types.
|
||||
type DateTime1 time.Time
|
||||
|
||||
// DateTimeOffset encodes parameters to DateTimeOffset, preserving the UTC offset.
|
||||
type DateTimeOffset time.Time
|
||||
|
||||
func convertInputParameter(val interface{}) (interface{}, error) {
|
||||
switch v := val.(type) {
|
||||
case VarChar:
|
||||
return val, nil
|
||||
case NVarCharMax:
|
||||
return val, nil
|
||||
case VarCharMax:
|
||||
return val, nil
|
||||
case DateTime1:
|
||||
return val, nil
|
||||
case DateTimeOffset:
|
||||
return val, nil
|
||||
case civil.Date:
|
||||
return val, nil
|
||||
case civil.DateTime:
|
||||
return val, nil
|
||||
case civil.Time:
|
||||
return val, nil
|
||||
// case *apd.Decimal:
|
||||
// return nil
|
||||
default:
|
||||
return driver.DefaultParameterConverter.ConvertValue(v)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Conn) CheckNamedValue(nv *driver.NamedValue) error {
|
||||
switch v := nv.Value.(type) {
|
||||
case sql.Out:
|
||||
if c.outs == nil {
|
||||
c.outs = make(map[string]interface{})
|
||||
}
|
||||
c.outs[nv.Name] = v.Dest
|
||||
|
||||
if v.Dest == nil {
|
||||
return errors.New("destination is a nil pointer")
|
||||
}
|
||||
|
||||
dest_info := reflect.ValueOf(v.Dest)
|
||||
if dest_info.Kind() != reflect.Ptr {
|
||||
return errors.New("destination not a pointer")
|
||||
}
|
||||
|
||||
if dest_info.IsNil() {
|
||||
return errors.New("destination is a nil pointer")
|
||||
}
|
||||
|
||||
pointed_value := reflect.Indirect(dest_info)
|
||||
|
||||
// don't allow pointer to a pointer, only pointer to a value can be handled
|
||||
// correctly
|
||||
if pointed_value.Kind() == reflect.Ptr {
|
||||
return errors.New("destination is a pointer to a pointer")
|
||||
}
|
||||
|
||||
// Unwrap the Out value and check the inner value.
|
||||
val := pointed_value.Interface()
|
||||
if val == nil {
|
||||
return errors.New("MSSQL does not allow NULL value without type for OUTPUT parameters")
|
||||
}
|
||||
conv, err := convertInputParameter(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if conv == nil {
|
||||
// if we replace with nil we would lose type information
|
||||
nv.Value = sql.Out{Dest: val}
|
||||
} else {
|
||||
nv.Value = sql.Out{Dest: conv}
|
||||
}
|
||||
return nil
|
||||
case *ReturnStatus:
|
||||
*v = 0 // By default the return value should be zero.
|
||||
c.returnStatus = v
|
||||
return driver.ErrRemoveArgument
|
||||
case TVPType:
|
||||
return nil
|
||||
default:
|
||||
var err error
|
||||
nv.Value, err = convertInputParameter(nv.Value)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Stmt) makeParamExtra(val driver.Value) (res param, err error) {
|
||||
switch val := val.(type) {
|
||||
case VarChar:
|
||||
res.ti.TypeId = typeBigVarChar
|
||||
res.buffer = []byte(val)
|
||||
res.ti.Size = len(res.buffer)
|
||||
case VarCharMax:
|
||||
res.ti.TypeId = typeBigVarChar
|
||||
res.buffer = []byte(val)
|
||||
res.ti.Size = 0 // currently zero forces varchar(max)
|
||||
case NVarCharMax:
|
||||
res.ti.TypeId = typeNVarChar
|
||||
res.buffer = str2ucs2(string(val))
|
||||
res.ti.Size = 0 // currently zero forces nvarchar(max)
|
||||
case DateTime1:
|
||||
t := time.Time(val)
|
||||
res.ti.TypeId = typeDateTimeN
|
||||
res.buffer = encodeDateTime(t)
|
||||
res.ti.Size = len(res.buffer)
|
||||
case DateTimeOffset:
|
||||
res.ti.TypeId = typeDateTimeOffsetN
|
||||
res.ti.Scale = 7
|
||||
res.buffer = encodeDateTimeOffset(time.Time(val), int(res.ti.Scale))
|
||||
res.ti.Size = len(res.buffer)
|
||||
case civil.Date:
|
||||
res.ti.TypeId = typeDateN
|
||||
res.buffer = encodeDate(val.In(time.UTC))
|
||||
res.ti.Size = len(res.buffer)
|
||||
case civil.DateTime:
|
||||
res.ti.TypeId = typeDateTime2N
|
||||
res.ti.Scale = 7
|
||||
res.buffer = encodeDateTime2(val.In(time.UTC), int(res.ti.Scale))
|
||||
res.ti.Size = len(res.buffer)
|
||||
case civil.Time:
|
||||
res.ti.TypeId = typeTimeN
|
||||
res.ti.Scale = 7
|
||||
res.buffer = encodeTime(val.Hour, val.Minute, val.Second, val.Nanosecond, int(res.ti.Scale))
|
||||
res.ti.Size = len(res.buffer)
|
||||
case sql.Out:
|
||||
res, err = s.makeParam(val.Dest)
|
||||
res.Flags = fByRevValue
|
||||
case TVPType:
|
||||
err = val.check()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res.ti.UdtInfo.TypeName = val.TVPTypeName
|
||||
res.ti.UdtInfo.SchemaName = val.TVPScheme
|
||||
res.ti.TypeId = typeTvp
|
||||
res.buffer, err = val.encode()
|
||||
res.ti.Size = len(res.buffer)
|
||||
|
||||
default:
|
||||
err = fmt.Errorf("mssql: unknown type for %T", val)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func scanIntoOut(name string, fromServer, scanInto interface{}) error {
|
||||
return convertAssign(scanInto, fromServer)
|
||||
}
|
16
vendor/github.com/denisenkom/go-mssqldb/mssql_go19pre.go
generated
vendored
Normal file
16
vendor/github.com/denisenkom/go-mssqldb/mssql_go19pre.go
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// +build !go1.9
|
||||
|
||||
package mssql
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func (s *Stmt) makeParamExtra(val driver.Value) (param, error) {
|
||||
return param{}, fmt.Errorf("mssql: unknown type for %T", val)
|
||||
}
|
||||
|
||||
func scanIntoOut(name string, fromServer, scanInto interface{}) error {
|
||||
return fmt.Errorf("mssql: unsupported OUTPUT type, use a newer Go version")
|
||||
}
|
103
vendor/github.com/denisenkom/go-mssqldb/net.go
generated
vendored
Normal file
103
vendor/github.com/denisenkom/go-mssqldb/net.go
generated
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type timeoutConn struct {
|
||||
c net.Conn
|
||||
timeout time.Duration
|
||||
buf *tdsBuffer
|
||||
packetPending bool
|
||||
continueRead bool
|
||||
}
|
||||
|
||||
func newTimeoutConn(conn net.Conn, timeout time.Duration) *timeoutConn {
|
||||
return &timeoutConn{
|
||||
c: conn,
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *timeoutConn) Read(b []byte) (n int, err error) {
|
||||
if c.buf != nil {
|
||||
if c.packetPending {
|
||||
c.packetPending = false
|
||||
err = c.buf.FinishPacket()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Cannot send handshake packet: %s", err.Error())
|
||||
return
|
||||
}
|
||||
c.continueRead = false
|
||||
}
|
||||
if !c.continueRead {
|
||||
var packet packetType
|
||||
packet, err = c.buf.BeginRead()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Cannot read handshake packet: %s", err.Error())
|
||||
return
|
||||
}
|
||||
if packet != packPrelogin {
|
||||
err = fmt.Errorf("unexpected packet %d, expecting prelogin", packet)
|
||||
return
|
||||
}
|
||||
c.continueRead = true
|
||||
}
|
||||
n, err = c.buf.Read(b)
|
||||
return
|
||||
}
|
||||
if c.timeout > 0 {
|
||||
err = c.c.SetDeadline(time.Now().Add(c.timeout))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return c.c.Read(b)
|
||||
}
|
||||
|
||||
func (c *timeoutConn) Write(b []byte) (n int, err error) {
|
||||
if c.buf != nil {
|
||||
if !c.packetPending {
|
||||
c.buf.BeginPacket(packPrelogin, false)
|
||||
c.packetPending = true
|
||||
}
|
||||
n, err = c.buf.Write(b)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
if c.timeout > 0 {
|
||||
err = c.c.SetDeadline(time.Now().Add(c.timeout))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return c.c.Write(b)
|
||||
}
|
||||
|
||||
func (c timeoutConn) Close() error {
|
||||
return c.c.Close()
|
||||
}
|
||||
|
||||
func (c timeoutConn) LocalAddr() net.Addr {
|
||||
return c.c.LocalAddr()
|
||||
}
|
||||
|
||||
func (c timeoutConn) RemoteAddr() net.Addr {
|
||||
return c.c.RemoteAddr()
|
||||
}
|
||||
|
||||
func (c timeoutConn) SetDeadline(t time.Time) error {
|
||||
panic("Not implemented")
|
||||
}
|
||||
|
||||
func (c timeoutConn) SetReadDeadline(t time.Time) error {
|
||||
panic("Not implemented")
|
||||
}
|
||||
|
||||
func (c timeoutConn) SetWriteDeadline(t time.Time) error {
|
||||
panic("Not implemented")
|
||||
}
|
283
vendor/github.com/denisenkom/go-mssqldb/ntlm.go
generated
vendored
Normal file
283
vendor/github.com/denisenkom/go-mssqldb/ntlm.go
generated
vendored
Normal file
|
@ -0,0 +1,283 @@
|
|||
// +build !windows
|
||||
|
||||
package mssql
|
||||
|
||||
import (
|
||||
"crypto/des"
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"strings"
|
||||
"unicode/utf16"
|
||||
|
||||
"golang.org/x/crypto/md4"
|
||||
)
|
||||
|
||||
const (
|
||||
_NEGOTIATE_MESSAGE = 1
|
||||
_CHALLENGE_MESSAGE = 2
|
||||
_AUTHENTICATE_MESSAGE = 3
|
||||
)
|
||||
|
||||
const (
|
||||
_NEGOTIATE_UNICODE = 0x00000001
|
||||
_NEGOTIATE_OEM = 0x00000002
|
||||
_NEGOTIATE_TARGET = 0x00000004
|
||||
_NEGOTIATE_SIGN = 0x00000010
|
||||
_NEGOTIATE_SEAL = 0x00000020
|
||||
_NEGOTIATE_DATAGRAM = 0x00000040
|
||||
_NEGOTIATE_LMKEY = 0x00000080
|
||||
_NEGOTIATE_NTLM = 0x00000200
|
||||
_NEGOTIATE_ANONYMOUS = 0x00000800
|
||||
_NEGOTIATE_OEM_DOMAIN_SUPPLIED = 0x00001000
|
||||
_NEGOTIATE_OEM_WORKSTATION_SUPPLIED = 0x00002000
|
||||
_NEGOTIATE_ALWAYS_SIGN = 0x00008000
|
||||
_NEGOTIATE_TARGET_TYPE_DOMAIN = 0x00010000
|
||||
_NEGOTIATE_TARGET_TYPE_SERVER = 0x00020000
|
||||
_NEGOTIATE_EXTENDED_SESSIONSECURITY = 0x00080000
|
||||
_NEGOTIATE_IDENTIFY = 0x00100000
|
||||
_REQUEST_NON_NT_SESSION_KEY = 0x00400000
|
||||
_NEGOTIATE_TARGET_INFO = 0x00800000
|
||||
_NEGOTIATE_VERSION = 0x02000000
|
||||
_NEGOTIATE_128 = 0x20000000
|
||||
_NEGOTIATE_KEY_EXCH = 0x40000000
|
||||
_NEGOTIATE_56 = 0x80000000
|
||||
)
|
||||
|
||||
const _NEGOTIATE_FLAGS = _NEGOTIATE_UNICODE |
|
||||
_NEGOTIATE_NTLM |
|
||||
_NEGOTIATE_OEM_DOMAIN_SUPPLIED |
|
||||
_NEGOTIATE_OEM_WORKSTATION_SUPPLIED |
|
||||
_NEGOTIATE_ALWAYS_SIGN |
|
||||
_NEGOTIATE_EXTENDED_SESSIONSECURITY
|
||||
|
||||
type ntlmAuth struct {
|
||||
Domain string
|
||||
UserName string
|
||||
Password string
|
||||
Workstation string
|
||||
}
|
||||
|
||||
func getAuth(user, password, service, workstation string) (auth, bool) {
|
||||
if !strings.ContainsRune(user, '\\') {
|
||||
return nil, false
|
||||
}
|
||||
domain_user := strings.SplitN(user, "\\", 2)
|
||||
return &ntlmAuth{
|
||||
Domain: domain_user[0],
|
||||
UserName: domain_user[1],
|
||||
Password: password,
|
||||
Workstation: workstation,
|
||||
}, true
|
||||
}
|
||||
|
||||
func utf16le(val string) []byte {
|
||||
var v []byte
|
||||
for _, r := range val {
|
||||
if utf16.IsSurrogate(r) {
|
||||
r1, r2 := utf16.EncodeRune(r)
|
||||
v = append(v, byte(r1), byte(r1>>8))
|
||||
v = append(v, byte(r2), byte(r2>>8))
|
||||
} else {
|
||||
v = append(v, byte(r), byte(r>>8))
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (auth *ntlmAuth) InitialBytes() ([]byte, error) {
|
||||
domain_len := len(auth.Domain)
|
||||
workstation_len := len(auth.Workstation)
|
||||
msg := make([]byte, 40+domain_len+workstation_len)
|
||||
copy(msg, []byte("NTLMSSP\x00"))
|
||||
binary.LittleEndian.PutUint32(msg[8:], _NEGOTIATE_MESSAGE)
|
||||
binary.LittleEndian.PutUint32(msg[12:], _NEGOTIATE_FLAGS)
|
||||
// Domain Name Fields
|
||||
binary.LittleEndian.PutUint16(msg[16:], uint16(domain_len))
|
||||
binary.LittleEndian.PutUint16(msg[18:], uint16(domain_len))
|
||||
binary.LittleEndian.PutUint32(msg[20:], 40)
|
||||
// Workstation Fields
|
||||
binary.LittleEndian.PutUint16(msg[24:], uint16(workstation_len))
|
||||
binary.LittleEndian.PutUint16(msg[26:], uint16(workstation_len))
|
||||
binary.LittleEndian.PutUint32(msg[28:], uint32(40+domain_len))
|
||||
// Version
|
||||
binary.LittleEndian.PutUint32(msg[32:], 0)
|
||||
binary.LittleEndian.PutUint32(msg[36:], 0)
|
||||
// Payload
|
||||
copy(msg[40:], auth.Domain)
|
||||
copy(msg[40+domain_len:], auth.Workstation)
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
var errorNTLM = errors.New("NTLM protocol error")
|
||||
|
||||
func createDesKey(bytes, material []byte) {
|
||||
material[0] = bytes[0]
|
||||
material[1] = (byte)(bytes[0]<<7 | (bytes[1]&0xff)>>1)
|
||||
material[2] = (byte)(bytes[1]<<6 | (bytes[2]&0xff)>>2)
|
||||
material[3] = (byte)(bytes[2]<<5 | (bytes[3]&0xff)>>3)
|
||||
material[4] = (byte)(bytes[3]<<4 | (bytes[4]&0xff)>>4)
|
||||
material[5] = (byte)(bytes[4]<<3 | (bytes[5]&0xff)>>5)
|
||||
material[6] = (byte)(bytes[5]<<2 | (bytes[6]&0xff)>>6)
|
||||
material[7] = (byte)(bytes[6] << 1)
|
||||
}
|
||||
|
||||
func oddParity(bytes []byte) {
|
||||
for i := 0; i < len(bytes); i++ {
|
||||
b := bytes[i]
|
||||
needsParity := (((b >> 7) ^ (b >> 6) ^ (b >> 5) ^ (b >> 4) ^ (b >> 3) ^ (b >> 2) ^ (b >> 1)) & 0x01) == 0
|
||||
if needsParity {
|
||||
bytes[i] = bytes[i] | byte(0x01)
|
||||
} else {
|
||||
bytes[i] = bytes[i] & byte(0xfe)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func encryptDes(key []byte, cleartext []byte, ciphertext []byte) {
|
||||
var desKey [8]byte
|
||||
createDesKey(key, desKey[:])
|
||||
cipher, err := des.NewCipher(desKey[:])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cipher.Encrypt(ciphertext, cleartext)
|
||||
}
|
||||
|
||||
func response(challenge [8]byte, hash [21]byte) (ret [24]byte) {
|
||||
encryptDes(hash[:7], challenge[:], ret[:8])
|
||||
encryptDes(hash[7:14], challenge[:], ret[8:16])
|
||||
encryptDes(hash[14:], challenge[:], ret[16:])
|
||||
return
|
||||
}
|
||||
|
||||
func lmHash(password string) (hash [21]byte) {
|
||||
var lmpass [14]byte
|
||||
copy(lmpass[:14], []byte(strings.ToUpper(password)))
|
||||
magic := []byte("KGS!@#$%")
|
||||
encryptDes(lmpass[:7], magic, hash[:8])
|
||||
encryptDes(lmpass[7:], magic, hash[8:])
|
||||
return
|
||||
}
|
||||
|
||||
func lmResponse(challenge [8]byte, password string) [24]byte {
|
||||
hash := lmHash(password)
|
||||
return response(challenge, hash)
|
||||
}
|
||||
|
||||
func ntlmHash(password string) (hash [21]byte) {
|
||||
h := md4.New()
|
||||
h.Write(utf16le(password))
|
||||
h.Sum(hash[:0])
|
||||
return
|
||||
}
|
||||
|
||||
func ntResponse(challenge [8]byte, password string) [24]byte {
|
||||
hash := ntlmHash(password)
|
||||
return response(challenge, hash)
|
||||
}
|
||||
|
||||
func clientChallenge() (nonce [8]byte) {
|
||||
_, err := rand.Read(nonce[:])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ntlmSessionResponse(clientNonce [8]byte, serverChallenge [8]byte, password string) [24]byte {
|
||||
var sessionHash [16]byte
|
||||
h := md5.New()
|
||||
h.Write(serverChallenge[:])
|
||||
h.Write(clientNonce[:])
|
||||
h.Sum(sessionHash[:0])
|
||||
var hash [8]byte
|
||||
copy(hash[:], sessionHash[:8])
|
||||
passwordHash := ntlmHash(password)
|
||||
return response(hash, passwordHash)
|
||||
}
|
||||
|
||||
func (auth *ntlmAuth) NextBytes(bytes []byte) ([]byte, error) {
|
||||
if string(bytes[0:8]) != "NTLMSSP\x00" {
|
||||
return nil, errorNTLM
|
||||
}
|
||||
if binary.LittleEndian.Uint32(bytes[8:12]) != _CHALLENGE_MESSAGE {
|
||||
return nil, errorNTLM
|
||||
}
|
||||
flags := binary.LittleEndian.Uint32(bytes[20:24])
|
||||
var challenge [8]byte
|
||||
copy(challenge[:], bytes[24:32])
|
||||
|
||||
var lm, nt []byte
|
||||
if (flags & _NEGOTIATE_EXTENDED_SESSIONSECURITY) != 0 {
|
||||
nonce := clientChallenge()
|
||||
var lm_bytes [24]byte
|
||||
copy(lm_bytes[:8], nonce[:])
|
||||
lm = lm_bytes[:]
|
||||
nt_bytes := ntlmSessionResponse(nonce, challenge, auth.Password)
|
||||
nt = nt_bytes[:]
|
||||
} else {
|
||||
lm_bytes := lmResponse(challenge, auth.Password)
|
||||
lm = lm_bytes[:]
|
||||
nt_bytes := ntResponse(challenge, auth.Password)
|
||||
nt = nt_bytes[:]
|
||||
}
|
||||
lm_len := len(lm)
|
||||
nt_len := len(nt)
|
||||
|
||||
domain16 := utf16le(auth.Domain)
|
||||
domain_len := len(domain16)
|
||||
user16 := utf16le(auth.UserName)
|
||||
user_len := len(user16)
|
||||
workstation16 := utf16le(auth.Workstation)
|
||||
workstation_len := len(workstation16)
|
||||
|
||||
msg := make([]byte, 88+lm_len+nt_len+domain_len+user_len+workstation_len)
|
||||
copy(msg, []byte("NTLMSSP\x00"))
|
||||
binary.LittleEndian.PutUint32(msg[8:], _AUTHENTICATE_MESSAGE)
|
||||
// Lm Challenge Response Fields
|
||||
binary.LittleEndian.PutUint16(msg[12:], uint16(lm_len))
|
||||
binary.LittleEndian.PutUint16(msg[14:], uint16(lm_len))
|
||||
binary.LittleEndian.PutUint32(msg[16:], 88)
|
||||
// Nt Challenge Response Fields
|
||||
binary.LittleEndian.PutUint16(msg[20:], uint16(nt_len))
|
||||
binary.LittleEndian.PutUint16(msg[22:], uint16(nt_len))
|
||||
binary.LittleEndian.PutUint32(msg[24:], uint32(88+lm_len))
|
||||
// Domain Name Fields
|
||||
binary.LittleEndian.PutUint16(msg[28:], uint16(domain_len))
|
||||
binary.LittleEndian.PutUint16(msg[30:], uint16(domain_len))
|
||||
binary.LittleEndian.PutUint32(msg[32:], uint32(88+lm_len+nt_len))
|
||||
// User Name Fields
|
||||
binary.LittleEndian.PutUint16(msg[36:], uint16(user_len))
|
||||
binary.LittleEndian.PutUint16(msg[38:], uint16(user_len))
|
||||
binary.LittleEndian.PutUint32(msg[40:], uint32(88+lm_len+nt_len+domain_len))
|
||||
// Workstation Fields
|
||||
binary.LittleEndian.PutUint16(msg[44:], uint16(workstation_len))
|
||||
binary.LittleEndian.PutUint16(msg[46:], uint16(workstation_len))
|
||||
binary.LittleEndian.PutUint32(msg[48:], uint32(88+lm_len+nt_len+domain_len+user_len))
|
||||
// Encrypted Random Session Key Fields
|
||||
binary.LittleEndian.PutUint16(msg[52:], 0)
|
||||
binary.LittleEndian.PutUint16(msg[54:], 0)
|
||||
binary.LittleEndian.PutUint32(msg[56:], uint32(88+lm_len+nt_len+domain_len+user_len+workstation_len))
|
||||
// Negotiate Flags
|
||||
binary.LittleEndian.PutUint32(msg[60:], flags)
|
||||
// Version
|
||||
binary.LittleEndian.PutUint32(msg[64:], 0)
|
||||
binary.LittleEndian.PutUint32(msg[68:], 0)
|
||||
// MIC
|
||||
binary.LittleEndian.PutUint32(msg[72:], 0)
|
||||
binary.LittleEndian.PutUint32(msg[76:], 0)
|
||||
binary.LittleEndian.PutUint32(msg[88:], 0)
|
||||
binary.LittleEndian.PutUint32(msg[84:], 0)
|
||||
// Payload
|
||||
copy(msg[88:], lm)
|
||||
copy(msg[88+lm_len:], nt)
|
||||
copy(msg[88+lm_len+nt_len:], domain16)
|
||||
copy(msg[88+lm_len+nt_len+domain_len:], user16)
|
||||
copy(msg[88+lm_len+nt_len+domain_len+user_len:], workstation16)
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
func (auth *ntlmAuth) Free() {
|
||||
}
|
257
vendor/github.com/denisenkom/go-mssqldb/parser.go
generated
vendored
Normal file
257
vendor/github.com/denisenkom/go-mssqldb/parser.go
generated
vendored
Normal file
|
@ -0,0 +1,257 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type parser struct {
|
||||
r *bytes.Reader
|
||||
w bytes.Buffer
|
||||
paramCount int
|
||||
paramMax int
|
||||
|
||||
// using map as a set
|
||||
namedParams map[string]bool
|
||||
}
|
||||
|
||||
func (p *parser) next() (rune, bool) {
|
||||
ch, _, err := p.r.ReadRune()
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
panic(err)
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
return ch, true
|
||||
}
|
||||
|
||||
func (p *parser) unread() {
|
||||
err := p.r.UnreadRune()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *parser) write(ch rune) {
|
||||
p.w.WriteRune(ch)
|
||||
}
|
||||
|
||||
type stateFunc func(*parser) stateFunc
|
||||
|
||||
func parseParams(query string) (string, int) {
|
||||
p := &parser{
|
||||
r: bytes.NewReader([]byte(query)),
|
||||
namedParams: map[string]bool{},
|
||||
}
|
||||
state := parseNormal
|
||||
for state != nil {
|
||||
state = state(p)
|
||||
}
|
||||
return p.w.String(), p.paramMax + len(p.namedParams)
|
||||
}
|
||||
|
||||
func parseNormal(p *parser) stateFunc {
|
||||
for {
|
||||
ch, ok := p.next()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if ch == '?' {
|
||||
return parseOrdinalParameter
|
||||
} else if ch == '$' || ch == ':' {
|
||||
ch2, ok := p.next()
|
||||
if !ok {
|
||||
p.write(ch)
|
||||
return nil
|
||||
}
|
||||
p.unread()
|
||||
if ch2 >= '0' && ch2 <= '9' {
|
||||
return parseOrdinalParameter
|
||||
} else if 'a' <= ch2 && ch2 <= 'z' || 'A' <= ch2 && ch2 <= 'Z' {
|
||||
return parseNamedParameter
|
||||
}
|
||||
}
|
||||
p.write(ch)
|
||||
switch ch {
|
||||
case '\'':
|
||||
return parseQuote
|
||||
case '"':
|
||||
return parseDoubleQuote
|
||||
case '[':
|
||||
return parseBracket
|
||||
case '-':
|
||||
return parseLineComment
|
||||
case '/':
|
||||
return parseComment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func parseOrdinalParameter(p *parser) stateFunc {
|
||||
var paramN int
|
||||
var ok bool
|
||||
for {
|
||||
var ch rune
|
||||
ch, ok = p.next()
|
||||
if ok && ch >= '0' && ch <= '9' {
|
||||
paramN = paramN*10 + int(ch-'0')
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if ok {
|
||||
p.unread()
|
||||
}
|
||||
if paramN == 0 {
|
||||
p.paramCount++
|
||||
paramN = p.paramCount
|
||||
}
|
||||
if paramN > p.paramMax {
|
||||
p.paramMax = paramN
|
||||
}
|
||||
p.w.WriteString("@p")
|
||||
p.w.WriteString(strconv.Itoa(paramN))
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return parseNormal
|
||||
}
|
||||
|
||||
func parseNamedParameter(p *parser) stateFunc {
|
||||
var paramName string
|
||||
var ok bool
|
||||
for {
|
||||
var ch rune
|
||||
ch, ok = p.next()
|
||||
if ok && (ch >= '0' && ch <= '9' || 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z') {
|
||||
paramName = paramName + string(ch)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if ok {
|
||||
p.unread()
|
||||
}
|
||||
p.namedParams[paramName] = true
|
||||
p.w.WriteString("@")
|
||||
p.w.WriteString(paramName)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return parseNormal
|
||||
}
|
||||
|
||||
func parseQuote(p *parser) stateFunc {
|
||||
for {
|
||||
ch, ok := p.next()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
p.write(ch)
|
||||
if ch == '\'' {
|
||||
return parseNormal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func parseDoubleQuote(p *parser) stateFunc {
|
||||
for {
|
||||
ch, ok := p.next()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
p.write(ch)
|
||||
if ch == '"' {
|
||||
return parseNormal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func parseBracket(p *parser) stateFunc {
|
||||
for {
|
||||
ch, ok := p.next()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
p.write(ch)
|
||||
if ch == ']' {
|
||||
ch, ok = p.next()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if ch != ']' {
|
||||
p.unread()
|
||||
return parseNormal
|
||||
}
|
||||
p.write(ch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func parseLineComment(p *parser) stateFunc {
|
||||
ch, ok := p.next()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if ch != '-' {
|
||||
p.unread()
|
||||
return parseNormal
|
||||
}
|
||||
p.write(ch)
|
||||
for {
|
||||
ch, ok = p.next()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
p.write(ch)
|
||||
if ch == '\n' {
|
||||
return parseNormal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func parseComment(p *parser) stateFunc {
|
||||
var nested int
|
||||
ch, ok := p.next()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if ch != '*' {
|
||||
p.unread()
|
||||
return parseNormal
|
||||
}
|
||||
p.write(ch)
|
||||
for {
|
||||
ch, ok = p.next()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
p.write(ch)
|
||||
for ch == '*' {
|
||||
ch, ok = p.next()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
p.write(ch)
|
||||
if ch == '/' {
|
||||
if nested == 0 {
|
||||
return parseNormal
|
||||
} else {
|
||||
nested--
|
||||
}
|
||||
}
|
||||
}
|
||||
for ch == '/' {
|
||||
ch, ok = p.next()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
p.write(ch)
|
||||
if ch == '*' {
|
||||
nested++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
89
vendor/github.com/denisenkom/go-mssqldb/rpc.go
generated
vendored
Normal file
89
vendor/github.com/denisenkom/go-mssqldb/rpc.go
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
)
|
||||
|
||||
type procId struct {
|
||||
id uint16
|
||||
name string
|
||||
}
|
||||
|
||||
// parameter flags
|
||||
const (
|
||||
fByRevValue = 1
|
||||
fDefaultValue = 2
|
||||
)
|
||||
|
||||
type param struct {
|
||||
Name string
|
||||
Flags uint8
|
||||
ti typeInfo
|
||||
buffer []byte
|
||||
}
|
||||
|
||||
const (
|
||||
fWithRecomp = 1
|
||||
fNoMetaData = 2
|
||||
fReuseMetaData = 4
|
||||
)
|
||||
|
||||
var (
|
||||
sp_Cursor = procId{1, ""}
|
||||
sp_CursorOpen = procId{2, ""}
|
||||
sp_CursorPrepare = procId{3, ""}
|
||||
sp_CursorExecute = procId{4, ""}
|
||||
sp_CursorPrepExec = procId{5, ""}
|
||||
sp_CursorUnprepare = procId{6, ""}
|
||||
sp_CursorFetch = procId{7, ""}
|
||||
sp_CursorOption = procId{8, ""}
|
||||
sp_CursorClose = procId{9, ""}
|
||||
sp_ExecuteSql = procId{10, ""}
|
||||
sp_Prepare = procId{11, ""}
|
||||
sp_PrepExec = procId{13, ""}
|
||||
sp_PrepExecRpc = procId{14, ""}
|
||||
sp_Unprepare = procId{15, ""}
|
||||
)
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd357576.aspx
|
||||
func sendRpc(buf *tdsBuffer, headers []headerStruct, proc procId, flags uint16, params []param, resetSession bool) (err error) {
|
||||
buf.BeginPacket(packRPCRequest, resetSession)
|
||||
writeAllHeaders(buf, headers)
|
||||
if len(proc.name) == 0 {
|
||||
var idswitch uint16 = 0xffff
|
||||
err = binary.Write(buf, binary.LittleEndian, &idswitch)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = binary.Write(buf, binary.LittleEndian, &proc.id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = writeUsVarChar(buf, proc.name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
err = binary.Write(buf, binary.LittleEndian, &flags)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for _, param := range params {
|
||||
if err = writeBVarChar(buf, param.Name); err != nil {
|
||||
return
|
||||
}
|
||||
if err = binary.Write(buf, binary.LittleEndian, param.Flags); err != nil {
|
||||
return
|
||||
}
|
||||
err = writeTypeInfo(buf, ¶m.ti)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = param.ti.Writer(buf, param.ti, param.buffer)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return buf.FinishPacket()
|
||||
}
|
266
vendor/github.com/denisenkom/go-mssqldb/sspi_windows.go
generated
vendored
Normal file
266
vendor/github.com/denisenkom/go-mssqldb/sspi_windows.go
generated
vendored
Normal file
|
@ -0,0 +1,266 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var (
|
||||
secur32_dll = syscall.NewLazyDLL("secur32.dll")
|
||||
initSecurityInterface = secur32_dll.NewProc("InitSecurityInterfaceW")
|
||||
sec_fn *SecurityFunctionTable
|
||||
)
|
||||
|
||||
func init() {
|
||||
ptr, _, _ := initSecurityInterface.Call()
|
||||
sec_fn = (*SecurityFunctionTable)(unsafe.Pointer(ptr))
|
||||
}
|
||||
|
||||
const (
|
||||
SEC_E_OK = 0
|
||||
SECPKG_CRED_OUTBOUND = 2
|
||||
SEC_WINNT_AUTH_IDENTITY_UNICODE = 2
|
||||
ISC_REQ_DELEGATE = 0x00000001
|
||||
ISC_REQ_REPLAY_DETECT = 0x00000004
|
||||
ISC_REQ_SEQUENCE_DETECT = 0x00000008
|
||||
ISC_REQ_CONFIDENTIALITY = 0x00000010
|
||||
ISC_REQ_CONNECTION = 0x00000800
|
||||
SECURITY_NETWORK_DREP = 0
|
||||
SEC_I_CONTINUE_NEEDED = 0x00090312
|
||||
SEC_I_COMPLETE_NEEDED = 0x00090313
|
||||
SEC_I_COMPLETE_AND_CONTINUE = 0x00090314
|
||||
SECBUFFER_VERSION = 0
|
||||
SECBUFFER_TOKEN = 2
|
||||
NTLMBUF_LEN = 12000
|
||||
)
|
||||
|
||||
const ISC_REQ = ISC_REQ_CONFIDENTIALITY |
|
||||
ISC_REQ_REPLAY_DETECT |
|
||||
ISC_REQ_SEQUENCE_DETECT |
|
||||
ISC_REQ_CONNECTION |
|
||||
ISC_REQ_DELEGATE
|
||||
|
||||
type SecurityFunctionTable struct {
|
||||
dwVersion uint32
|
||||
EnumerateSecurityPackages uintptr
|
||||
QueryCredentialsAttributes uintptr
|
||||
AcquireCredentialsHandle uintptr
|
||||
FreeCredentialsHandle uintptr
|
||||
Reserved2 uintptr
|
||||
InitializeSecurityContext uintptr
|
||||
AcceptSecurityContext uintptr
|
||||
CompleteAuthToken uintptr
|
||||
DeleteSecurityContext uintptr
|
||||
ApplyControlToken uintptr
|
||||
QueryContextAttributes uintptr
|
||||
ImpersonateSecurityContext uintptr
|
||||
RevertSecurityContext uintptr
|
||||
MakeSignature uintptr
|
||||
VerifySignature uintptr
|
||||
FreeContextBuffer uintptr
|
||||
QuerySecurityPackageInfo uintptr
|
||||
Reserved3 uintptr
|
||||
Reserved4 uintptr
|
||||
Reserved5 uintptr
|
||||
Reserved6 uintptr
|
||||
Reserved7 uintptr
|
||||
Reserved8 uintptr
|
||||
QuerySecurityContextToken uintptr
|
||||
EncryptMessage uintptr
|
||||
DecryptMessage uintptr
|
||||
}
|
||||
|
||||
type SEC_WINNT_AUTH_IDENTITY struct {
|
||||
User *uint16
|
||||
UserLength uint32
|
||||
Domain *uint16
|
||||
DomainLength uint32
|
||||
Password *uint16
|
||||
PasswordLength uint32
|
||||
Flags uint32
|
||||
}
|
||||
|
||||
type TimeStamp struct {
|
||||
LowPart uint32
|
||||
HighPart int32
|
||||
}
|
||||
|
||||
type SecHandle struct {
|
||||
dwLower uintptr
|
||||
dwUpper uintptr
|
||||
}
|
||||
|
||||
type SecBuffer struct {
|
||||
cbBuffer uint32
|
||||
BufferType uint32
|
||||
pvBuffer *byte
|
||||
}
|
||||
|
||||
type SecBufferDesc struct {
|
||||
ulVersion uint32
|
||||
cBuffers uint32
|
||||
pBuffers *SecBuffer
|
||||
}
|
||||
|
||||
type SSPIAuth struct {
|
||||
Domain string
|
||||
UserName string
|
||||
Password string
|
||||
Service string
|
||||
cred SecHandle
|
||||
ctxt SecHandle
|
||||
}
|
||||
|
||||
func getAuth(user, password, service, workstation string) (auth, bool) {
|
||||
if user == "" {
|
||||
return &SSPIAuth{Service: service}, true
|
||||
}
|
||||
if !strings.ContainsRune(user, '\\') {
|
||||
return nil, false
|
||||
}
|
||||
domain_user := strings.SplitN(user, "\\", 2)
|
||||
return &SSPIAuth{
|
||||
Domain: domain_user[0],
|
||||
UserName: domain_user[1],
|
||||
Password: password,
|
||||
Service: service,
|
||||
}, true
|
||||
}
|
||||
|
||||
func (auth *SSPIAuth) InitialBytes() ([]byte, error) {
|
||||
var identity *SEC_WINNT_AUTH_IDENTITY
|
||||
if auth.UserName != "" {
|
||||
identity = &SEC_WINNT_AUTH_IDENTITY{
|
||||
Flags: SEC_WINNT_AUTH_IDENTITY_UNICODE,
|
||||
Password: syscall.StringToUTF16Ptr(auth.Password),
|
||||
PasswordLength: uint32(len(auth.Password)),
|
||||
Domain: syscall.StringToUTF16Ptr(auth.Domain),
|
||||
DomainLength: uint32(len(auth.Domain)),
|
||||
User: syscall.StringToUTF16Ptr(auth.UserName),
|
||||
UserLength: uint32(len(auth.UserName)),
|
||||
}
|
||||
}
|
||||
var ts TimeStamp
|
||||
sec_ok, _, _ := syscall.Syscall9(sec_fn.AcquireCredentialsHandle,
|
||||
9,
|
||||
0,
|
||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("Negotiate"))),
|
||||
SECPKG_CRED_OUTBOUND,
|
||||
0,
|
||||
uintptr(unsafe.Pointer(identity)),
|
||||
0,
|
||||
0,
|
||||
uintptr(unsafe.Pointer(&auth.cred)),
|
||||
uintptr(unsafe.Pointer(&ts)))
|
||||
if sec_ok != SEC_E_OK {
|
||||
return nil, fmt.Errorf("AcquireCredentialsHandle failed %x", sec_ok)
|
||||
}
|
||||
|
||||
var buf SecBuffer
|
||||
var desc SecBufferDesc
|
||||
desc.ulVersion = SECBUFFER_VERSION
|
||||
desc.cBuffers = 1
|
||||
desc.pBuffers = &buf
|
||||
|
||||
outbuf := make([]byte, NTLMBUF_LEN)
|
||||
buf.cbBuffer = NTLMBUF_LEN
|
||||
buf.BufferType = SECBUFFER_TOKEN
|
||||
buf.pvBuffer = &outbuf[0]
|
||||
|
||||
var attrs uint32
|
||||
sec_ok, _, _ = syscall.Syscall12(sec_fn.InitializeSecurityContext,
|
||||
12,
|
||||
uintptr(unsafe.Pointer(&auth.cred)),
|
||||
0,
|
||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(auth.Service))),
|
||||
ISC_REQ,
|
||||
0,
|
||||
SECURITY_NETWORK_DREP,
|
||||
0,
|
||||
0,
|
||||
uintptr(unsafe.Pointer(&auth.ctxt)),
|
||||
uintptr(unsafe.Pointer(&desc)),
|
||||
uintptr(unsafe.Pointer(&attrs)),
|
||||
uintptr(unsafe.Pointer(&ts)))
|
||||
if sec_ok == SEC_I_COMPLETE_AND_CONTINUE ||
|
||||
sec_ok == SEC_I_COMPLETE_NEEDED {
|
||||
syscall.Syscall6(sec_fn.CompleteAuthToken,
|
||||
2,
|
||||
uintptr(unsafe.Pointer(&auth.ctxt)),
|
||||
uintptr(unsafe.Pointer(&desc)),
|
||||
0, 0, 0, 0)
|
||||
} else if sec_ok != SEC_E_OK &&
|
||||
sec_ok != SEC_I_CONTINUE_NEEDED {
|
||||
syscall.Syscall6(sec_fn.FreeCredentialsHandle,
|
||||
1,
|
||||
uintptr(unsafe.Pointer(&auth.cred)),
|
||||
0, 0, 0, 0, 0)
|
||||
return nil, fmt.Errorf("InitialBytes InitializeSecurityContext failed %x", sec_ok)
|
||||
}
|
||||
return outbuf[:buf.cbBuffer], nil
|
||||
}
|
||||
|
||||
func (auth *SSPIAuth) NextBytes(bytes []byte) ([]byte, error) {
|
||||
var in_buf, out_buf SecBuffer
|
||||
var in_desc, out_desc SecBufferDesc
|
||||
|
||||
in_desc.ulVersion = SECBUFFER_VERSION
|
||||
in_desc.cBuffers = 1
|
||||
in_desc.pBuffers = &in_buf
|
||||
|
||||
out_desc.ulVersion = SECBUFFER_VERSION
|
||||
out_desc.cBuffers = 1
|
||||
out_desc.pBuffers = &out_buf
|
||||
|
||||
in_buf.BufferType = SECBUFFER_TOKEN
|
||||
in_buf.pvBuffer = &bytes[0]
|
||||
in_buf.cbBuffer = uint32(len(bytes))
|
||||
|
||||
outbuf := make([]byte, NTLMBUF_LEN)
|
||||
out_buf.BufferType = SECBUFFER_TOKEN
|
||||
out_buf.pvBuffer = &outbuf[0]
|
||||
out_buf.cbBuffer = NTLMBUF_LEN
|
||||
|
||||
var attrs uint32
|
||||
var ts TimeStamp
|
||||
sec_ok, _, _ := syscall.Syscall12(sec_fn.InitializeSecurityContext,
|
||||
12,
|
||||
uintptr(unsafe.Pointer(&auth.cred)),
|
||||
uintptr(unsafe.Pointer(&auth.ctxt)),
|
||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(auth.Service))),
|
||||
ISC_REQ,
|
||||
0,
|
||||
SECURITY_NETWORK_DREP,
|
||||
uintptr(unsafe.Pointer(&in_desc)),
|
||||
0,
|
||||
uintptr(unsafe.Pointer(&auth.ctxt)),
|
||||
uintptr(unsafe.Pointer(&out_desc)),
|
||||
uintptr(unsafe.Pointer(&attrs)),
|
||||
uintptr(unsafe.Pointer(&ts)))
|
||||
if sec_ok == SEC_I_COMPLETE_AND_CONTINUE ||
|
||||
sec_ok == SEC_I_COMPLETE_NEEDED {
|
||||
syscall.Syscall6(sec_fn.CompleteAuthToken,
|
||||
2,
|
||||
uintptr(unsafe.Pointer(&auth.ctxt)),
|
||||
uintptr(unsafe.Pointer(&out_desc)),
|
||||
0, 0, 0, 0)
|
||||
} else if sec_ok != SEC_E_OK &&
|
||||
sec_ok != SEC_I_CONTINUE_NEEDED {
|
||||
return nil, fmt.Errorf("NextBytes InitializeSecurityContext failed %x", sec_ok)
|
||||
}
|
||||
|
||||
return outbuf[:out_buf.cbBuffer], nil
|
||||
}
|
||||
|
||||
func (auth *SSPIAuth) Free() {
|
||||
syscall.Syscall6(sec_fn.DeleteSecurityContext,
|
||||
1,
|
||||
uintptr(unsafe.Pointer(&auth.ctxt)),
|
||||
0, 0, 0, 0, 0)
|
||||
syscall.Syscall6(sec_fn.FreeCredentialsHandle,
|
||||
1,
|
||||
uintptr(unsafe.Pointer(&auth.cred)),
|
||||
0, 0, 0, 0, 0)
|
||||
}
|
1367
vendor/github.com/denisenkom/go-mssqldb/tds.go
generated
vendored
Normal file
1367
vendor/github.com/denisenkom/go-mssqldb/tds.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
804
vendor/github.com/denisenkom/go-mssqldb/token.go
generated
vendored
Normal file
804
vendor/github.com/denisenkom/go-mssqldb/token.go
generated
vendored
Normal file
|
@ -0,0 +1,804 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//go:generate stringer -type token
|
||||
|
||||
type token byte
|
||||
|
||||
// token ids
|
||||
const (
|
||||
tokenReturnStatus token = 121 // 0x79
|
||||
tokenColMetadata token = 129 // 0x81
|
||||
tokenOrder token = 169 // 0xA9
|
||||
tokenError token = 170 // 0xAA
|
||||
tokenInfo token = 171 // 0xAB
|
||||
tokenReturnValue token = 0xAC
|
||||
tokenLoginAck token = 173 // 0xad
|
||||
tokenRow token = 209 // 0xd1
|
||||
tokenNbcRow token = 210 // 0xd2
|
||||
tokenEnvChange token = 227 // 0xE3
|
||||
tokenSSPI token = 237 // 0xED
|
||||
tokenDone token = 253 // 0xFD
|
||||
tokenDoneProc token = 254
|
||||
tokenDoneInProc token = 255
|
||||
)
|
||||
|
||||
// done flags
|
||||
// https://msdn.microsoft.com/en-us/library/dd340421.aspx
|
||||
const (
|
||||
doneFinal = 0
|
||||
doneMore = 1
|
||||
doneError = 2
|
||||
doneInxact = 4
|
||||
doneCount = 0x10
|
||||
doneAttn = 0x20
|
||||
doneSrvError = 0x100
|
||||
)
|
||||
|
||||
// ENVCHANGE types
|
||||
// http://msdn.microsoft.com/en-us/library/dd303449.aspx
|
||||
const (
|
||||
envTypDatabase = 1
|
||||
envTypLanguage = 2
|
||||
envTypCharset = 3
|
||||
envTypPacketSize = 4
|
||||
envSortId = 5
|
||||
envSortFlags = 6
|
||||
envSqlCollation = 7
|
||||
envTypBeginTran = 8
|
||||
envTypCommitTran = 9
|
||||
envTypRollbackTran = 10
|
||||
envEnlistDTC = 11
|
||||
envDefectTran = 12
|
||||
envDatabaseMirrorPartner = 13
|
||||
envPromoteTran = 15
|
||||
envTranMgrAddr = 16
|
||||
envTranEnded = 17
|
||||
envResetConnAck = 18
|
||||
envStartedInstanceName = 19
|
||||
envRouting = 20
|
||||
)
|
||||
|
||||
// COLMETADATA flags
|
||||
// https://msdn.microsoft.com/en-us/library/dd357363.aspx
|
||||
const (
|
||||
colFlagNullable = 1
|
||||
// TODO implement more flags
|
||||
)
|
||||
|
||||
// interface for all tokens
|
||||
type tokenStruct interface{}
|
||||
|
||||
type orderStruct struct {
|
||||
ColIds []uint16
|
||||
}
|
||||
|
||||
type doneStruct struct {
|
||||
Status uint16
|
||||
CurCmd uint16
|
||||
RowCount uint64
|
||||
errors []Error
|
||||
}
|
||||
|
||||
func (d doneStruct) isError() bool {
|
||||
return d.Status&doneError != 0 || len(d.errors) > 0
|
||||
}
|
||||
|
||||
func (d doneStruct) getError() Error {
|
||||
if len(d.errors) > 0 {
|
||||
return d.errors[len(d.errors)-1]
|
||||
} else {
|
||||
return Error{Message: "Request failed but didn't provide reason"}
|
||||
}
|
||||
}
|
||||
|
||||
type doneInProcStruct doneStruct
|
||||
|
||||
var doneFlags2str = map[uint16]string{
|
||||
doneFinal: "final",
|
||||
doneMore: "more",
|
||||
doneError: "error",
|
||||
doneInxact: "inxact",
|
||||
doneCount: "count",
|
||||
doneAttn: "attn",
|
||||
doneSrvError: "srverror",
|
||||
}
|
||||
|
||||
func doneFlags2Str(flags uint16) string {
|
||||
strs := make([]string, 0, len(doneFlags2str))
|
||||
for flag, tag := range doneFlags2str {
|
||||
if flags&flag != 0 {
|
||||
strs = append(strs, tag)
|
||||
}
|
||||
}
|
||||
return strings.Join(strs, "|")
|
||||
}
|
||||
|
||||
// ENVCHANGE stream
|
||||
// http://msdn.microsoft.com/en-us/library/dd303449.aspx
|
||||
func processEnvChg(sess *tdsSession) {
|
||||
size := sess.buf.uint16()
|
||||
r := &io.LimitedReader{R: sess.buf, N: int64(size)}
|
||||
for {
|
||||
var err error
|
||||
var envtype uint8
|
||||
err = binary.Read(r, binary.LittleEndian, &envtype)
|
||||
if err == io.EOF {
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
switch envtype {
|
||||
case envTypDatabase:
|
||||
sess.database, err = readBVarChar(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
_, err = readBVarChar(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envTypLanguage:
|
||||
// currently ignored
|
||||
// new value
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// old value
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envTypCharset:
|
||||
// currently ignored
|
||||
// new value
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// old value
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envTypPacketSize:
|
||||
packetsize, err := readBVarChar(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
_, err = readBVarChar(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
packetsizei, err := strconv.Atoi(packetsize)
|
||||
if err != nil {
|
||||
badStreamPanicf("Invalid Packet size value returned from server (%s): %s", packetsize, err.Error())
|
||||
}
|
||||
sess.buf.ResizeBuffer(packetsizei)
|
||||
case envSortId:
|
||||
// currently ignored
|
||||
// new value
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// old value, should be 0
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envSortFlags:
|
||||
// currently ignored
|
||||
// new value
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// old value, should be 0
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envSqlCollation:
|
||||
// currently ignored
|
||||
var collationSize uint8
|
||||
err = binary.Read(r, binary.LittleEndian, &collationSize)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
|
||||
// SQL Collation data should contain 5 bytes in length
|
||||
if collationSize != 5 {
|
||||
badStreamPanicf("Invalid SQL Collation size value returned from server: %d", collationSize)
|
||||
}
|
||||
|
||||
// 4 bytes, contains: LCID ColFlags Version
|
||||
var info uint32
|
||||
err = binary.Read(r, binary.LittleEndian, &info)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
|
||||
// 1 byte, contains: sortID
|
||||
var sortID uint8
|
||||
err = binary.Read(r, binary.LittleEndian, &sortID)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
|
||||
// old value, should be 0
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envTypBeginTran:
|
||||
tranid, err := readBVarByte(r)
|
||||
if len(tranid) != 8 {
|
||||
badStreamPanicf("invalid size of transaction identifier: %d", len(tranid))
|
||||
}
|
||||
sess.tranid = binary.LittleEndian.Uint64(tranid)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
if sess.logFlags&logTransaction != 0 {
|
||||
sess.log.Printf("BEGIN TRANSACTION %x\n", sess.tranid)
|
||||
}
|
||||
_, err = readBVarByte(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envTypCommitTran, envTypRollbackTran:
|
||||
_, err = readBVarByte(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
_, err = readBVarByte(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
if sess.logFlags&logTransaction != 0 {
|
||||
if envtype == envTypCommitTran {
|
||||
sess.log.Printf("COMMIT TRANSACTION %x\n", sess.tranid)
|
||||
} else {
|
||||
sess.log.Printf("ROLLBACK TRANSACTION %x\n", sess.tranid)
|
||||
}
|
||||
}
|
||||
sess.tranid = 0
|
||||
case envEnlistDTC:
|
||||
// currently ignored
|
||||
// new value, should be 0
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// old value
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envDefectTran:
|
||||
// currently ignored
|
||||
// new value
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// old value, should be 0
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envDatabaseMirrorPartner:
|
||||
sess.partner, err = readBVarChar(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
_, err = readBVarChar(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envPromoteTran:
|
||||
// currently ignored
|
||||
// old value, should be 0
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// dtc token
|
||||
// spec says it should be L_VARBYTE, so this code might be wrong
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envTranMgrAddr:
|
||||
// currently ignored
|
||||
// old value, should be 0
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// XACT_MANAGER_ADDRESS = B_VARBYTE
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envTranEnded:
|
||||
// currently ignored
|
||||
// old value, B_VARBYTE
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// should be 0
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envResetConnAck:
|
||||
// currently ignored
|
||||
// old value, should be 0
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// should be 0
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envStartedInstanceName:
|
||||
// currently ignored
|
||||
// old value, should be 0
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// instance name
|
||||
if _, err = readBVarChar(r); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
case envRouting:
|
||||
// RoutingData message is:
|
||||
// ValueLength USHORT
|
||||
// Protocol (TCP = 0) BYTE
|
||||
// ProtocolProperty (new port) USHORT
|
||||
// AlternateServer US_VARCHAR
|
||||
_, err := readUshort(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
protocol, err := readByte(r)
|
||||
if err != nil || protocol != 0 {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
newPort, err := readUshort(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
newServer, err := readUsVarChar(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
// consume the OLDVALUE = %x00 %x00
|
||||
_, err = readUshort(r)
|
||||
if err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
sess.routedServer = newServer
|
||||
sess.routedPort = newPort
|
||||
default:
|
||||
// ignore rest of records because we don't know how to skip those
|
||||
sess.log.Printf("WARN: Unknown ENVCHANGE record detected with type id = %d\n", envtype)
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd358180.aspx
|
||||
func parseReturnStatus(r *tdsBuffer) ReturnStatus {
|
||||
return ReturnStatus(r.int32())
|
||||
}
|
||||
|
||||
func parseOrder(r *tdsBuffer) (res orderStruct) {
|
||||
len := int(r.uint16())
|
||||
res.ColIds = make([]uint16, len/2)
|
||||
for i := 0; i < len/2; i++ {
|
||||
res.ColIds[i] = r.uint16()
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/dd340421.aspx
|
||||
func parseDone(r *tdsBuffer) (res doneStruct) {
|
||||
res.Status = r.uint16()
|
||||
res.CurCmd = r.uint16()
|
||||
res.RowCount = r.uint64()
|
||||
return res
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/dd340553.aspx
|
||||
func parseDoneInProc(r *tdsBuffer) (res doneInProcStruct) {
|
||||
res.Status = r.uint16()
|
||||
res.CurCmd = r.uint16()
|
||||
res.RowCount = r.uint64()
|
||||
return res
|
||||
}
|
||||
|
||||
type sspiMsg []byte
|
||||
|
||||
func parseSSPIMsg(r *tdsBuffer) sspiMsg {
|
||||
size := r.uint16()
|
||||
buf := make([]byte, size)
|
||||
r.ReadFull(buf)
|
||||
return sspiMsg(buf)
|
||||
}
|
||||
|
||||
type loginAckStruct struct {
|
||||
Interface uint8
|
||||
TDSVersion uint32
|
||||
ProgName string
|
||||
ProgVer uint32
|
||||
}
|
||||
|
||||
func parseLoginAck(r *tdsBuffer) loginAckStruct {
|
||||
size := r.uint16()
|
||||
buf := make([]byte, size)
|
||||
r.ReadFull(buf)
|
||||
var res loginAckStruct
|
||||
res.Interface = buf[0]
|
||||
res.TDSVersion = binary.BigEndian.Uint32(buf[1:])
|
||||
prognamelen := buf[1+4]
|
||||
var err error
|
||||
if res.ProgName, err = ucs22str(buf[1+4+1 : 1+4+1+prognamelen*2]); err != nil {
|
||||
badStreamPanic(err)
|
||||
}
|
||||
res.ProgVer = binary.BigEndian.Uint32(buf[size-4:])
|
||||
return res
|
||||
}
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd357363.aspx
|
||||
func parseColMetadata72(r *tdsBuffer) (columns []columnStruct) {
|
||||
count := r.uint16()
|
||||
if count == 0xffff {
|
||||
// no metadata is sent
|
||||
return nil
|
||||
}
|
||||
columns = make([]columnStruct, count)
|
||||
for i := range columns {
|
||||
column := &columns[i]
|
||||
column.UserType = r.uint32()
|
||||
column.Flags = r.uint16()
|
||||
|
||||
// parsing TYPE_INFO structure
|
||||
column.ti = readTypeInfo(r)
|
||||
column.ColName = r.BVarChar()
|
||||
}
|
||||
return columns
|
||||
}
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd357254.aspx
|
||||
func parseRow(r *tdsBuffer, columns []columnStruct, row []interface{}) {
|
||||
for i, column := range columns {
|
||||
row[i] = column.ti.Reader(&column.ti, r)
|
||||
}
|
||||
}
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd304783.aspx
|
||||
func parseNbcRow(r *tdsBuffer, columns []columnStruct, row []interface{}) {
|
||||
bitlen := (len(columns) + 7) / 8
|
||||
pres := make([]byte, bitlen)
|
||||
r.ReadFull(pres)
|
||||
for i, col := range columns {
|
||||
if pres[i/8]&(1<<(uint(i)%8)) != 0 {
|
||||
row[i] = nil
|
||||
continue
|
||||
}
|
||||
row[i] = col.ti.Reader(&col.ti, r)
|
||||
}
|
||||
}
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd304156.aspx
|
||||
func parseError72(r *tdsBuffer) (res Error) {
|
||||
length := r.uint16()
|
||||
_ = length // ignore length
|
||||
res.Number = r.int32()
|
||||
res.State = r.byte()
|
||||
res.Class = r.byte()
|
||||
res.Message = r.UsVarChar()
|
||||
res.ServerName = r.BVarChar()
|
||||
res.ProcName = r.BVarChar()
|
||||
res.LineNo = r.int32()
|
||||
return
|
||||
}
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd304156.aspx
|
||||
func parseInfo(r *tdsBuffer) (res Error) {
|
||||
length := r.uint16()
|
||||
_ = length // ignore length
|
||||
res.Number = r.int32()
|
||||
res.State = r.byte()
|
||||
res.Class = r.byte()
|
||||
res.Message = r.UsVarChar()
|
||||
res.ServerName = r.BVarChar()
|
||||
res.ProcName = r.BVarChar()
|
||||
res.LineNo = r.int32()
|
||||
return
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/dd303881.aspx
|
||||
func parseReturnValue(r *tdsBuffer) (nv namedValue) {
|
||||
/*
|
||||
ParamOrdinal
|
||||
ParamName
|
||||
Status
|
||||
UserType
|
||||
Flags
|
||||
TypeInfo
|
||||
CryptoMetadata
|
||||
Value
|
||||
*/
|
||||
r.uint16()
|
||||
nv.Name = r.BVarChar()
|
||||
r.byte()
|
||||
r.uint32() // UserType (uint16 prior to 7.2)
|
||||
r.uint16()
|
||||
ti := readTypeInfo(r)
|
||||
nv.Value = ti.Reader(&ti, r)
|
||||
return
|
||||
}
|
||||
|
||||
func processSingleResponse(sess *tdsSession, ch chan tokenStruct, outs map[string]interface{}) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
if sess.logFlags&logErrors != 0 {
|
||||
sess.log.Printf("ERROR: Intercepted panic %v", err)
|
||||
}
|
||||
ch <- err
|
||||
}
|
||||
close(ch)
|
||||
}()
|
||||
|
||||
packet_type, err := sess.buf.BeginRead()
|
||||
if err != nil {
|
||||
if sess.logFlags&logErrors != 0 {
|
||||
sess.log.Printf("ERROR: BeginRead failed %v", err)
|
||||
}
|
||||
ch <- err
|
||||
return
|
||||
}
|
||||
if packet_type != packReply {
|
||||
badStreamPanic(fmt.Errorf("unexpected packet type in reply: got %v, expected %v", packet_type, packReply))
|
||||
}
|
||||
var columns []columnStruct
|
||||
errs := make([]Error, 0, 5)
|
||||
for {
|
||||
token := token(sess.buf.byte())
|
||||
if sess.logFlags&logDebug != 0 {
|
||||
sess.log.Printf("got token %v", token)
|
||||
}
|
||||
switch token {
|
||||
case tokenSSPI:
|
||||
ch <- parseSSPIMsg(sess.buf)
|
||||
return
|
||||
case tokenReturnStatus:
|
||||
returnStatus := parseReturnStatus(sess.buf)
|
||||
ch <- returnStatus
|
||||
case tokenLoginAck:
|
||||
loginAck := parseLoginAck(sess.buf)
|
||||
ch <- loginAck
|
||||
case tokenOrder:
|
||||
order := parseOrder(sess.buf)
|
||||
ch <- order
|
||||
case tokenDoneInProc:
|
||||
done := parseDoneInProc(sess.buf)
|
||||
if sess.logFlags&logRows != 0 && done.Status&doneCount != 0 {
|
||||
sess.log.Printf("(%d row(s) affected)\n", done.RowCount)
|
||||
}
|
||||
ch <- done
|
||||
case tokenDone, tokenDoneProc:
|
||||
done := parseDone(sess.buf)
|
||||
done.errors = errs
|
||||
if sess.logFlags&logDebug != 0 {
|
||||
sess.log.Printf("got DONE or DONEPROC status=%d", done.Status)
|
||||
}
|
||||
if done.Status&doneSrvError != 0 {
|
||||
ch <- errors.New("SQL Server had internal error")
|
||||
return
|
||||
}
|
||||
if sess.logFlags&logRows != 0 && done.Status&doneCount != 0 {
|
||||
sess.log.Printf("(%d row(s) affected)\n", done.RowCount)
|
||||
}
|
||||
ch <- done
|
||||
if done.Status&doneMore == 0 {
|
||||
return
|
||||
}
|
||||
case tokenColMetadata:
|
||||
columns = parseColMetadata72(sess.buf)
|
||||
ch <- columns
|
||||
case tokenRow:
|
||||
row := make([]interface{}, len(columns))
|
||||
parseRow(sess.buf, columns, row)
|
||||
ch <- row
|
||||
case tokenNbcRow:
|
||||
row := make([]interface{}, len(columns))
|
||||
parseNbcRow(sess.buf, columns, row)
|
||||
ch <- row
|
||||
case tokenEnvChange:
|
||||
processEnvChg(sess)
|
||||
case tokenError:
|
||||
err := parseError72(sess.buf)
|
||||
if sess.logFlags&logDebug != 0 {
|
||||
sess.log.Printf("got ERROR %d %s", err.Number, err.Message)
|
||||
}
|
||||
errs = append(errs, err)
|
||||
if sess.logFlags&logErrors != 0 {
|
||||
sess.log.Println(err.Message)
|
||||
}
|
||||
case tokenInfo:
|
||||
info := parseInfo(sess.buf)
|
||||
if sess.logFlags&logDebug != 0 {
|
||||
sess.log.Printf("got INFO %d %s", info.Number, info.Message)
|
||||
}
|
||||
if sess.logFlags&logMessages != 0 {
|
||||
sess.log.Println(info.Message)
|
||||
}
|
||||
case tokenReturnValue:
|
||||
nv := parseReturnValue(sess.buf)
|
||||
if len(nv.Name) > 0 {
|
||||
name := nv.Name[1:] // Remove the leading "@".
|
||||
if ov, has := outs[name]; has {
|
||||
err = scanIntoOut(name, nv.Value, ov)
|
||||
if err != nil {
|
||||
fmt.Println("scan error", err)
|
||||
ch <- err
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
badStreamPanic(fmt.Errorf("unknown token type returned: %v", token))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type parseRespIter byte
|
||||
|
||||
const (
|
||||
parseRespIterContinue parseRespIter = iota // Continue parsing current token.
|
||||
parseRespIterNext // Fetch the next token.
|
||||
parseRespIterDone // Done with parsing the response.
|
||||
)
|
||||
|
||||
type parseRespState byte
|
||||
|
||||
const (
|
||||
parseRespStateNormal parseRespState = iota // Normal response state.
|
||||
parseRespStateCancel // Query is canceled, wait for server to confirm.
|
||||
parseRespStateClosing // Waiting for tokens to come through.
|
||||
)
|
||||
|
||||
type parseResp struct {
|
||||
sess *tdsSession
|
||||
ctxDone <-chan struct{}
|
||||
state parseRespState
|
||||
cancelError error
|
||||
}
|
||||
|
||||
func (ts *parseResp) sendAttention(ch chan tokenStruct) parseRespIter {
|
||||
if err := sendAttention(ts.sess.buf); err != nil {
|
||||
ts.dlogf("failed to send attention signal %v", err)
|
||||
ch <- err
|
||||
return parseRespIterDone
|
||||
}
|
||||
ts.state = parseRespStateCancel
|
||||
return parseRespIterContinue
|
||||
}
|
||||
|
||||
func (ts *parseResp) dlog(msg string) {
|
||||
if ts.sess.logFlags&logDebug != 0 {
|
||||
ts.sess.log.Println(msg)
|
||||
}
|
||||
}
|
||||
func (ts *parseResp) dlogf(f string, v ...interface{}) {
|
||||
if ts.sess.logFlags&logDebug != 0 {
|
||||
ts.sess.log.Printf(f, v...)
|
||||
}
|
||||
}
|
||||
|
||||
func (ts *parseResp) iter(ctx context.Context, ch chan tokenStruct, tokChan chan tokenStruct) parseRespIter {
|
||||
switch ts.state {
|
||||
default:
|
||||
panic("unknown state")
|
||||
case parseRespStateNormal:
|
||||
select {
|
||||
case tok, ok := <-tokChan:
|
||||
if !ok {
|
||||
ts.dlog("response finished")
|
||||
return parseRespIterDone
|
||||
}
|
||||
if err, ok := tok.(net.Error); ok && err.Timeout() {
|
||||
ts.cancelError = err
|
||||
ts.dlog("got timeout error, sending attention signal to server")
|
||||
return ts.sendAttention(ch)
|
||||
}
|
||||
// Pass the token along.
|
||||
ch <- tok
|
||||
return parseRespIterContinue
|
||||
|
||||
case <-ts.ctxDone:
|
||||
ts.ctxDone = nil
|
||||
ts.dlog("got cancel message, sending attention signal to server")
|
||||
return ts.sendAttention(ch)
|
||||
}
|
||||
case parseRespStateCancel: // Read all responses until a DONE or error is received.Auth
|
||||
select {
|
||||
case tok, ok := <-tokChan:
|
||||
if !ok {
|
||||
ts.dlog("response finished but waiting for attention ack")
|
||||
return parseRespIterNext
|
||||
}
|
||||
switch tok := tok.(type) {
|
||||
default:
|
||||
// Ignore all other tokens while waiting.
|
||||
// The TDS spec says other tokens may arrive after an attention
|
||||
// signal is sent. Ignore these tokens and continue looking for
|
||||
// a DONE with attention confirm mark.
|
||||
case doneStruct:
|
||||
if tok.Status&doneAttn != 0 {
|
||||
ts.dlog("got cancellation confirmation from server")
|
||||
if ts.cancelError != nil {
|
||||
ch <- ts.cancelError
|
||||
ts.cancelError = nil
|
||||
} else {
|
||||
ch <- ctx.Err()
|
||||
}
|
||||
return parseRespIterDone
|
||||
}
|
||||
|
||||
// If an error happens during cancel, pass it along and just stop.
|
||||
// We are uncertain to receive more tokens.
|
||||
case error:
|
||||
ch <- tok
|
||||
ts.state = parseRespStateClosing
|
||||
}
|
||||
return parseRespIterContinue
|
||||
case <-ts.ctxDone:
|
||||
ts.ctxDone = nil
|
||||
ts.state = parseRespStateClosing
|
||||
return parseRespIterContinue
|
||||
}
|
||||
case parseRespStateClosing: // Wait for current token chan to close.
|
||||
if _, ok := <-tokChan; !ok {
|
||||
ts.dlog("response finished")
|
||||
return parseRespIterDone
|
||||
}
|
||||
return parseRespIterContinue
|
||||
}
|
||||
}
|
||||
|
||||
func processResponse(ctx context.Context, sess *tdsSession, ch chan tokenStruct, outs map[string]interface{}) {
|
||||
ts := &parseResp{
|
||||
sess: sess,
|
||||
ctxDone: ctx.Done(),
|
||||
}
|
||||
defer func() {
|
||||
// Ensure any remaining error is piped through
|
||||
// or the query may look like it executed when it actually failed.
|
||||
if ts.cancelError != nil {
|
||||
ch <- ts.cancelError
|
||||
ts.cancelError = nil
|
||||
}
|
||||
close(ch)
|
||||
}()
|
||||
|
||||
// Loop over multiple responses.
|
||||
for {
|
||||
ts.dlog("initiating response reading")
|
||||
|
||||
tokChan := make(chan tokenStruct)
|
||||
go processSingleResponse(sess, tokChan, outs)
|
||||
|
||||
// Loop over multiple tokens in response.
|
||||
tokensLoop:
|
||||
for {
|
||||
switch ts.iter(ctx, ch, tokChan) {
|
||||
case parseRespIterContinue:
|
||||
// Nothing, continue to next token.
|
||||
case parseRespIterNext:
|
||||
break tokensLoop
|
||||
case parseRespIterDone:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
53
vendor/github.com/denisenkom/go-mssqldb/token_string.go
generated
vendored
Normal file
53
vendor/github.com/denisenkom/go-mssqldb/token_string.go
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Code generated by "stringer -type token"; DO NOT EDIT
|
||||
|
||||
package mssql
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
_token_name_0 = "tokenReturnStatus"
|
||||
_token_name_1 = "tokenColMetadata"
|
||||
_token_name_2 = "tokenOrdertokenErrortokenInfo"
|
||||
_token_name_3 = "tokenLoginAck"
|
||||
_token_name_4 = "tokenRowtokenNbcRow"
|
||||
_token_name_5 = "tokenEnvChange"
|
||||
_token_name_6 = "tokenSSPI"
|
||||
_token_name_7 = "tokenDonetokenDoneProctokenDoneInProc"
|
||||
)
|
||||
|
||||
var (
|
||||
_token_index_0 = [...]uint8{0, 17}
|
||||
_token_index_1 = [...]uint8{0, 16}
|
||||
_token_index_2 = [...]uint8{0, 10, 20, 29}
|
||||
_token_index_3 = [...]uint8{0, 13}
|
||||
_token_index_4 = [...]uint8{0, 8, 19}
|
||||
_token_index_5 = [...]uint8{0, 14}
|
||||
_token_index_6 = [...]uint8{0, 9}
|
||||
_token_index_7 = [...]uint8{0, 9, 22, 37}
|
||||
)
|
||||
|
||||
func (i token) String() string {
|
||||
switch {
|
||||
case i == 121:
|
||||
return _token_name_0
|
||||
case i == 129:
|
||||
return _token_name_1
|
||||
case 169 <= i && i <= 171:
|
||||
i -= 169
|
||||
return _token_name_2[_token_index_2[i]:_token_index_2[i+1]]
|
||||
case i == 173:
|
||||
return _token_name_3
|
||||
case 209 <= i && i <= 210:
|
||||
i -= 209
|
||||
return _token_name_4[_token_index_4[i]:_token_index_4[i+1]]
|
||||
case i == 227:
|
||||
return _token_name_5
|
||||
case i == 237:
|
||||
return _token_name_6
|
||||
case 253 <= i && i <= 255:
|
||||
i -= 253
|
||||
return _token_name_7[_token_index_7[i]:_token_index_7[i+1]]
|
||||
default:
|
||||
return fmt.Sprintf("token(%d)", i)
|
||||
}
|
||||
}
|
110
vendor/github.com/denisenkom/go-mssqldb/tran.go
generated
vendored
Normal file
110
vendor/github.com/denisenkom/go-mssqldb/tran.go
generated
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
package mssql
|
||||
|
||||
// Transaction Manager requests
|
||||
// http://msdn.microsoft.com/en-us/library/dd339887.aspx
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
)
|
||||
|
||||
const (
|
||||
tmGetDtcAddr = 0
|
||||
tmPropagateXact = 1
|
||||
tmBeginXact = 5
|
||||
tmPromoteXact = 6
|
||||
tmCommitXact = 7
|
||||
tmRollbackXact = 8
|
||||
tmSaveXact = 9
|
||||
)
|
||||
|
||||
type isoLevel uint8
|
||||
|
||||
const (
|
||||
isolationUseCurrent isoLevel = 0
|
||||
isolationReadUncommited = 1
|
||||
isolationReadCommited = 2
|
||||
isolationRepeatableRead = 3
|
||||
isolationSerializable = 4
|
||||
isolationSnapshot = 5
|
||||
)
|
||||
|
||||
func sendBeginXact(buf *tdsBuffer, headers []headerStruct, isolation isoLevel, name string, resetSession bool) (err error) {
|
||||
buf.BeginPacket(packTransMgrReq, resetSession)
|
||||
writeAllHeaders(buf, headers)
|
||||
var rqtype uint16 = tmBeginXact
|
||||
err = binary.Write(buf, binary.LittleEndian, &rqtype)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = binary.Write(buf, binary.LittleEndian, &isolation)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = writeBVarChar(buf, name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return buf.FinishPacket()
|
||||
}
|
||||
|
||||
const (
|
||||
fBeginXact = 1
|
||||
)
|
||||
|
||||
func sendCommitXact(buf *tdsBuffer, headers []headerStruct, name string, flags uint8, isolation uint8, newname string, resetSession bool) error {
|
||||
buf.BeginPacket(packTransMgrReq, resetSession)
|
||||
writeAllHeaders(buf, headers)
|
||||
var rqtype uint16 = tmCommitXact
|
||||
err := binary.Write(buf, binary.LittleEndian, &rqtype)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = writeBVarChar(buf, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = binary.Write(buf, binary.LittleEndian, &flags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if flags&fBeginXact != 0 {
|
||||
err = binary.Write(buf, binary.LittleEndian, &isolation)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = writeBVarChar(buf, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return buf.FinishPacket()
|
||||
}
|
||||
|
||||
func sendRollbackXact(buf *tdsBuffer, headers []headerStruct, name string, flags uint8, isolation uint8, newname string, resetSession bool) error {
|
||||
buf.BeginPacket(packTransMgrReq, resetSession)
|
||||
writeAllHeaders(buf, headers)
|
||||
var rqtype uint16 = tmRollbackXact
|
||||
err := binary.Write(buf, binary.LittleEndian, &rqtype)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = writeBVarChar(buf, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = binary.Write(buf, binary.LittleEndian, &flags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if flags&fBeginXact != 0 {
|
||||
err = binary.Write(buf, binary.LittleEndian, &isolation)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = writeBVarChar(buf, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return buf.FinishPacket()
|
||||
}
|
167
vendor/github.com/denisenkom/go-mssqldb/tvp_go19.go
generated
vendored
Normal file
167
vendor/github.com/denisenkom/go-mssqldb/tvp_go19.go
generated
vendored
Normal file
|
@ -0,0 +1,167 @@
|
|||
// +build go1.9
|
||||
|
||||
package mssql
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrorEmptyTVPName = errors.New("TVPTypeName must not be empty")
|
||||
ErrorTVPTypeSlice = errors.New("TVPType must be slice type")
|
||||
ErrorTVPTypeSliceIsEmpty = errors.New("TVPType mustn't be null value")
|
||||
)
|
||||
|
||||
//TVPType is driver type, which allows supporting Table Valued Parameters (TVP) in SQL Server
|
||||
type TVPType struct {
|
||||
//TVP param name, mustn't be default value
|
||||
TVPTypeName string
|
||||
//TVP scheme name
|
||||
TVPScheme string
|
||||
//TVP Value. Param must be the slice, mustn't be nil
|
||||
TVPValue interface{}
|
||||
}
|
||||
|
||||
func (tvp TVPType) check() error {
|
||||
if len(tvp.TVPTypeName) == 0 {
|
||||
return ErrorEmptyTVPName
|
||||
}
|
||||
valueOf := reflect.ValueOf(tvp.TVPValue)
|
||||
if valueOf.Kind() != reflect.Slice {
|
||||
return ErrorTVPTypeSlice
|
||||
}
|
||||
if valueOf.IsNil() {
|
||||
return ErrorTVPTypeSliceIsEmpty
|
||||
}
|
||||
if reflect.TypeOf(tvp.TVPValue).Elem().Kind() != reflect.Struct {
|
||||
return ErrorTVPTypeSlice
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tvp TVPType) encode() ([]byte, error) {
|
||||
columnStr, err := tvp.columnTypes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
preparedBuffer := make([]byte, 0, 20+(10*len(columnStr)))
|
||||
buf := bytes.NewBuffer(preparedBuffer)
|
||||
err = writeBVarChar(buf, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
writeBVarChar(buf, tvp.TVPScheme)
|
||||
writeBVarChar(buf, tvp.TVPTypeName)
|
||||
|
||||
binary.Write(buf, binary.LittleEndian, uint16(len(columnStr)))
|
||||
|
||||
for i, column := range columnStr {
|
||||
binary.Write(buf, binary.LittleEndian, uint32(column.UserType))
|
||||
binary.Write(buf, binary.LittleEndian, uint16(column.Flags))
|
||||
writeTypeInfo(buf, &columnStr[i].ti)
|
||||
writeBVarChar(buf, "")
|
||||
}
|
||||
buf.WriteByte(_TVP_END_TOKEN)
|
||||
conn := new(Conn)
|
||||
conn.sess = new(tdsSession)
|
||||
conn.sess.loginAck = loginAckStruct{TDSVersion: verTDS73}
|
||||
stmt := &Stmt{
|
||||
c: conn,
|
||||
}
|
||||
|
||||
val := reflect.ValueOf(tvp.TVPValue)
|
||||
for i := 0; i < val.Len(); i++ {
|
||||
refStr := reflect.ValueOf(val.Index(i).Interface())
|
||||
buf.WriteByte(_TVP_ROW_TOKEN)
|
||||
for j := 0; j < refStr.NumField(); j++ {
|
||||
field := refStr.Field(j)
|
||||
tvpVal := field.Interface()
|
||||
valOf := reflect.ValueOf(tvpVal)
|
||||
elemKind := field.Kind()
|
||||
if elemKind == reflect.Ptr && valOf.IsNil() {
|
||||
switch tvpVal.(type) {
|
||||
case *bool, *time.Time, *int8, *int16, *int32, *int64, *float32, *float64:
|
||||
binary.Write(buf, binary.LittleEndian, uint8(0))
|
||||
continue
|
||||
default:
|
||||
binary.Write(buf, binary.LittleEndian, uint64(_PLP_NULL))
|
||||
continue
|
||||
}
|
||||
}
|
||||
if elemKind == reflect.Slice && valOf.IsNil() {
|
||||
binary.Write(buf, binary.LittleEndian, uint64(_PLP_NULL))
|
||||
continue
|
||||
}
|
||||
|
||||
cval, err := convertInputParameter(tvpVal)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to convert tvp parameter row col: %s", err)
|
||||
}
|
||||
param, err := stmt.makeParam(cval)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to make tvp parameter row col: %s", err)
|
||||
}
|
||||
columnStr[j].ti.Writer(buf, param.ti, param.buffer)
|
||||
}
|
||||
}
|
||||
buf.WriteByte(_TVP_END_TOKEN)
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func (tvp TVPType) columnTypes() ([]columnStruct, error) {
|
||||
val := reflect.ValueOf(tvp.TVPValue)
|
||||
var firstRow interface{}
|
||||
if val.Len() != 0 {
|
||||
firstRow = val.Index(0).Interface()
|
||||
} else {
|
||||
firstRow = reflect.New(reflect.TypeOf(tvp.TVPValue).Elem()).Elem().Interface()
|
||||
}
|
||||
|
||||
tvpRow := reflect.TypeOf(firstRow)
|
||||
columnCount := tvpRow.NumField()
|
||||
defaultValues := make([]interface{}, 0, columnCount)
|
||||
|
||||
for i := 0; i < columnCount; i++ {
|
||||
typeField := tvpRow.Field(i).Type
|
||||
if typeField.Kind() == reflect.Ptr {
|
||||
v := reflect.New(typeField.Elem())
|
||||
defaultValues = append(defaultValues, v.Interface())
|
||||
continue
|
||||
}
|
||||
defaultValues = append(defaultValues, reflect.Zero(typeField).Interface())
|
||||
}
|
||||
|
||||
conn := new(Conn)
|
||||
conn.sess = new(tdsSession)
|
||||
conn.sess.loginAck = loginAckStruct{TDSVersion: verTDS73}
|
||||
stmt := &Stmt{
|
||||
c: conn,
|
||||
}
|
||||
|
||||
columnConfiguration := make([]columnStruct, 0, columnCount)
|
||||
for index, val := range defaultValues {
|
||||
cval, err := convertInputParameter(val)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to convert tvp parameter row %d col %d: %s", index, val, err)
|
||||
}
|
||||
param, err := stmt.makeParam(cval)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
column := columnStruct{
|
||||
ti: param.ti,
|
||||
}
|
||||
switch param.ti.TypeId {
|
||||
case typeNVarChar, typeBigVarBin:
|
||||
column.ti.Size = 0
|
||||
}
|
||||
columnConfiguration = append(columnConfiguration, column)
|
||||
}
|
||||
|
||||
return columnConfiguration, nil
|
||||
}
|
1584
vendor/github.com/denisenkom/go-mssqldb/types.go
generated
vendored
Normal file
1584
vendor/github.com/denisenkom/go-mssqldb/types.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
74
vendor/github.com/denisenkom/go-mssqldb/uniqueidentifier.go
generated
vendored
Normal file
74
vendor/github.com/denisenkom/go-mssqldb/uniqueidentifier.go
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
package mssql
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type UniqueIdentifier [16]byte
|
||||
|
||||
func (u *UniqueIdentifier) Scan(v interface{}) error {
|
||||
reverse := func(b []byte) {
|
||||
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
|
||||
b[i], b[j] = b[j], b[i]
|
||||
}
|
||||
}
|
||||
|
||||
switch vt := v.(type) {
|
||||
case []byte:
|
||||
if len(vt) != 16 {
|
||||
return errors.New("mssql: invalid UniqueIdentifier length")
|
||||
}
|
||||
|
||||
var raw UniqueIdentifier
|
||||
|
||||
copy(raw[:], vt)
|
||||
|
||||
reverse(raw[0:4])
|
||||
reverse(raw[4:6])
|
||||
reverse(raw[6:8])
|
||||
*u = raw
|
||||
|
||||
return nil
|
||||
case string:
|
||||
if len(vt) != 36 {
|
||||
return errors.New("mssql: invalid UniqueIdentifier string length")
|
||||
}
|
||||
|
||||
b := []byte(vt)
|
||||
for i, c := range b {
|
||||
switch c {
|
||||
case '-':
|
||||
b = append(b[:i], b[i+1:]...)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := hex.Decode(u[:], []byte(b))
|
||||
return err
|
||||
default:
|
||||
return fmt.Errorf("mssql: cannot convert %T to UniqueIdentifier", v)
|
||||
}
|
||||
}
|
||||
|
||||
func (u UniqueIdentifier) Value() (driver.Value, error) {
|
||||
reverse := func(b []byte) {
|
||||
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
|
||||
b[i], b[j] = b[j], b[i]
|
||||
}
|
||||
}
|
||||
|
||||
raw := make([]byte, len(u))
|
||||
copy(raw, u[:])
|
||||
|
||||
reverse(raw[0:4])
|
||||
reverse(raw[4:6])
|
||||
reverse(raw[6:8])
|
||||
|
||||
return raw, nil
|
||||
}
|
||||
|
||||
func (u UniqueIdentifier) String() string {
|
||||
return fmt.Sprintf("%X-%X-%X-%X-%X", u[0:4], u[4:6], u[6:8], u[8:10], u[10:])
|
||||
}
|
118
vendor/golang.org/x/crypto/md4/md4.go
generated
vendored
Normal file
118
vendor/golang.org/x/crypto/md4/md4.go
generated
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package md4 implements the MD4 hash algorithm as defined in RFC 1320.
|
||||
package md4 // import "golang.org/x/crypto/md4"
|
||||
|
||||
import (
|
||||
"crypto"
|
||||
"hash"
|
||||
)
|
||||
|
||||
func init() {
|
||||
crypto.RegisterHash(crypto.MD4, New)
|
||||
}
|
||||
|
||||
// The size of an MD4 checksum in bytes.
|
||||
const Size = 16
|
||||
|
||||
// The blocksize of MD4 in bytes.
|
||||
const BlockSize = 64
|
||||
|
||||
const (
|
||||
_Chunk = 64
|
||||
_Init0 = 0x67452301
|
||||
_Init1 = 0xEFCDAB89
|
||||
_Init2 = 0x98BADCFE
|
||||
_Init3 = 0x10325476
|
||||
)
|
||||
|
||||
// digest represents the partial evaluation of a checksum.
|
||||
type digest struct {
|
||||
s [4]uint32
|
||||
x [_Chunk]byte
|
||||
nx int
|
||||
len uint64
|
||||
}
|
||||
|
||||
func (d *digest) Reset() {
|
||||
d.s[0] = _Init0
|
||||
d.s[1] = _Init1
|
||||
d.s[2] = _Init2
|
||||
d.s[3] = _Init3
|
||||
d.nx = 0
|
||||
d.len = 0
|
||||
}
|
||||
|
||||
// New returns a new hash.Hash computing the MD4 checksum.
|
||||
func New() hash.Hash {
|
||||
d := new(digest)
|
||||
d.Reset()
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *digest) Size() int { return Size }
|
||||
|
||||
func (d *digest) BlockSize() int { return BlockSize }
|
||||
|
||||
func (d *digest) Write(p []byte) (nn int, err error) {
|
||||
nn = len(p)
|
||||
d.len += uint64(nn)
|
||||
if d.nx > 0 {
|
||||
n := len(p)
|
||||
if n > _Chunk-d.nx {
|
||||
n = _Chunk - d.nx
|
||||
}
|
||||
for i := 0; i < n; i++ {
|
||||
d.x[d.nx+i] = p[i]
|
||||
}
|
||||
d.nx += n
|
||||
if d.nx == _Chunk {
|
||||
_Block(d, d.x[0:])
|
||||
d.nx = 0
|
||||
}
|
||||
p = p[n:]
|
||||
}
|
||||
n := _Block(d, p)
|
||||
p = p[n:]
|
||||
if len(p) > 0 {
|
||||
d.nx = copy(d.x[:], p)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (d0 *digest) Sum(in []byte) []byte {
|
||||
// Make a copy of d0, so that caller can keep writing and summing.
|
||||
d := new(digest)
|
||||
*d = *d0
|
||||
|
||||
// Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.
|
||||
len := d.len
|
||||
var tmp [64]byte
|
||||
tmp[0] = 0x80
|
||||
if len%64 < 56 {
|
||||
d.Write(tmp[0 : 56-len%64])
|
||||
} else {
|
||||
d.Write(tmp[0 : 64+56-len%64])
|
||||
}
|
||||
|
||||
// Length in bits.
|
||||
len <<= 3
|
||||
for i := uint(0); i < 8; i++ {
|
||||
tmp[i] = byte(len >> (8 * i))
|
||||
}
|
||||
d.Write(tmp[0:8])
|
||||
|
||||
if d.nx != 0 {
|
||||
panic("d.nx != 0")
|
||||
}
|
||||
|
||||
for _, s := range d.s {
|
||||
in = append(in, byte(s>>0))
|
||||
in = append(in, byte(s>>8))
|
||||
in = append(in, byte(s>>16))
|
||||
in = append(in, byte(s>>24))
|
||||
}
|
||||
return in
|
||||
}
|
89
vendor/golang.org/x/crypto/md4/md4block.go
generated
vendored
Normal file
89
vendor/golang.org/x/crypto/md4/md4block.go
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// MD4 block step.
|
||||
// In its own file so that a faster assembly or C version
|
||||
// can be substituted easily.
|
||||
|
||||
package md4
|
||||
|
||||
var shift1 = []uint{3, 7, 11, 19}
|
||||
var shift2 = []uint{3, 5, 9, 13}
|
||||
var shift3 = []uint{3, 9, 11, 15}
|
||||
|
||||
var xIndex2 = []uint{0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}
|
||||
var xIndex3 = []uint{0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}
|
||||
|
||||
func _Block(dig *digest, p []byte) int {
|
||||
a := dig.s[0]
|
||||
b := dig.s[1]
|
||||
c := dig.s[2]
|
||||
d := dig.s[3]
|
||||
n := 0
|
||||
var X [16]uint32
|
||||
for len(p) >= _Chunk {
|
||||
aa, bb, cc, dd := a, b, c, d
|
||||
|
||||
j := 0
|
||||
for i := 0; i < 16; i++ {
|
||||
X[i] = uint32(p[j]) | uint32(p[j+1])<<8 | uint32(p[j+2])<<16 | uint32(p[j+3])<<24
|
||||
j += 4
|
||||
}
|
||||
|
||||
// If this needs to be made faster in the future,
|
||||
// the usual trick is to unroll each of these
|
||||
// loops by a factor of 4; that lets you replace
|
||||
// the shift[] lookups with constants and,
|
||||
// with suitable variable renaming in each
|
||||
// unrolled body, delete the a, b, c, d = d, a, b, c
|
||||
// (or you can let the optimizer do the renaming).
|
||||
//
|
||||
// The index variables are uint so that % by a power
|
||||
// of two can be optimized easily by a compiler.
|
||||
|
||||
// Round 1.
|
||||
for i := uint(0); i < 16; i++ {
|
||||
x := i
|
||||
s := shift1[i%4]
|
||||
f := ((c ^ d) & b) ^ d
|
||||
a += f + X[x]
|
||||
a = a<<s | a>>(32-s)
|
||||
a, b, c, d = d, a, b, c
|
||||
}
|
||||
|
||||
// Round 2.
|
||||
for i := uint(0); i < 16; i++ {
|
||||
x := xIndex2[i]
|
||||
s := shift2[i%4]
|
||||
g := (b & c) | (b & d) | (c & d)
|
||||
a += g + X[x] + 0x5a827999
|
||||
a = a<<s | a>>(32-s)
|
||||
a, b, c, d = d, a, b, c
|
||||
}
|
||||
|
||||
// Round 3.
|
||||
for i := uint(0); i < 16; i++ {
|
||||
x := xIndex3[i]
|
||||
s := shift3[i%4]
|
||||
h := b ^ c ^ d
|
||||
a += h + X[x] + 0x6ed9eba1
|
||||
a = a<<s | a>>(32-s)
|
||||
a, b, c, d = d, a, b, c
|
||||
}
|
||||
|
||||
a += aa
|
||||
b += bb
|
||||
c += cc
|
||||
d += dd
|
||||
|
||||
p = p[_Chunk:]
|
||||
n += _Chunk
|
||||
}
|
||||
|
||||
dig.s[0] = a
|
||||
dig.s[1] = b
|
||||
dig.s[2] = c
|
||||
dig.s[3] = d
|
||||
return n
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue