├── Godeps ├── Godeps.json ├── Readme └── _workspace │ ├── .gitignore │ └── src │ ├── github.com │ ├── BurntSushi │ │ └── toml │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── COMPATIBLE │ │ │ ├── COPYING │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── cmd │ │ │ ├── toml-test-decoder │ │ │ │ ├── COPYING │ │ │ │ ├── README.md │ │ │ │ └── main.go │ │ │ ├── toml-test-encoder │ │ │ │ ├── COPYING │ │ │ │ ├── README.md │ │ │ │ └── main.go │ │ │ └── tomlv │ │ │ │ ├── COPYING │ │ │ │ ├── README.md │ │ │ │ └── main.go │ │ │ ├── decode.go │ │ │ ├── decode_meta.go │ │ │ ├── doc.go │ │ │ ├── encode.go │ │ │ ├── encoding_types.go │ │ │ ├── encoding_types_1.1.go │ │ │ ├── lex.go │ │ │ ├── parse.go │ │ │ ├── session.vim │ │ │ ├── type_check.go │ │ │ └── type_fields.go │ └── zensqlmonitor │ │ └── go-mssqldb │ │ ├── README.md │ │ ├── buf.go │ │ ├── charset.go │ │ ├── collation.go │ │ ├── cp1250.go │ │ ├── cp1251.go │ │ ├── cp1252.go │ │ ├── cp1253.go │ │ ├── cp1254.go │ │ ├── cp1255.go │ │ ├── cp1256.go │ │ ├── cp1257.go │ │ ├── cp1258.go │ │ ├── cp437.go │ │ ├── cp850.go │ │ ├── cp874.go │ │ ├── cp932.go │ │ ├── cp936.go │ │ ├── cp949.go │ │ ├── cp950.go │ │ ├── decimal.go │ │ ├── error.go │ │ ├── examples │ │ ├── simple.go │ │ └── tsql.go │ │ ├── log.go │ │ ├── mssql.go │ │ ├── mssql_go1.3.go │ │ ├── mssql_go1.3pre.go │ │ ├── net.go │ │ ├── ntlm.go │ │ ├── parser.go │ │ ├── rpc.go │ │ ├── sspi_windows.go │ │ ├── tds.go │ │ ├── token.go │ │ ├── tran.go │ │ └── types.go │ └── golang.org │ └── x │ └── crypto │ ├── LICENSE │ ├── PATENTS │ └── md4 │ ├── md4.go │ └── md4block.go ├── LICENSE ├── README.md ├── config └── config.go ├── etl └── etl.go ├── grafana └── influxdb-sqlserver-dashboard ├── influxdb-sqlserver ├── influxdb-sqlserver.conf ├── influxdb-sqlserver.go ├── log ├── console.go ├── file.go └── log.go ├── scripts ├── influxdb-sqlserver ├── influxdb-sqlserver.service ├── init.sh └── package.sh └── sqlscripts ├── getcpu.sql ├── getdatabaseio.sql ├── getdatabasesizetrend.sql ├── getmemory.sql ├── getmemoryclerksplit.sql ├── getperfcounters.sql ├── getperfmetrics.sql ├── getwaitstats.sql └── getwaitstatscat.sql /Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/zensqlmonitor/influxdb-sqlserver", 3 | "GoVersion": "go1.5", 4 | "Deps": [ 5 | { 6 | "ImportPath": "github.com/BurntSushi/toml", 7 | "Comment": "v0.1.0-21-g056c9bc", 8 | "Rev": "056c9bc7be7190eaa7715723883caffa5f8fa3e4" 9 | }, 10 | { 11 | "ImportPath": "github.com/zensqlmonitor/go-mssqldb", 12 | "Rev": "ffe5510c6fa5e15e6d983210ab501c815b56b363" 13 | }, 14 | { 15 | "ImportPath": "golang.org/x/crypto/md4", 16 | "Rev": "f18420efc3b4f8e9f3d51f6bd2476e92c46260e9" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /Godeps/_workspace/.gitignore: -------------------------------------------------------------------------------- 1 | /pkg 2 | /bin 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/.gitignore: -------------------------------------------------------------------------------- 1 | TAGS 2 | tags 3 | .*.swp 4 | tomlcheck/tomlcheck 5 | toml.test 6 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.1 4 | - 1.2 5 | - tip 6 | install: 7 | - go install ./... 8 | - go get github.com/BurntSushi/toml-test 9 | script: 10 | - export PATH="$PATH:$HOME/gopath/bin" 11 | - make test 12 | 13 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/COMPATIBLE: -------------------------------------------------------------------------------- 1 | Compatible with TOML version 2 | [v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) 3 | 4 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/Makefile: -------------------------------------------------------------------------------- 1 | install: 2 | go install ./... 3 | 4 | test: install 5 | go test -v 6 | toml-test toml-test-decoder 7 | toml-test -encoder toml-test-encoder 8 | 9 | fmt: 10 | gofmt -w *.go */*.go 11 | colcheck *.go */*.go 12 | 13 | tags: 14 | find ./ -name '*.go' -print0 | xargs -0 gotags > TAGS 15 | 16 | push: 17 | git push origin master 18 | git push github master 19 | 20 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/README.md: -------------------------------------------------------------------------------- 1 | ## TOML parser and encoder for Go with reflection 2 | 3 | TOML stands for Tom's Obvious, Minimal Language. This Go package provides a 4 | reflection interface similar to Go's standard library `json` and `xml` 5 | packages. This package also supports the `encoding.TextUnmarshaler` and 6 | `encoding.TextMarshaler` interfaces so that you can define custom data 7 | representations. (There is an example of this below.) 8 | 9 | Spec: https://github.com/mojombo/toml 10 | 11 | Compatible with TOML version 12 | [v0.2.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.2.0.md) 13 | 14 | Documentation: http://godoc.org/github.com/BurntSushi/toml 15 | 16 | Installation: 17 | 18 | ```bash 19 | go get github.com/BurntSushi/toml 20 | ``` 21 | 22 | Try the toml validator: 23 | 24 | ```bash 25 | go get github.com/BurntSushi/toml/cmd/tomlv 26 | tomlv some-toml-file.toml 27 | ``` 28 | 29 | [![Build status](https://api.travis-ci.org/BurntSushi/toml.png)](https://travis-ci.org/BurntSushi/toml) 30 | 31 | 32 | ### Testing 33 | 34 | This package passes all tests in 35 | [toml-test](https://github.com/BurntSushi/toml-test) for both the decoder 36 | and the encoder. 37 | 38 | ### Examples 39 | 40 | This package works similarly to how the Go standard library handles `XML` 41 | and `JSON`. Namely, data is loaded into Go values via reflection. 42 | 43 | For the simplest example, consider some TOML file as just a list of keys 44 | and values: 45 | 46 | ```toml 47 | Age = 25 48 | Cats = [ "Cauchy", "Plato" ] 49 | Pi = 3.14 50 | Perfection = [ 6, 28, 496, 8128 ] 51 | DOB = 1987-07-05T05:45:00Z 52 | ``` 53 | 54 | Which could be defined in Go as: 55 | 56 | ```go 57 | type Config struct { 58 | Age int 59 | Cats []string 60 | Pi float64 61 | Perfection []int 62 | DOB time.Time // requires `import time` 63 | } 64 | ``` 65 | 66 | And then decoded with: 67 | 68 | ```go 69 | var conf Config 70 | if _, err := toml.Decode(tomlData, &conf); err != nil { 71 | // handle error 72 | } 73 | ``` 74 | 75 | You can also use struct tags if your struct field name doesn't map to a TOML 76 | key value directly: 77 | 78 | ```toml 79 | some_key_NAME = "wat" 80 | ``` 81 | 82 | ```go 83 | type TOML struct { 84 | ObscureKey string `toml:"some_key_NAME"` 85 | } 86 | ``` 87 | 88 | ### Using the `encoding.TextUnmarshaler` interface 89 | 90 | Here's an example that automatically parses duration strings into 91 | `time.Duration` values: 92 | 93 | ```toml 94 | [[song]] 95 | name = "Thunder Road" 96 | duration = "4m49s" 97 | 98 | [[song]] 99 | name = "Stairway to Heaven" 100 | duration = "8m03s" 101 | ``` 102 | 103 | Which can be decoded with: 104 | 105 | ```go 106 | type song struct { 107 | Name string 108 | Duration duration 109 | } 110 | type songs struct { 111 | Song []song 112 | } 113 | var favorites songs 114 | if _, err := toml.Decode(blob, &favorites); err != nil { 115 | log.Fatal(err) 116 | } 117 | 118 | for _, s := range favorites.Song { 119 | fmt.Printf("%s (%s)\n", s.Name, s.Duration) 120 | } 121 | ``` 122 | 123 | And you'll also need a `duration` type that satisfies the 124 | `encoding.TextUnmarshaler` interface: 125 | 126 | ```go 127 | type duration struct { 128 | time.Duration 129 | } 130 | 131 | func (d *duration) UnmarshalText(text []byte) error { 132 | var err error 133 | d.Duration, err = time.ParseDuration(string(text)) 134 | return err 135 | } 136 | ``` 137 | 138 | ### More complex usage 139 | 140 | Here's an example of how to load the example from the official spec page: 141 | 142 | ```toml 143 | # This is a TOML document. Boom. 144 | 145 | title = "TOML Example" 146 | 147 | [owner] 148 | name = "Tom Preston-Werner" 149 | organization = "GitHub" 150 | bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." 151 | dob = 1979-05-27T07:32:00Z # First class dates? Why not? 152 | 153 | [database] 154 | server = "192.168.1.1" 155 | ports = [ 8001, 8001, 8002 ] 156 | connection_max = 5000 157 | enabled = true 158 | 159 | [servers] 160 | 161 | # You can indent as you please. Tabs or spaces. TOML don't care. 162 | [servers.alpha] 163 | ip = "10.0.0.1" 164 | dc = "eqdc10" 165 | 166 | [servers.beta] 167 | ip = "10.0.0.2" 168 | dc = "eqdc10" 169 | 170 | [clients] 171 | data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it 172 | 173 | # Line breaks are OK when inside arrays 174 | hosts = [ 175 | "alpha", 176 | "omega" 177 | ] 178 | ``` 179 | 180 | And the corresponding Go types are: 181 | 182 | ```go 183 | type tomlConfig struct { 184 | Title string 185 | Owner ownerInfo 186 | DB database `toml:"database"` 187 | Servers map[string]server 188 | Clients clients 189 | } 190 | 191 | type ownerInfo struct { 192 | Name string 193 | Org string `toml:"organization"` 194 | Bio string 195 | DOB time.Time 196 | } 197 | 198 | type database struct { 199 | Server string 200 | Ports []int 201 | ConnMax int `toml:"connection_max"` 202 | Enabled bool 203 | } 204 | 205 | type server struct { 206 | IP string 207 | DC string 208 | } 209 | 210 | type clients struct { 211 | Data [][]interface{} 212 | Hosts []string 213 | } 214 | ``` 215 | 216 | Note that a case insensitive match will be tried if an exact match can't be 217 | found. 218 | 219 | A working example of the above can be found in `_examples/example.{go,toml}`. 220 | 221 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/cmd/toml-test-decoder/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/cmd/toml-test-decoder/README.md: -------------------------------------------------------------------------------- 1 | # Implements the TOML test suite interface 2 | 3 | This is an implementation of the interface expected by 4 | [toml-test](https://github.com/BurntSushi/toml-test) for my 5 | [toml parser written in Go](https://github.com/BurntSushi/toml). 6 | In particular, it maps TOML data on `stdin` to a JSON format on `stdout`. 7 | 8 | 9 | Compatible with TOML version 10 | [v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) 11 | 12 | Compatible with `toml-test` version 13 | [v0.2.0](https://github.com/BurntSushi/toml-test/tree/v0.2.0) 14 | 15 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/cmd/toml-test-decoder/main.go: -------------------------------------------------------------------------------- 1 | // Command toml-test-decoder satisfies the toml-test interface for testing 2 | // TOML decoders. Namely, it accepts TOML on stdin and outputs JSON on stdout. 3 | package main 4 | 5 | import ( 6 | "encoding/json" 7 | "flag" 8 | "fmt" 9 | "log" 10 | "os" 11 | "path" 12 | "time" 13 | 14 | "github.com/zensqlmonitor/influxdb-sqlserver/Godeps/_workspace/src/github.com/BurntSushi/toml" 15 | ) 16 | 17 | func init() { 18 | log.SetFlags(0) 19 | 20 | flag.Usage = usage 21 | flag.Parse() 22 | } 23 | 24 | func usage() { 25 | log.Printf("Usage: %s < toml-file\n", path.Base(os.Args[0])) 26 | flag.PrintDefaults() 27 | 28 | os.Exit(1) 29 | } 30 | 31 | func main() { 32 | if flag.NArg() != 0 { 33 | flag.Usage() 34 | } 35 | 36 | var tmp interface{} 37 | if _, err := toml.DecodeReader(os.Stdin, &tmp); err != nil { 38 | log.Fatalf("Error decoding TOML: %s", err) 39 | } 40 | 41 | typedTmp := translate(tmp) 42 | if err := json.NewEncoder(os.Stdout).Encode(typedTmp); err != nil { 43 | log.Fatalf("Error encoding JSON: %s", err) 44 | } 45 | } 46 | 47 | func translate(tomlData interface{}) interface{} { 48 | switch orig := tomlData.(type) { 49 | case map[string]interface{}: 50 | typed := make(map[string]interface{}, len(orig)) 51 | for k, v := range orig { 52 | typed[k] = translate(v) 53 | } 54 | return typed 55 | case []map[string]interface{}: 56 | typed := make([]map[string]interface{}, len(orig)) 57 | for i, v := range orig { 58 | typed[i] = translate(v).(map[string]interface{}) 59 | } 60 | return typed 61 | case []interface{}: 62 | typed := make([]interface{}, len(orig)) 63 | for i, v := range orig { 64 | typed[i] = translate(v) 65 | } 66 | 67 | // We don't really need to tag arrays, but let's be future proof. 68 | // (If TOML ever supports tuples, we'll need this.) 69 | return tag("array", typed) 70 | case time.Time: 71 | return tag("datetime", orig.Format("2006-01-02T15:04:05Z")) 72 | case bool: 73 | return tag("bool", fmt.Sprintf("%v", orig)) 74 | case int64: 75 | return tag("integer", fmt.Sprintf("%d", orig)) 76 | case float64: 77 | return tag("float", fmt.Sprintf("%v", orig)) 78 | case string: 79 | return tag("string", orig) 80 | } 81 | 82 | panic(fmt.Sprintf("Unknown type: %T", tomlData)) 83 | } 84 | 85 | func tag(typeName string, data interface{}) map[string]interface{} { 86 | return map[string]interface{}{ 87 | "type": typeName, 88 | "value": data, 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/cmd/toml-test-encoder/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/cmd/toml-test-encoder/README.md: -------------------------------------------------------------------------------- 1 | # Implements the TOML test suite interface for TOML encoders 2 | 3 | This is an implementation of the interface expected by 4 | [toml-test](https://github.com/BurntSushi/toml-test) for the 5 | [TOML encoder](https://github.com/BurntSushi/toml). 6 | In particular, it maps JSON data on `stdin` to a TOML format on `stdout`. 7 | 8 | 9 | Compatible with TOML version 10 | [v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) 11 | 12 | Compatible with `toml-test` version 13 | [v0.2.0](https://github.com/BurntSushi/toml-test/tree/v0.2.0) 14 | 15 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/cmd/toml-test-encoder/main.go: -------------------------------------------------------------------------------- 1 | // Command toml-test-encoder satisfies the toml-test interface for testing 2 | // TOML encoders. Namely, it accepts JSON on stdin and outputs TOML on stdout. 3 | package main 4 | 5 | import ( 6 | "encoding/json" 7 | "flag" 8 | "log" 9 | "os" 10 | "path" 11 | "strconv" 12 | "time" 13 | 14 | "github.com/zensqlmonitor/influxdb-sqlserver/Godeps/_workspace/src/github.com/BurntSushi/toml" 15 | ) 16 | 17 | func init() { 18 | log.SetFlags(0) 19 | 20 | flag.Usage = usage 21 | flag.Parse() 22 | } 23 | 24 | func usage() { 25 | log.Printf("Usage: %s < json-file\n", path.Base(os.Args[0])) 26 | flag.PrintDefaults() 27 | 28 | os.Exit(1) 29 | } 30 | 31 | func main() { 32 | if flag.NArg() != 0 { 33 | flag.Usage() 34 | } 35 | 36 | var tmp interface{} 37 | if err := json.NewDecoder(os.Stdin).Decode(&tmp); err != nil { 38 | log.Fatalf("Error decoding JSON: %s", err) 39 | } 40 | 41 | tomlData := translate(tmp) 42 | if err := toml.NewEncoder(os.Stdout).Encode(tomlData); err != nil { 43 | log.Fatalf("Error encoding TOML: %s", err) 44 | } 45 | } 46 | 47 | func translate(typedJson interface{}) interface{} { 48 | switch v := typedJson.(type) { 49 | case map[string]interface{}: 50 | if len(v) == 2 && in("type", v) && in("value", v) { 51 | return untag(v) 52 | } 53 | m := make(map[string]interface{}, len(v)) 54 | for k, v2 := range v { 55 | m[k] = translate(v2) 56 | } 57 | return m 58 | case []interface{}: 59 | tabArray := make([]map[string]interface{}, len(v)) 60 | for i := range v { 61 | if m, ok := translate(v[i]).(map[string]interface{}); ok { 62 | tabArray[i] = m 63 | } else { 64 | log.Fatalf("JSON arrays may only contain objects. This " + 65 | "corresponds to only tables being allowed in " + 66 | "TOML table arrays.") 67 | } 68 | } 69 | return tabArray 70 | } 71 | log.Fatalf("Unrecognized JSON format '%T'.", typedJson) 72 | panic("unreachable") 73 | } 74 | 75 | func untag(typed map[string]interface{}) interface{} { 76 | t := typed["type"].(string) 77 | v := typed["value"] 78 | switch t { 79 | case "string": 80 | return v.(string) 81 | case "integer": 82 | v := v.(string) 83 | n, err := strconv.Atoi(v) 84 | if err != nil { 85 | log.Fatalf("Could not parse '%s' as integer: %s", v, err) 86 | } 87 | return n 88 | case "float": 89 | v := v.(string) 90 | f, err := strconv.ParseFloat(v, 64) 91 | if err != nil { 92 | log.Fatalf("Could not parse '%s' as float64: %s", v, err) 93 | } 94 | return f 95 | case "datetime": 96 | v := v.(string) 97 | t, err := time.Parse("2006-01-02T15:04:05Z", v) 98 | if err != nil { 99 | log.Fatalf("Could not parse '%s' as a datetime: %s", v, err) 100 | } 101 | return t 102 | case "bool": 103 | v := v.(string) 104 | switch v { 105 | case "true": 106 | return true 107 | case "false": 108 | return false 109 | } 110 | log.Fatalf("Could not parse '%s' as a boolean.", v) 111 | case "array": 112 | v := v.([]interface{}) 113 | array := make([]interface{}, len(v)) 114 | for i := range v { 115 | if m, ok := v[i].(map[string]interface{}); ok { 116 | array[i] = untag(m) 117 | } else { 118 | log.Fatalf("Arrays may only contain other arrays or "+ 119 | "primitive values, but found a '%T'.", m) 120 | } 121 | } 122 | return array 123 | } 124 | log.Fatalf("Unrecognized tag type '%s'.", t) 125 | panic("unreachable") 126 | } 127 | 128 | func in(key string, m map[string]interface{}) bool { 129 | _, ok := m[key] 130 | return ok 131 | } 132 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/cmd/tomlv/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/cmd/tomlv/README.md: -------------------------------------------------------------------------------- 1 | # TOML Validator 2 | 3 | If Go is installed, it's simple to try it out: 4 | 5 | ```bash 6 | go get github.com/BurntSushi/toml/cmd/tomlv 7 | tomlv some-toml-file.toml 8 | ``` 9 | 10 | You can see the types of every key in a TOML file with: 11 | 12 | ```bash 13 | tomlv -types some-toml-file.toml 14 | ``` 15 | 16 | At the moment, only one error message is reported at a time. Error messages 17 | include line numbers. No output means that the files given are valid TOML, or 18 | there is a bug in `tomlv`. 19 | 20 | Compatible with TOML version 21 | [v0.1.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.1.0.md) 22 | 23 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/cmd/tomlv/main.go: -------------------------------------------------------------------------------- 1 | // Command tomlv validates TOML documents and prints each key's type. 2 | package main 3 | 4 | import ( 5 | "flag" 6 | "fmt" 7 | "log" 8 | "os" 9 | "path" 10 | "strings" 11 | "text/tabwriter" 12 | 13 | "github.com/zensqlmonitor/influxdb-sqlserver/Godeps/_workspace/src/github.com/BurntSushi/toml" 14 | ) 15 | 16 | var ( 17 | flagTypes = false 18 | ) 19 | 20 | func init() { 21 | log.SetFlags(0) 22 | 23 | flag.BoolVar(&flagTypes, "types", flagTypes, 24 | "When set, the types of every defined key will be shown.") 25 | 26 | flag.Usage = usage 27 | flag.Parse() 28 | } 29 | 30 | func usage() { 31 | log.Printf("Usage: %s toml-file [ toml-file ... ]\n", 32 | path.Base(os.Args[0])) 33 | flag.PrintDefaults() 34 | 35 | os.Exit(1) 36 | } 37 | 38 | func main() { 39 | if flag.NArg() < 1 { 40 | flag.Usage() 41 | } 42 | for _, f := range flag.Args() { 43 | var tmp interface{} 44 | md, err := toml.DecodeFile(f, &tmp) 45 | if err != nil { 46 | log.Fatalf("Error in '%s': %s", f, err) 47 | } 48 | if flagTypes { 49 | printTypes(md) 50 | } 51 | } 52 | } 53 | 54 | func printTypes(md toml.MetaData) { 55 | tabw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) 56 | for _, key := range md.Keys() { 57 | fmt.Fprintf(tabw, "%s%s\t%s\n", 58 | strings.Repeat(" ", len(key)-1), key, md.Type(key...)) 59 | } 60 | tabw.Flush() 61 | } 62 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/decode_meta.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | import "strings" 4 | 5 | // MetaData allows access to meta information about TOML data that may not 6 | // be inferrable via reflection. In particular, whether a key has been defined 7 | // and the TOML type of a key. 8 | type MetaData struct { 9 | mapping map[string]interface{} 10 | types map[string]tomlType 11 | keys []Key 12 | decoded map[string]bool 13 | context Key // Used only during decoding. 14 | } 15 | 16 | // IsDefined returns true if the key given exists in the TOML data. The key 17 | // should be specified hierarchially. e.g., 18 | // 19 | // // access the TOML key 'a.b.c' 20 | // IsDefined("a", "b", "c") 21 | // 22 | // IsDefined will return false if an empty key given. Keys are case sensitive. 23 | func (md *MetaData) IsDefined(key ...string) bool { 24 | if len(key) == 0 { 25 | return false 26 | } 27 | 28 | var hash map[string]interface{} 29 | var ok bool 30 | var hashOrVal interface{} = md.mapping 31 | for _, k := range key { 32 | if hash, ok = hashOrVal.(map[string]interface{}); !ok { 33 | return false 34 | } 35 | if hashOrVal, ok = hash[k]; !ok { 36 | return false 37 | } 38 | } 39 | return true 40 | } 41 | 42 | // Type returns a string representation of the type of the key specified. 43 | // 44 | // Type will return the empty string if given an empty key or a key that 45 | // does not exist. Keys are case sensitive. 46 | func (md *MetaData) Type(key ...string) string { 47 | fullkey := strings.Join(key, ".") 48 | if typ, ok := md.types[fullkey]; ok { 49 | return typ.typeString() 50 | } 51 | return "" 52 | } 53 | 54 | // Key is the type of any TOML key, including key groups. Use (MetaData).Keys 55 | // to get values of this type. 56 | type Key []string 57 | 58 | func (k Key) String() string { 59 | return strings.Join(k, ".") 60 | } 61 | 62 | func (k Key) maybeQuotedAll() string { 63 | var ss []string 64 | for i := range k { 65 | ss = append(ss, k.maybeQuoted(i)) 66 | } 67 | return strings.Join(ss, ".") 68 | } 69 | 70 | func (k Key) maybeQuoted(i int) string { 71 | quote := false 72 | for _, c := range k[i] { 73 | if !isBareKeyChar(c) { 74 | quote = true 75 | break 76 | } 77 | } 78 | if quote { 79 | return "\"" + strings.Replace(k[i], "\"", "\\\"", -1) + "\"" 80 | } else { 81 | return k[i] 82 | } 83 | } 84 | 85 | func (k Key) add(piece string) Key { 86 | newKey := make(Key, len(k)+1) 87 | copy(newKey, k) 88 | newKey[len(k)] = piece 89 | return newKey 90 | } 91 | 92 | // Keys returns a slice of every key in the TOML data, including key groups. 93 | // Each key is itself a slice, where the first element is the top of the 94 | // hierarchy and the last is the most specific. 95 | // 96 | // The list will have the same order as the keys appeared in the TOML data. 97 | // 98 | // All keys returned are non-empty. 99 | func (md *MetaData) Keys() []Key { 100 | return md.keys 101 | } 102 | 103 | // Undecoded returns all keys that have not been decoded in the order in which 104 | // they appear in the original TOML document. 105 | // 106 | // This includes keys that haven't been decoded because of a Primitive value. 107 | // Once the Primitive value is decoded, the keys will be considered decoded. 108 | // 109 | // Also note that decoding into an empty interface will result in no decoding, 110 | // and so no keys will be considered decoded. 111 | // 112 | // In this sense, the Undecoded keys correspond to keys in the TOML document 113 | // that do not have a concrete type in your representation. 114 | func (md *MetaData) Undecoded() []Key { 115 | undecoded := make([]Key, 0, len(md.keys)) 116 | for _, key := range md.keys { 117 | if !md.decoded[key.String()] { 118 | undecoded = append(undecoded, key) 119 | } 120 | } 121 | return undecoded 122 | } 123 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package toml provides facilities for decoding and encoding TOML configuration 3 | files via reflection. There is also support for delaying decoding with 4 | the Primitive type, and querying the set of keys in a TOML document with the 5 | MetaData type. 6 | 7 | The specification implemented: https://github.com/mojombo/toml 8 | 9 | The sub-command github.com/BurntSushi/toml/cmd/tomlv can be used to verify 10 | whether a file is a valid TOML document. It can also be used to print the 11 | type of each key in a TOML document. 12 | 13 | Testing 14 | 15 | There are two important types of tests used for this package. The first is 16 | contained inside '*_test.go' files and uses the standard Go unit testing 17 | framework. These tests are primarily devoted to holistically testing the 18 | decoder and encoder. 19 | 20 | The second type of testing is used to verify the implementation's adherence 21 | to the TOML specification. These tests have been factored into their own 22 | project: https://github.com/BurntSushi/toml-test 23 | 24 | The reason the tests are in a separate project is so that they can be used by 25 | any implementation of TOML. Namely, it is language agnostic. 26 | */ 27 | package toml 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/encoding_types.go: -------------------------------------------------------------------------------- 1 | // +build go1.2 2 | 3 | package toml 4 | 5 | // In order to support Go 1.1, we define our own TextMarshaler and 6 | // TextUnmarshaler types. For Go 1.2+, we just alias them with the 7 | // standard library interfaces. 8 | 9 | import ( 10 | "encoding" 11 | ) 12 | 13 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 14 | // so that Go 1.1 can be supported. 15 | type TextMarshaler encoding.TextMarshaler 16 | 17 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 18 | // here so that Go 1.1 can be supported. 19 | type TextUnmarshaler encoding.TextUnmarshaler 20 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/encoding_types_1.1.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | package toml 4 | 5 | // These interfaces were introduced in Go 1.2, so we add them manually when 6 | // compiling for Go 1.1. 7 | 8 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 9 | // so that Go 1.1 can be supported. 10 | type TextMarshaler interface { 11 | MarshalText() (text []byte, err error) 12 | } 13 | 14 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 15 | // here so that Go 1.1 can be supported. 16 | type TextUnmarshaler interface { 17 | UnmarshalText(text []byte) error 18 | } 19 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/session.vim: -------------------------------------------------------------------------------- 1 | au BufWritePost *.go silent!make tags > /dev/null 2>&1 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/type_check.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | // tomlType represents any Go type that corresponds to a TOML type. 4 | // While the first draft of the TOML spec has a simplistic type system that 5 | // probably doesn't need this level of sophistication, we seem to be militating 6 | // toward adding real composite types. 7 | type tomlType interface { 8 | typeString() string 9 | } 10 | 11 | // typeEqual accepts any two types and returns true if they are equal. 12 | func typeEqual(t1, t2 tomlType) bool { 13 | if t1 == nil || t2 == nil { 14 | return false 15 | } 16 | return t1.typeString() == t2.typeString() 17 | } 18 | 19 | func typeIsHash(t tomlType) bool { 20 | return typeEqual(t, tomlHash) || typeEqual(t, tomlArrayHash) 21 | } 22 | 23 | type tomlBaseType string 24 | 25 | func (btype tomlBaseType) typeString() string { 26 | return string(btype) 27 | } 28 | 29 | func (btype tomlBaseType) String() string { 30 | return btype.typeString() 31 | } 32 | 33 | var ( 34 | tomlInteger tomlBaseType = "Integer" 35 | tomlFloat tomlBaseType = "Float" 36 | tomlDatetime tomlBaseType = "Datetime" 37 | tomlString tomlBaseType = "String" 38 | tomlBool tomlBaseType = "Bool" 39 | tomlArray tomlBaseType = "Array" 40 | tomlHash tomlBaseType = "Hash" 41 | tomlArrayHash tomlBaseType = "ArrayHash" 42 | ) 43 | 44 | // typeOfPrimitive returns a tomlType of any primitive value in TOML. 45 | // Primitive values are: Integer, Float, Datetime, String and Bool. 46 | // 47 | // Passing a lexer item other than the following will cause a BUG message 48 | // to occur: itemString, itemBool, itemInteger, itemFloat, itemDatetime. 49 | func (p *parser) typeOfPrimitive(lexItem item) tomlType { 50 | switch lexItem.typ { 51 | case itemInteger: 52 | return tomlInteger 53 | case itemFloat: 54 | return tomlFloat 55 | case itemDatetime: 56 | return tomlDatetime 57 | case itemString: 58 | return tomlString 59 | case itemMultilineString: 60 | return tomlString 61 | case itemRawString: 62 | return tomlString 63 | case itemRawMultilineString: 64 | return tomlString 65 | case itemBool: 66 | return tomlBool 67 | } 68 | p.bug("Cannot infer primitive type of lex item '%s'.", lexItem) 69 | panic("unreachable") 70 | } 71 | 72 | // typeOfArray returns a tomlType for an array given a list of types of its 73 | // values. 74 | // 75 | // In the current spec, if an array is homogeneous, then its type is always 76 | // "Array". If the array is not homogeneous, an error is generated. 77 | func (p *parser) typeOfArray(types []tomlType) tomlType { 78 | // Empty arrays are cool. 79 | if len(types) == 0 { 80 | return tomlArray 81 | } 82 | 83 | theType := types[0] 84 | for _, t := range types[1:] { 85 | if !typeEqual(theType, t) { 86 | p.panicf("Array contains values of type '%s' and '%s', but "+ 87 | "arrays must be homogeneous.", theType, t) 88 | } 89 | } 90 | return tomlArray 91 | } 92 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/type_fields.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | // Struct field handling is adapted from code in encoding/json: 4 | // 5 | // Copyright 2010 The Go Authors. All rights reserved. 6 | // Use of this source code is governed by a BSD-style 7 | // license that can be found in the Go distribution. 8 | 9 | import ( 10 | "reflect" 11 | "sort" 12 | "sync" 13 | ) 14 | 15 | // A field represents a single field found in a struct. 16 | type field struct { 17 | name string // the name of the field (`toml` tag included) 18 | tag bool // whether field has a `toml` tag 19 | index []int // represents the depth of an anonymous field 20 | typ reflect.Type // the type of the field 21 | } 22 | 23 | // byName sorts field by name, breaking ties with depth, 24 | // then breaking ties with "name came from toml tag", then 25 | // breaking ties with index sequence. 26 | type byName []field 27 | 28 | func (x byName) Len() int { return len(x) } 29 | 30 | func (x byName) Swap(i, j int) { x[i], x[j] = x[j], x[i] } 31 | 32 | func (x byName) Less(i, j int) bool { 33 | if x[i].name != x[j].name { 34 | return x[i].name < x[j].name 35 | } 36 | if len(x[i].index) != len(x[j].index) { 37 | return len(x[i].index) < len(x[j].index) 38 | } 39 | if x[i].tag != x[j].tag { 40 | return x[i].tag 41 | } 42 | return byIndex(x).Less(i, j) 43 | } 44 | 45 | // byIndex sorts field by index sequence. 46 | type byIndex []field 47 | 48 | func (x byIndex) Len() int { return len(x) } 49 | 50 | func (x byIndex) Swap(i, j int) { x[i], x[j] = x[j], x[i] } 51 | 52 | func (x byIndex) Less(i, j int) bool { 53 | for k, xik := range x[i].index { 54 | if k >= len(x[j].index) { 55 | return false 56 | } 57 | if xik != x[j].index[k] { 58 | return xik < x[j].index[k] 59 | } 60 | } 61 | return len(x[i].index) < len(x[j].index) 62 | } 63 | 64 | // typeFields returns a list of fields that TOML should recognize for the given 65 | // type. The algorithm is breadth-first search over the set of structs to 66 | // include - the top struct and then any reachable anonymous structs. 67 | func typeFields(t reflect.Type) []field { 68 | // Anonymous fields to explore at the current level and the next. 69 | current := []field{} 70 | next := []field{{typ: t}} 71 | 72 | // Count of queued names for current level and the next. 73 | count := map[reflect.Type]int{} 74 | nextCount := map[reflect.Type]int{} 75 | 76 | // Types already visited at an earlier level. 77 | visited := map[reflect.Type]bool{} 78 | 79 | // Fields found. 80 | var fields []field 81 | 82 | for len(next) > 0 { 83 | current, next = next, current[:0] 84 | count, nextCount = nextCount, map[reflect.Type]int{} 85 | 86 | for _, f := range current { 87 | if visited[f.typ] { 88 | continue 89 | } 90 | visited[f.typ] = true 91 | 92 | // Scan f.typ for fields to include. 93 | for i := 0; i < f.typ.NumField(); i++ { 94 | sf := f.typ.Field(i) 95 | if sf.PkgPath != "" { // unexported 96 | continue 97 | } 98 | name := sf.Tag.Get("toml") 99 | if name == "-" { 100 | continue 101 | } 102 | index := make([]int, len(f.index)+1) 103 | copy(index, f.index) 104 | index[len(f.index)] = i 105 | 106 | ft := sf.Type 107 | if ft.Name() == "" && ft.Kind() == reflect.Ptr { 108 | // Follow pointer. 109 | ft = ft.Elem() 110 | } 111 | 112 | // Record found field and index sequence. 113 | if name != "" || !sf.Anonymous || ft.Kind() != reflect.Struct { 114 | tagged := name != "" 115 | if name == "" { 116 | name = sf.Name 117 | } 118 | fields = append(fields, field{name, tagged, index, ft}) 119 | if count[f.typ] > 1 { 120 | // If there were multiple instances, add a second, 121 | // so that the annihilation code will see a duplicate. 122 | // It only cares about the distinction between 1 or 2, 123 | // so don't bother generating any more copies. 124 | fields = append(fields, fields[len(fields)-1]) 125 | } 126 | continue 127 | } 128 | 129 | // Record new anonymous struct to explore in next round. 130 | nextCount[ft]++ 131 | if nextCount[ft] == 1 { 132 | f := field{name: ft.Name(), index: index, typ: ft} 133 | next = append(next, f) 134 | } 135 | } 136 | } 137 | } 138 | 139 | sort.Sort(byName(fields)) 140 | 141 | // Delete all fields that are hidden by the Go rules for embedded fields, 142 | // except that fields with TOML tags are promoted. 143 | 144 | // The fields are sorted in primary order of name, secondary order 145 | // of field index length. Loop over names; for each name, delete 146 | // hidden fields by choosing the one dominant field that survives. 147 | out := fields[:0] 148 | for advance, i := 0, 0; i < len(fields); i += advance { 149 | // One iteration per name. 150 | // Find the sequence of fields with the name of this first field. 151 | fi := fields[i] 152 | name := fi.name 153 | for advance = 1; i+advance < len(fields); advance++ { 154 | fj := fields[i+advance] 155 | if fj.name != name { 156 | break 157 | } 158 | } 159 | if advance == 1 { // Only one field with this name 160 | out = append(out, fi) 161 | continue 162 | } 163 | dominant, ok := dominantField(fields[i : i+advance]) 164 | if ok { 165 | out = append(out, dominant) 166 | } 167 | } 168 | 169 | fields = out 170 | sort.Sort(byIndex(fields)) 171 | 172 | return fields 173 | } 174 | 175 | // dominantField looks through the fields, all of which are known to 176 | // have the same name, to find the single field that dominates the 177 | // others using Go's embedding rules, modified by the presence of 178 | // TOML tags. If there are multiple top-level fields, the boolean 179 | // will be false: This condition is an error in Go and we skip all 180 | // the fields. 181 | func dominantField(fields []field) (field, bool) { 182 | // The fields are sorted in increasing index-length order. The winner 183 | // must therefore be one with the shortest index length. Drop all 184 | // longer entries, which is easy: just truncate the slice. 185 | length := len(fields[0].index) 186 | tagged := -1 // Index of first tagged field. 187 | for i, f := range fields { 188 | if len(f.index) > length { 189 | fields = fields[:i] 190 | break 191 | } 192 | if f.tag { 193 | if tagged >= 0 { 194 | // Multiple tagged fields at the same level: conflict. 195 | // Return no field. 196 | return field{}, false 197 | } 198 | tagged = i 199 | } 200 | } 201 | if tagged >= 0 { 202 | return fields[tagged], true 203 | } 204 | // All remaining fields have the same length. If there's more than one, 205 | // we have a conflict (two fields named "X" at the same level) and we 206 | // return no field. 207 | if len(fields) > 1 { 208 | return field{}, false 209 | } 210 | return fields[0], true 211 | } 212 | 213 | var fieldCache struct { 214 | sync.RWMutex 215 | m map[reflect.Type][]field 216 | } 217 | 218 | // cachedTypeFields is like typeFields but uses a cache to avoid repeated work. 219 | func cachedTypeFields(t reflect.Type) []field { 220 | fieldCache.RLock() 221 | f := fieldCache.m[t] 222 | fieldCache.RUnlock() 223 | if f != nil { 224 | return f 225 | } 226 | 227 | // Compute fields without lock. 228 | // Might duplicate effort but won't hold other computations back. 229 | f = typeFields(t) 230 | if f == nil { 231 | f = []field{} 232 | } 233 | 234 | fieldCache.Lock() 235 | if fieldCache.m == nil { 236 | fieldCache.m = map[reflect.Type][]field{} 237 | } 238 | fieldCache.m[t] = f 239 | fieldCache.Unlock() 240 | return f 241 | } 242 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/README.md: -------------------------------------------------------------------------------- 1 | # A pure Go MSSQL driver for Go's database/sql package 2 | 3 | ## Install 4 | 5 | go get github.com/denisenkom/go-mssqldb 6 | 7 | ## Tests 8 | 9 | `go test` is used for testing. A running instance of MSSQL server is required. 10 | Environment variables are used to pass login information. 11 | 12 | Example: 13 | 14 | env HOST=localhost SQLUSER=sa SQLPASSWORD=sa DATABASE=test go test 15 | 16 | ## Connection Parameters 17 | 18 | * "server" - host or host\instance (default localhost) 19 | * "port" - used only when there is no instance in server (default 1433) 20 | * "failoverpartner" - host or host\instance (default is no partner). Used only until a successful connection has been made; thereafter, the partner provided in the first successful connection is used. 21 | * "failoverport" - used only when there is no instance in failoverpartner (default 1433) 22 | * "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. 23 | * "password" 24 | * "database" 25 | * "connection timeout" - in seconds (default is 30) 26 | * "dial timeout" - in seconds (default is 5) 27 | * "keepAlive" - in seconds; 0 to disable (default is 0) 28 | * "log" - logging flags (default 0/no logging, 63 for full logging) 29 | * 1 log errors 30 | * 2 log messages 31 | * 4 log rows affected 32 | * 8 trace sql statements 33 | * 16 log statement parameters 34 | * 32 log transaction begin/end 35 | * "encrypt" 36 | * disable - Data send between client and server is not encrypted. 37 | * false - Data sent between client and server is not encrypted beyond the login packet. (Default) 38 | * true - Data sent between client and server is encrypted. 39 | * "TrustServerCertificate" 40 | * false - Server certificate is checked. Default is false if encypt is specified. 41 | * 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. 42 | * "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. 43 | * "hostNameInCertificate" - Specifies the Common Name (CN) in the server certificate. Default value is the server host. 44 | * "ServerSPN" - The kerberos SPN (Service Principal Name) for the server. Default is MSSQLSvc/host:port. 45 | * "Workstation ID" - The workstation name (default is the host name) 46 | * "app name" - The application name (default is go-mssqldb) 47 | * "ApplicationIntent" - Can be given the value "ReadOnly" to initiate a read-only connection to an Availability Group listener. 48 | 49 | Example: 50 | 51 | ```go 52 | db, err := sql.Open("mssql", "server=localhost;user id=sa") 53 | ``` 54 | 55 | ## Statement Parameters 56 | 57 | In the SQL statement text, literals may be replaced by a parameter that matches one of the following: 58 | 59 | * ? 60 | * ?nnn 61 | * :nnn 62 | * $nnn 63 | 64 | where nnn represents an integer. 65 | 66 | ## Features 67 | 68 | * Can be used with SQL Server 2005 or newer 69 | * Can be used with Microsoft Azure SQL Database 70 | * Can be used on all go supported platforms (e.g. Linux, Mac OS X and Windows) 71 | * Supports new date/time types: date, time, datetime2, datetimeoffset 72 | * Supports string parameters longer than 8000 characters 73 | * Supports encryption using SSL/TLS 74 | * Supports SQL Server and Windows Authentication 75 | * Supports Single-Sign-On on Windows 76 | * Supports connections to AlwaysOn Availability Group listeners, including re-direction to read-only replicas. 77 | 78 | ## Known Issues 79 | 80 | * SQL Server 2008 and 2008 R2 engine cannot handle login records when SSL encryption is not disabled. 81 | To fix SQL Server 2008 R2 issue, install SQL Server 2008 R2 Service Pack 2. 82 | To fix SQL Server 2008 issue, install Microsoft SQL Server 2008 Service Pack 3 and Cumulative update package 3 for SQL Server 2008 SP3. 83 | More information: http://support.microsoft.com/kb/2653857 84 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/buf.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "encoding/binary" 5 | "io" 6 | ) 7 | 8 | type header struct { 9 | PacketType uint8 10 | Status uint8 11 | Size uint16 12 | Spid uint16 13 | PacketNo uint8 14 | Pad uint8 15 | } 16 | 17 | type tdsBuffer struct { 18 | buf []byte 19 | pos uint16 20 | transport io.ReadWriteCloser 21 | size uint16 22 | final bool 23 | packet_type uint8 24 | afterFirst func() 25 | } 26 | 27 | func newTdsBuffer(bufsize int, transport io.ReadWriteCloser) *tdsBuffer { 28 | buf := make([]byte, bufsize) 29 | w := new(tdsBuffer) 30 | w.buf = buf 31 | w.pos = 8 32 | w.transport = transport 33 | w.size = 0 34 | return w 35 | } 36 | 37 | func (w *tdsBuffer) flush() (err error) { 38 | binary.BigEndian.PutUint16(w.buf[2:], w.pos) 39 | if _, err = w.transport.Write(w.buf[:w.pos]); err != nil { 40 | return err 41 | } 42 | if w.afterFirst != nil { 43 | w.afterFirst() 44 | w.afterFirst = nil 45 | } 46 | w.pos = 8 47 | w.buf[6] += 1 48 | return nil 49 | } 50 | 51 | func (w *tdsBuffer) Write(p []byte) (nn int, err error) { 52 | total := 0 53 | for { 54 | copied := copy(w.buf[w.pos:], p) 55 | w.pos += uint16(copied) 56 | total += copied 57 | if copied == len(p) { 58 | break 59 | } 60 | if err = w.flush(); err != nil { 61 | return total, err 62 | } 63 | p = p[copied:] 64 | } 65 | return total, nil 66 | } 67 | 68 | func (w *tdsBuffer) WriteByte(b byte) error { 69 | if int(w.pos) == len(w.buf) { 70 | if err := w.flush(); err != nil { 71 | return err 72 | } 73 | } 74 | w.buf[w.pos] = b 75 | w.pos += 1 76 | return nil 77 | } 78 | 79 | func (w *tdsBuffer) BeginPacket(packet_type byte) { 80 | w.buf[0] = packet_type 81 | w.buf[1] = 0 // packet is incomplete 82 | w.buf[4] = 0 // spid 83 | w.buf[5] = 0 84 | w.buf[6] = 1 // packet id 85 | w.buf[7] = 0 // window 86 | w.pos = 8 87 | } 88 | 89 | func (w *tdsBuffer) FinishPacket() (err error) { 90 | w.buf[1] = 1 // packet is complete 91 | binary.BigEndian.PutUint16(w.buf[2:], w.pos) 92 | _, err = w.transport.Write(w.buf[:w.pos]) 93 | if w.afterFirst != nil { 94 | w.afterFirst() 95 | w.afterFirst = nil 96 | } 97 | return err 98 | } 99 | 100 | func (r *tdsBuffer) readNextPacket() error { 101 | header := header{} 102 | var err error 103 | err = binary.Read(r.transport, binary.BigEndian, &header) 104 | if err != nil { 105 | return err 106 | } 107 | offset := uint16(binary.Size(header)) 108 | _, err = io.ReadFull(r.transport, r.buf[offset:header.Size]) 109 | if err != nil { 110 | return err 111 | } 112 | r.pos = offset 113 | r.size = header.Size 114 | r.final = header.Status != 0 115 | r.packet_type = header.PacketType 116 | return nil 117 | } 118 | 119 | func (r *tdsBuffer) BeginRead() (uint8, error) { 120 | err := r.readNextPacket() 121 | if err != nil { 122 | return 0, err 123 | } 124 | return r.packet_type, nil 125 | } 126 | 127 | func (r *tdsBuffer) ReadByte() (res byte, err error) { 128 | if r.pos == r.size { 129 | if r.final { 130 | return 0, io.EOF 131 | } 132 | err = r.readNextPacket() 133 | if err != nil { 134 | return 0, err 135 | } 136 | } 137 | res = r.buf[r.pos] 138 | r.pos++ 139 | return res, nil 140 | } 141 | 142 | func (r *tdsBuffer) byte() byte { 143 | b, err := r.ReadByte() 144 | if err != nil { 145 | badStreamPanic(err) 146 | } 147 | return b 148 | } 149 | 150 | func (r *tdsBuffer) ReadFull(buf []byte) { 151 | _, err := io.ReadFull(r, buf[:]) 152 | if err != nil { 153 | badStreamPanic(err) 154 | } 155 | } 156 | 157 | func (r *tdsBuffer) uint64() uint64 { 158 | var buf [8]byte 159 | r.ReadFull(buf[:]) 160 | return binary.LittleEndian.Uint64(buf[:]) 161 | } 162 | 163 | func (r *tdsBuffer) int32() int32 { 164 | return int32(r.uint32()) 165 | } 166 | 167 | func (r *tdsBuffer) uint32() uint32 { 168 | var buf [4]byte 169 | r.ReadFull(buf[:]) 170 | return binary.LittleEndian.Uint32(buf[:]) 171 | } 172 | 173 | func (r *tdsBuffer) uint16() uint16 { 174 | var buf [2]byte 175 | r.ReadFull(buf[:]) 176 | return binary.LittleEndian.Uint16(buf[:]) 177 | } 178 | 179 | func (r *tdsBuffer) BVarChar() string { 180 | l := int(r.byte()) 181 | return r.readUcs2(l) 182 | } 183 | 184 | func (r *tdsBuffer) UsVarChar() string { 185 | l := int(r.uint16()) 186 | return r.readUcs2(l) 187 | } 188 | 189 | func (r *tdsBuffer) readUcs2(numchars int) string { 190 | b := make([]byte, numchars*2) 191 | r.ReadFull(b) 192 | res, err := ucs22str(b) 193 | if err != nil { 194 | badStreamPanic(err) 195 | } 196 | return res 197 | } 198 | 199 | func (r *tdsBuffer) Read(buf []byte) (n int, err error) { 200 | if r.pos == r.size { 201 | if r.final { 202 | return 0, io.EOF 203 | } 204 | err = r.readNextPacket() 205 | if err != nil { 206 | return 0, err 207 | } 208 | } 209 | copied := copy(buf, r.buf[r.pos:r.size]) 210 | r.pos += uint16(copied) 211 | return copied, nil 212 | } 213 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/charset.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | type charsetMap struct { 4 | sb [256]rune // single byte runes, -1 for a double byte character lead byte 5 | db map[int]rune // double byte runes 6 | } 7 | 8 | func collation2charset(col collation) *charsetMap { 9 | // http://msdn.microsoft.com/en-us/library/ms144250.aspx 10 | // http://msdn.microsoft.com/en-us/library/ms144250(v=sql.105).aspx 11 | switch col.sortId { 12 | case 30, 31, 32, 33, 34: 13 | return cp437 14 | case 40, 41, 42, 44, 49, 55, 56, 57, 58, 59, 60, 61: 15 | return cp850 16 | case 50, 51, 52, 53, 54, 71, 72, 73, 74, 75: 17 | return cp1252 18 | case 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96: 19 | return cp1250 20 | case 104, 105, 106, 107, 108: 21 | return cp1251 22 | case 112, 113, 114, 121, 124: 23 | return cp1253 24 | case 128, 129, 130: 25 | return cp1254 26 | case 136, 137, 138: 27 | return cp1255 28 | case 144, 145, 146: 29 | return cp1256 30 | case 152, 153, 154, 155, 156, 157, 158, 159, 160: 31 | return cp1257 32 | case 183, 184, 185, 186: 33 | return cp1252 34 | case 192, 193: 35 | return cp932 36 | case 194, 195: 37 | return cp949 38 | case 196, 197: 39 | return cp950 40 | case 198, 199: 41 | return cp936 42 | case 200: 43 | return cp932 44 | case 201: 45 | return cp949 46 | case 202: 47 | return cp950 48 | case 203: 49 | return cp936 50 | case 204, 205, 206: 51 | return cp874 52 | case 210, 211, 212, 213, 214, 215, 216, 217: 53 | return cp1252 54 | } 55 | // http://technet.microsoft.com/en-us/library/aa176553(v=sql.80).aspx 56 | switch col.getLcid() { 57 | case 0x001e, 0x041e: 58 | return cp874 59 | case 0x0411, 0x10411: 60 | return cp932 61 | case 0x0804, 0x1004, 0x20804: 62 | return cp936 63 | case 0x0012, 0x0412: 64 | return cp949 65 | case 0x0404, 0x1404, 0x0c04, 0x7c04, 0x30404: 66 | return cp950 67 | case 0x041c, 0x041a, 0x0405, 0x040e, 0x104e, 0x0415, 0x0418, 0x041b, 0x0424, 0x1040e: 68 | return cp1250 69 | case 0x0423, 0x0402, 0x042f, 0x0419, 0x081a, 0x0c1a, 0x0422, 0x043f, 0x0444, 0x082c: 70 | return cp1251 71 | case 0x0408: 72 | return cp1253 73 | case 0x041f, 0x042c, 0x0443: 74 | return cp1254 75 | case 0x040d: 76 | return cp1255 77 | case 0x0401, 0x0801, 0xc01, 0x1001, 0x1401, 0x1801, 0x1c01, 0x2001, 0x2401, 0x2801, 0x2c01, 0x3001, 0x3401, 0x3801, 0x3c01, 0x4001, 0x0429, 0x0420: 78 | return cp1256 79 | case 0x0425, 0x0426, 0x0427, 0x0827: 80 | return cp1257 81 | case 0x042a: 82 | return cp1258 83 | case 0x0439, 0x045a, 0x0465: 84 | return nil 85 | } 86 | return cp1252 87 | } 88 | 89 | func charset2utf8(col collation, s []byte) string { 90 | cm := collation2charset(col) 91 | if cm == nil { 92 | return string(s) 93 | } 94 | buf := make([]rune, 0, len(s)) 95 | for i := 0; i < len(s); i++ { 96 | ch := cm.sb[s[i]] 97 | if ch == -1 { 98 | if i+1 == len(s) { 99 | ch = 0xfffd 100 | } else { 101 | n := int(s[i+1]) + (int(s[i]) << 8) 102 | i++ 103 | var ok bool 104 | ch, ok = cm.db[n] 105 | if !ok { 106 | ch = 0xfffd 107 | } 108 | } 109 | } 110 | buf = append(buf, ch) 111 | } 112 | return string(buf) 113 | } 114 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/collation.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "encoding/binary" 5 | "io" 6 | ) 7 | 8 | // http://msdn.microsoft.com/en-us/library/dd340437.aspx 9 | 10 | type collation struct { 11 | lcidAndFlags uint32 12 | sortId uint8 13 | } 14 | 15 | func (c collation) getLcid() uint32 { 16 | return c.lcidAndFlags & 0x000fffff 17 | } 18 | 19 | func (c collation) getFlags() uint32 { 20 | return (c.lcidAndFlags & 0x0ff00000) >> 20 21 | } 22 | 23 | func (c collation) getVersion() uint32 { 24 | return (c.lcidAndFlags & 0xf0000000) >> 28 25 | } 26 | 27 | func readCollation(r *tdsBuffer) (res collation) { 28 | res.lcidAndFlags = r.uint32() 29 | res.sortId = r.byte() 30 | return 31 | } 32 | 33 | func writeCollation(w io.Writer, col collation) (err error) { 34 | if err = binary.Write(w, binary.LittleEndian, col.lcidAndFlags); err != nil { 35 | return 36 | } 37 | err = binary.Write(w, binary.LittleEndian, col.sortId) 38 | return 39 | } 40 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/cp1251.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | var cp1251 *charsetMap = &charsetMap{ 4 | sb: [256]rune{ 5 | 0x0000, //NULL 6 | 0x0001, //START OF HEADING 7 | 0x0002, //START OF TEXT 8 | 0x0003, //END OF TEXT 9 | 0x0004, //END OF TRANSMISSION 10 | 0x0005, //ENQUIRY 11 | 0x0006, //ACKNOWLEDGE 12 | 0x0007, //BELL 13 | 0x0008, //BACKSPACE 14 | 0x0009, //HORIZONTAL TABULATION 15 | 0x000A, //LINE FEED 16 | 0x000B, //VERTICAL TABULATION 17 | 0x000C, //FORM FEED 18 | 0x000D, //CARRIAGE RETURN 19 | 0x000E, //SHIFT OUT 20 | 0x000F, //SHIFT IN 21 | 0x0010, //DATA LINK ESCAPE 22 | 0x0011, //DEVICE CONTROL ONE 23 | 0x0012, //DEVICE CONTROL TWO 24 | 0x0013, //DEVICE CONTROL THREE 25 | 0x0014, //DEVICE CONTROL FOUR 26 | 0x0015, //NEGATIVE ACKNOWLEDGE 27 | 0x0016, //SYNCHRONOUS IDLE 28 | 0x0017, //END OF TRANSMISSION BLOCK 29 | 0x0018, //CANCEL 30 | 0x0019, //END OF MEDIUM 31 | 0x001A, //SUBSTITUTE 32 | 0x001B, //ESCAPE 33 | 0x001C, //FILE SEPARATOR 34 | 0x001D, //GROUP SEPARATOR 35 | 0x001E, //RECORD SEPARATOR 36 | 0x001F, //UNIT SEPARATOR 37 | 0x0020, //SPACE 38 | 0x0021, //EXCLAMATION MARK 39 | 0x0022, //QUOTATION MARK 40 | 0x0023, //NUMBER SIGN 41 | 0x0024, //DOLLAR SIGN 42 | 0x0025, //PERCENT SIGN 43 | 0x0026, //AMPERSAND 44 | 0x0027, //APOSTROPHE 45 | 0x0028, //LEFT PARENTHESIS 46 | 0x0029, //RIGHT PARENTHESIS 47 | 0x002A, //ASTERISK 48 | 0x002B, //PLUS SIGN 49 | 0x002C, //COMMA 50 | 0x002D, //HYPHEN-MINUS 51 | 0x002E, //FULL STOP 52 | 0x002F, //SOLIDUS 53 | 0x0030, //DIGIT ZERO 54 | 0x0031, //DIGIT ONE 55 | 0x0032, //DIGIT TWO 56 | 0x0033, //DIGIT THREE 57 | 0x0034, //DIGIT FOUR 58 | 0x0035, //DIGIT FIVE 59 | 0x0036, //DIGIT SIX 60 | 0x0037, //DIGIT SEVEN 61 | 0x0038, //DIGIT EIGHT 62 | 0x0039, //DIGIT NINE 63 | 0x003A, //COLON 64 | 0x003B, //SEMICOLON 65 | 0x003C, //LESS-THAN SIGN 66 | 0x003D, //EQUALS SIGN 67 | 0x003E, //GREATER-THAN SIGN 68 | 0x003F, //QUESTION MARK 69 | 0x0040, //COMMERCIAL AT 70 | 0x0041, //LATIN CAPITAL LETTER A 71 | 0x0042, //LATIN CAPITAL LETTER B 72 | 0x0043, //LATIN CAPITAL LETTER C 73 | 0x0044, //LATIN CAPITAL LETTER D 74 | 0x0045, //LATIN CAPITAL LETTER E 75 | 0x0046, //LATIN CAPITAL LETTER F 76 | 0x0047, //LATIN CAPITAL LETTER G 77 | 0x0048, //LATIN CAPITAL LETTER H 78 | 0x0049, //LATIN CAPITAL LETTER I 79 | 0x004A, //LATIN CAPITAL LETTER J 80 | 0x004B, //LATIN CAPITAL LETTER K 81 | 0x004C, //LATIN CAPITAL LETTER L 82 | 0x004D, //LATIN CAPITAL LETTER M 83 | 0x004E, //LATIN CAPITAL LETTER N 84 | 0x004F, //LATIN CAPITAL LETTER O 85 | 0x0050, //LATIN CAPITAL LETTER P 86 | 0x0051, //LATIN CAPITAL LETTER Q 87 | 0x0052, //LATIN CAPITAL LETTER R 88 | 0x0053, //LATIN CAPITAL LETTER S 89 | 0x0054, //LATIN CAPITAL LETTER T 90 | 0x0055, //LATIN CAPITAL LETTER U 91 | 0x0056, //LATIN CAPITAL LETTER V 92 | 0x0057, //LATIN CAPITAL LETTER W 93 | 0x0058, //LATIN CAPITAL LETTER X 94 | 0x0059, //LATIN CAPITAL LETTER Y 95 | 0x005A, //LATIN CAPITAL LETTER Z 96 | 0x005B, //LEFT SQUARE BRACKET 97 | 0x005C, //REVERSE SOLIDUS 98 | 0x005D, //RIGHT SQUARE BRACKET 99 | 0x005E, //CIRCUMFLEX ACCENT 100 | 0x005F, //LOW LINE 101 | 0x0060, //GRAVE ACCENT 102 | 0x0061, //LATIN SMALL LETTER A 103 | 0x0062, //LATIN SMALL LETTER B 104 | 0x0063, //LATIN SMALL LETTER C 105 | 0x0064, //LATIN SMALL LETTER D 106 | 0x0065, //LATIN SMALL LETTER E 107 | 0x0066, //LATIN SMALL LETTER F 108 | 0x0067, //LATIN SMALL LETTER G 109 | 0x0068, //LATIN SMALL LETTER H 110 | 0x0069, //LATIN SMALL LETTER I 111 | 0x006A, //LATIN SMALL LETTER J 112 | 0x006B, //LATIN SMALL LETTER K 113 | 0x006C, //LATIN SMALL LETTER L 114 | 0x006D, //LATIN SMALL LETTER M 115 | 0x006E, //LATIN SMALL LETTER N 116 | 0x006F, //LATIN SMALL LETTER O 117 | 0x0070, //LATIN SMALL LETTER P 118 | 0x0071, //LATIN SMALL LETTER Q 119 | 0x0072, //LATIN SMALL LETTER R 120 | 0x0073, //LATIN SMALL LETTER S 121 | 0x0074, //LATIN SMALL LETTER T 122 | 0x0075, //LATIN SMALL LETTER U 123 | 0x0076, //LATIN SMALL LETTER V 124 | 0x0077, //LATIN SMALL LETTER W 125 | 0x0078, //LATIN SMALL LETTER X 126 | 0x0079, //LATIN SMALL LETTER Y 127 | 0x007A, //LATIN SMALL LETTER Z 128 | 0x007B, //LEFT CURLY BRACKET 129 | 0x007C, //VERTICAL LINE 130 | 0x007D, //RIGHT CURLY BRACKET 131 | 0x007E, //TILDE 132 | 0x007F, //DELETE 133 | 0x0402, //CYRILLIC CAPITAL LETTER DJE 134 | 0x0403, //CYRILLIC CAPITAL LETTER GJE 135 | 0x201A, //SINGLE LOW-9 QUOTATION MARK 136 | 0x0453, //CYRILLIC SMALL LETTER GJE 137 | 0x201E, //DOUBLE LOW-9 QUOTATION MARK 138 | 0x2026, //HORIZONTAL ELLIPSIS 139 | 0x2020, //DAGGER 140 | 0x2021, //DOUBLE DAGGER 141 | 0x20AC, //EURO SIGN 142 | 0x2030, //PER MILLE SIGN 143 | 0x0409, //CYRILLIC CAPITAL LETTER LJE 144 | 0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK 145 | 0x040A, //CYRILLIC CAPITAL LETTER NJE 146 | 0x040C, //CYRILLIC CAPITAL LETTER KJE 147 | 0x040B, //CYRILLIC CAPITAL LETTER TSHE 148 | 0x040F, //CYRILLIC CAPITAL LETTER DZHE 149 | 0x0452, //CYRILLIC SMALL LETTER DJE 150 | 0x2018, //LEFT SINGLE QUOTATION MARK 151 | 0x2019, //RIGHT SINGLE QUOTATION MARK 152 | 0x201C, //LEFT DOUBLE QUOTATION MARK 153 | 0x201D, //RIGHT DOUBLE QUOTATION MARK 154 | 0x2022, //BULLET 155 | 0x2013, //EN DASH 156 | 0x2014, //EM DASH 157 | 0xFFFD, //UNDEFINED 158 | 0x2122, //TRADE MARK SIGN 159 | 0x0459, //CYRILLIC SMALL LETTER LJE 160 | 0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK 161 | 0x045A, //CYRILLIC SMALL LETTER NJE 162 | 0x045C, //CYRILLIC SMALL LETTER KJE 163 | 0x045B, //CYRILLIC SMALL LETTER TSHE 164 | 0x045F, //CYRILLIC SMALL LETTER DZHE 165 | 0x00A0, //NO-BREAK SPACE 166 | 0x040E, //CYRILLIC CAPITAL LETTER SHORT U 167 | 0x045E, //CYRILLIC SMALL LETTER SHORT U 168 | 0x0408, //CYRILLIC CAPITAL LETTER JE 169 | 0x00A4, //CURRENCY SIGN 170 | 0x0490, //CYRILLIC CAPITAL LETTER GHE WITH UPTURN 171 | 0x00A6, //BROKEN BAR 172 | 0x00A7, //SECTION SIGN 173 | 0x0401, //CYRILLIC CAPITAL LETTER IO 174 | 0x00A9, //COPYRIGHT SIGN 175 | 0x0404, //CYRILLIC CAPITAL LETTER UKRAINIAN IE 176 | 0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 177 | 0x00AC, //NOT SIGN 178 | 0x00AD, //SOFT HYPHEN 179 | 0x00AE, //REGISTERED SIGN 180 | 0x0407, //CYRILLIC CAPITAL LETTER YI 181 | 0x00B0, //DEGREE SIGN 182 | 0x00B1, //PLUS-MINUS SIGN 183 | 0x0406, //CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I 184 | 0x0456, //CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I 185 | 0x0491, //CYRILLIC SMALL LETTER GHE WITH UPTURN 186 | 0x00B5, //MICRO SIGN 187 | 0x00B6, //PILCROW SIGN 188 | 0x00B7, //MIDDLE DOT 189 | 0x0451, //CYRILLIC SMALL LETTER IO 190 | 0x2116, //NUMERO SIGN 191 | 0x0454, //CYRILLIC SMALL LETTER UKRAINIAN IE 192 | 0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 193 | 0x0458, //CYRILLIC SMALL LETTER JE 194 | 0x0405, //CYRILLIC CAPITAL LETTER DZE 195 | 0x0455, //CYRILLIC SMALL LETTER DZE 196 | 0x0457, //CYRILLIC SMALL LETTER YI 197 | 0x0410, //CYRILLIC CAPITAL LETTER A 198 | 0x0411, //CYRILLIC CAPITAL LETTER BE 199 | 0x0412, //CYRILLIC CAPITAL LETTER VE 200 | 0x0413, //CYRILLIC CAPITAL LETTER GHE 201 | 0x0414, //CYRILLIC CAPITAL LETTER DE 202 | 0x0415, //CYRILLIC CAPITAL LETTER IE 203 | 0x0416, //CYRILLIC CAPITAL LETTER ZHE 204 | 0x0417, //CYRILLIC CAPITAL LETTER ZE 205 | 0x0418, //CYRILLIC CAPITAL LETTER I 206 | 0x0419, //CYRILLIC CAPITAL LETTER SHORT I 207 | 0x041A, //CYRILLIC CAPITAL LETTER KA 208 | 0x041B, //CYRILLIC CAPITAL LETTER EL 209 | 0x041C, //CYRILLIC CAPITAL LETTER EM 210 | 0x041D, //CYRILLIC CAPITAL LETTER EN 211 | 0x041E, //CYRILLIC CAPITAL LETTER O 212 | 0x041F, //CYRILLIC CAPITAL LETTER PE 213 | 0x0420, //CYRILLIC CAPITAL LETTER ER 214 | 0x0421, //CYRILLIC CAPITAL LETTER ES 215 | 0x0422, //CYRILLIC CAPITAL LETTER TE 216 | 0x0423, //CYRILLIC CAPITAL LETTER U 217 | 0x0424, //CYRILLIC CAPITAL LETTER EF 218 | 0x0425, //CYRILLIC CAPITAL LETTER HA 219 | 0x0426, //CYRILLIC CAPITAL LETTER TSE 220 | 0x0427, //CYRILLIC CAPITAL LETTER CHE 221 | 0x0428, //CYRILLIC CAPITAL LETTER SHA 222 | 0x0429, //CYRILLIC CAPITAL LETTER SHCHA 223 | 0x042A, //CYRILLIC CAPITAL LETTER HARD SIGN 224 | 0x042B, //CYRILLIC CAPITAL LETTER YERU 225 | 0x042C, //CYRILLIC CAPITAL LETTER SOFT SIGN 226 | 0x042D, //CYRILLIC CAPITAL LETTER E 227 | 0x042E, //CYRILLIC CAPITAL LETTER YU 228 | 0x042F, //CYRILLIC CAPITAL LETTER YA 229 | 0x0430, //CYRILLIC SMALL LETTER A 230 | 0x0431, //CYRILLIC SMALL LETTER BE 231 | 0x0432, //CYRILLIC SMALL LETTER VE 232 | 0x0433, //CYRILLIC SMALL LETTER GHE 233 | 0x0434, //CYRILLIC SMALL LETTER DE 234 | 0x0435, //CYRILLIC SMALL LETTER IE 235 | 0x0436, //CYRILLIC SMALL LETTER ZHE 236 | 0x0437, //CYRILLIC SMALL LETTER ZE 237 | 0x0438, //CYRILLIC SMALL LETTER I 238 | 0x0439, //CYRILLIC SMALL LETTER SHORT I 239 | 0x043A, //CYRILLIC SMALL LETTER KA 240 | 0x043B, //CYRILLIC SMALL LETTER EL 241 | 0x043C, //CYRILLIC SMALL LETTER EM 242 | 0x043D, //CYRILLIC SMALL LETTER EN 243 | 0x043E, //CYRILLIC SMALL LETTER O 244 | 0x043F, //CYRILLIC SMALL LETTER PE 245 | 0x0440, //CYRILLIC SMALL LETTER ER 246 | 0x0441, //CYRILLIC SMALL LETTER ES 247 | 0x0442, //CYRILLIC SMALL LETTER TE 248 | 0x0443, //CYRILLIC SMALL LETTER U 249 | 0x0444, //CYRILLIC SMALL LETTER EF 250 | 0x0445, //CYRILLIC SMALL LETTER HA 251 | 0x0446, //CYRILLIC SMALL LETTER TSE 252 | 0x0447, //CYRILLIC SMALL LETTER CHE 253 | 0x0448, //CYRILLIC SMALL LETTER SHA 254 | 0x0449, //CYRILLIC SMALL LETTER SHCHA 255 | 0x044A, //CYRILLIC SMALL LETTER HARD SIGN 256 | 0x044B, //CYRILLIC SMALL LETTER YERU 257 | 0x044C, //CYRILLIC SMALL LETTER SOFT SIGN 258 | 0x044D, //CYRILLIC SMALL LETTER E 259 | 0x044E, //CYRILLIC SMALL LETTER YU 260 | 0x044F, //CYRILLIC SMALL LETTER YA 261 | }, 262 | } 263 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/cp1253.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | var cp1253 *charsetMap = &charsetMap{ 4 | sb: [256]rune{ 5 | 0x0000, //NULL 6 | 0x0001, //START OF HEADING 7 | 0x0002, //START OF TEXT 8 | 0x0003, //END OF TEXT 9 | 0x0004, //END OF TRANSMISSION 10 | 0x0005, //ENQUIRY 11 | 0x0006, //ACKNOWLEDGE 12 | 0x0007, //BELL 13 | 0x0008, //BACKSPACE 14 | 0x0009, //HORIZONTAL TABULATION 15 | 0x000A, //LINE FEED 16 | 0x000B, //VERTICAL TABULATION 17 | 0x000C, //FORM FEED 18 | 0x000D, //CARRIAGE RETURN 19 | 0x000E, //SHIFT OUT 20 | 0x000F, //SHIFT IN 21 | 0x0010, //DATA LINK ESCAPE 22 | 0x0011, //DEVICE CONTROL ONE 23 | 0x0012, //DEVICE CONTROL TWO 24 | 0x0013, //DEVICE CONTROL THREE 25 | 0x0014, //DEVICE CONTROL FOUR 26 | 0x0015, //NEGATIVE ACKNOWLEDGE 27 | 0x0016, //SYNCHRONOUS IDLE 28 | 0x0017, //END OF TRANSMISSION BLOCK 29 | 0x0018, //CANCEL 30 | 0x0019, //END OF MEDIUM 31 | 0x001A, //SUBSTITUTE 32 | 0x001B, //ESCAPE 33 | 0x001C, //FILE SEPARATOR 34 | 0x001D, //GROUP SEPARATOR 35 | 0x001E, //RECORD SEPARATOR 36 | 0x001F, //UNIT SEPARATOR 37 | 0x0020, //SPACE 38 | 0x0021, //EXCLAMATION MARK 39 | 0x0022, //QUOTATION MARK 40 | 0x0023, //NUMBER SIGN 41 | 0x0024, //DOLLAR SIGN 42 | 0x0025, //PERCENT SIGN 43 | 0x0026, //AMPERSAND 44 | 0x0027, //APOSTROPHE 45 | 0x0028, //LEFT PARENTHESIS 46 | 0x0029, //RIGHT PARENTHESIS 47 | 0x002A, //ASTERISK 48 | 0x002B, //PLUS SIGN 49 | 0x002C, //COMMA 50 | 0x002D, //HYPHEN-MINUS 51 | 0x002E, //FULL STOP 52 | 0x002F, //SOLIDUS 53 | 0x0030, //DIGIT ZERO 54 | 0x0031, //DIGIT ONE 55 | 0x0032, //DIGIT TWO 56 | 0x0033, //DIGIT THREE 57 | 0x0034, //DIGIT FOUR 58 | 0x0035, //DIGIT FIVE 59 | 0x0036, //DIGIT SIX 60 | 0x0037, //DIGIT SEVEN 61 | 0x0038, //DIGIT EIGHT 62 | 0x0039, //DIGIT NINE 63 | 0x003A, //COLON 64 | 0x003B, //SEMICOLON 65 | 0x003C, //LESS-THAN SIGN 66 | 0x003D, //EQUALS SIGN 67 | 0x003E, //GREATER-THAN SIGN 68 | 0x003F, //QUESTION MARK 69 | 0x0040, //COMMERCIAL AT 70 | 0x0041, //LATIN CAPITAL LETTER A 71 | 0x0042, //LATIN CAPITAL LETTER B 72 | 0x0043, //LATIN CAPITAL LETTER C 73 | 0x0044, //LATIN CAPITAL LETTER D 74 | 0x0045, //LATIN CAPITAL LETTER E 75 | 0x0046, //LATIN CAPITAL LETTER F 76 | 0x0047, //LATIN CAPITAL LETTER G 77 | 0x0048, //LATIN CAPITAL LETTER H 78 | 0x0049, //LATIN CAPITAL LETTER I 79 | 0x004A, //LATIN CAPITAL LETTER J 80 | 0x004B, //LATIN CAPITAL LETTER K 81 | 0x004C, //LATIN CAPITAL LETTER L 82 | 0x004D, //LATIN CAPITAL LETTER M 83 | 0x004E, //LATIN CAPITAL LETTER N 84 | 0x004F, //LATIN CAPITAL LETTER O 85 | 0x0050, //LATIN CAPITAL LETTER P 86 | 0x0051, //LATIN CAPITAL LETTER Q 87 | 0x0052, //LATIN CAPITAL LETTER R 88 | 0x0053, //LATIN CAPITAL LETTER S 89 | 0x0054, //LATIN CAPITAL LETTER T 90 | 0x0055, //LATIN CAPITAL LETTER U 91 | 0x0056, //LATIN CAPITAL LETTER V 92 | 0x0057, //LATIN CAPITAL LETTER W 93 | 0x0058, //LATIN CAPITAL LETTER X 94 | 0x0059, //LATIN CAPITAL LETTER Y 95 | 0x005A, //LATIN CAPITAL LETTER Z 96 | 0x005B, //LEFT SQUARE BRACKET 97 | 0x005C, //REVERSE SOLIDUS 98 | 0x005D, //RIGHT SQUARE BRACKET 99 | 0x005E, //CIRCUMFLEX ACCENT 100 | 0x005F, //LOW LINE 101 | 0x0060, //GRAVE ACCENT 102 | 0x0061, //LATIN SMALL LETTER A 103 | 0x0062, //LATIN SMALL LETTER B 104 | 0x0063, //LATIN SMALL LETTER C 105 | 0x0064, //LATIN SMALL LETTER D 106 | 0x0065, //LATIN SMALL LETTER E 107 | 0x0066, //LATIN SMALL LETTER F 108 | 0x0067, //LATIN SMALL LETTER G 109 | 0x0068, //LATIN SMALL LETTER H 110 | 0x0069, //LATIN SMALL LETTER I 111 | 0x006A, //LATIN SMALL LETTER J 112 | 0x006B, //LATIN SMALL LETTER K 113 | 0x006C, //LATIN SMALL LETTER L 114 | 0x006D, //LATIN SMALL LETTER M 115 | 0x006E, //LATIN SMALL LETTER N 116 | 0x006F, //LATIN SMALL LETTER O 117 | 0x0070, //LATIN SMALL LETTER P 118 | 0x0071, //LATIN SMALL LETTER Q 119 | 0x0072, //LATIN SMALL LETTER R 120 | 0x0073, //LATIN SMALL LETTER S 121 | 0x0074, //LATIN SMALL LETTER T 122 | 0x0075, //LATIN SMALL LETTER U 123 | 0x0076, //LATIN SMALL LETTER V 124 | 0x0077, //LATIN SMALL LETTER W 125 | 0x0078, //LATIN SMALL LETTER X 126 | 0x0079, //LATIN SMALL LETTER Y 127 | 0x007A, //LATIN SMALL LETTER Z 128 | 0x007B, //LEFT CURLY BRACKET 129 | 0x007C, //VERTICAL LINE 130 | 0x007D, //RIGHT CURLY BRACKET 131 | 0x007E, //TILDE 132 | 0x007F, //DELETE 133 | 0x20AC, //EURO SIGN 134 | 0xFFFD, //UNDEFINED 135 | 0x201A, //SINGLE LOW-9 QUOTATION MARK 136 | 0x0192, //LATIN SMALL LETTER F WITH HOOK 137 | 0x201E, //DOUBLE LOW-9 QUOTATION MARK 138 | 0x2026, //HORIZONTAL ELLIPSIS 139 | 0x2020, //DAGGER 140 | 0x2021, //DOUBLE DAGGER 141 | 0xFFFD, //UNDEFINED 142 | 0x2030, //PER MILLE SIGN 143 | 0xFFFD, //UNDEFINED 144 | 0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK 145 | 0xFFFD, //UNDEFINED 146 | 0xFFFD, //UNDEFINED 147 | 0xFFFD, //UNDEFINED 148 | 0xFFFD, //UNDEFINED 149 | 0xFFFD, //UNDEFINED 150 | 0x2018, //LEFT SINGLE QUOTATION MARK 151 | 0x2019, //RIGHT SINGLE QUOTATION MARK 152 | 0x201C, //LEFT DOUBLE QUOTATION MARK 153 | 0x201D, //RIGHT DOUBLE QUOTATION MARK 154 | 0x2022, //BULLET 155 | 0x2013, //EN DASH 156 | 0x2014, //EM DASH 157 | 0xFFFD, //UNDEFINED 158 | 0x2122, //TRADE MARK SIGN 159 | 0xFFFD, //UNDEFINED 160 | 0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK 161 | 0xFFFD, //UNDEFINED 162 | 0xFFFD, //UNDEFINED 163 | 0xFFFD, //UNDEFINED 164 | 0xFFFD, //UNDEFINED 165 | 0x00A0, //NO-BREAK SPACE 166 | 0x0385, //GREEK DIALYTIKA TONOS 167 | 0x0386, //GREEK CAPITAL LETTER ALPHA WITH TONOS 168 | 0x00A3, //POUND SIGN 169 | 0x00A4, //CURRENCY SIGN 170 | 0x00A5, //YEN SIGN 171 | 0x00A6, //BROKEN BAR 172 | 0x00A7, //SECTION SIGN 173 | 0x00A8, //DIAERESIS 174 | 0x00A9, //COPYRIGHT SIGN 175 | 0xFFFD, //UNDEFINED 176 | 0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 177 | 0x00AC, //NOT SIGN 178 | 0x00AD, //SOFT HYPHEN 179 | 0x00AE, //REGISTERED SIGN 180 | 0x2015, //HORIZONTAL BAR 181 | 0x00B0, //DEGREE SIGN 182 | 0x00B1, //PLUS-MINUS SIGN 183 | 0x00B2, //SUPERSCRIPT TWO 184 | 0x00B3, //SUPERSCRIPT THREE 185 | 0x0384, //GREEK TONOS 186 | 0x00B5, //MICRO SIGN 187 | 0x00B6, //PILCROW SIGN 188 | 0x00B7, //MIDDLE DOT 189 | 0x0388, //GREEK CAPITAL LETTER EPSILON WITH TONOS 190 | 0x0389, //GREEK CAPITAL LETTER ETA WITH TONOS 191 | 0x038A, //GREEK CAPITAL LETTER IOTA WITH TONOS 192 | 0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 193 | 0x038C, //GREEK CAPITAL LETTER OMICRON WITH TONOS 194 | 0x00BD, //VULGAR FRACTION ONE HALF 195 | 0x038E, //GREEK CAPITAL LETTER UPSILON WITH TONOS 196 | 0x038F, //GREEK CAPITAL LETTER OMEGA WITH TONOS 197 | 0x0390, //GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS 198 | 0x0391, //GREEK CAPITAL LETTER ALPHA 199 | 0x0392, //GREEK CAPITAL LETTER BETA 200 | 0x0393, //GREEK CAPITAL LETTER GAMMA 201 | 0x0394, //GREEK CAPITAL LETTER DELTA 202 | 0x0395, //GREEK CAPITAL LETTER EPSILON 203 | 0x0396, //GREEK CAPITAL LETTER ZETA 204 | 0x0397, //GREEK CAPITAL LETTER ETA 205 | 0x0398, //GREEK CAPITAL LETTER THETA 206 | 0x0399, //GREEK CAPITAL LETTER IOTA 207 | 0x039A, //GREEK CAPITAL LETTER KAPPA 208 | 0x039B, //GREEK CAPITAL LETTER LAMDA 209 | 0x039C, //GREEK CAPITAL LETTER MU 210 | 0x039D, //GREEK CAPITAL LETTER NU 211 | 0x039E, //GREEK CAPITAL LETTER XI 212 | 0x039F, //GREEK CAPITAL LETTER OMICRON 213 | 0x03A0, //GREEK CAPITAL LETTER PI 214 | 0x03A1, //GREEK CAPITAL LETTER RHO 215 | 0xFFFD, //UNDEFINED 216 | 0x03A3, //GREEK CAPITAL LETTER SIGMA 217 | 0x03A4, //GREEK CAPITAL LETTER TAU 218 | 0x03A5, //GREEK CAPITAL LETTER UPSILON 219 | 0x03A6, //GREEK CAPITAL LETTER PHI 220 | 0x03A7, //GREEK CAPITAL LETTER CHI 221 | 0x03A8, //GREEK CAPITAL LETTER PSI 222 | 0x03A9, //GREEK CAPITAL LETTER OMEGA 223 | 0x03AA, //GREEK CAPITAL LETTER IOTA WITH DIALYTIKA 224 | 0x03AB, //GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA 225 | 0x03AC, //GREEK SMALL LETTER ALPHA WITH TONOS 226 | 0x03AD, //GREEK SMALL LETTER EPSILON WITH TONOS 227 | 0x03AE, //GREEK SMALL LETTER ETA WITH TONOS 228 | 0x03AF, //GREEK SMALL LETTER IOTA WITH TONOS 229 | 0x03B0, //GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS 230 | 0x03B1, //GREEK SMALL LETTER ALPHA 231 | 0x03B2, //GREEK SMALL LETTER BETA 232 | 0x03B3, //GREEK SMALL LETTER GAMMA 233 | 0x03B4, //GREEK SMALL LETTER DELTA 234 | 0x03B5, //GREEK SMALL LETTER EPSILON 235 | 0x03B6, //GREEK SMALL LETTER ZETA 236 | 0x03B7, //GREEK SMALL LETTER ETA 237 | 0x03B8, //GREEK SMALL LETTER THETA 238 | 0x03B9, //GREEK SMALL LETTER IOTA 239 | 0x03BA, //GREEK SMALL LETTER KAPPA 240 | 0x03BB, //GREEK SMALL LETTER LAMDA 241 | 0x03BC, //GREEK SMALL LETTER MU 242 | 0x03BD, //GREEK SMALL LETTER NU 243 | 0x03BE, //GREEK SMALL LETTER XI 244 | 0x03BF, //GREEK SMALL LETTER OMICRON 245 | 0x03C0, //GREEK SMALL LETTER PI 246 | 0x03C1, //GREEK SMALL LETTER RHO 247 | 0x03C2, //GREEK SMALL LETTER FINAL SIGMA 248 | 0x03C3, //GREEK SMALL LETTER SIGMA 249 | 0x03C4, //GREEK SMALL LETTER TAU 250 | 0x03C5, //GREEK SMALL LETTER UPSILON 251 | 0x03C6, //GREEK SMALL LETTER PHI 252 | 0x03C7, //GREEK SMALL LETTER CHI 253 | 0x03C8, //GREEK SMALL LETTER PSI 254 | 0x03C9, //GREEK SMALL LETTER OMEGA 255 | 0x03CA, //GREEK SMALL LETTER IOTA WITH DIALYTIKA 256 | 0x03CB, //GREEK SMALL LETTER UPSILON WITH DIALYTIKA 257 | 0x03CC, //GREEK SMALL LETTER OMICRON WITH TONOS 258 | 0x03CD, //GREEK SMALL LETTER UPSILON WITH TONOS 259 | 0x03CE, //GREEK SMALL LETTER OMEGA WITH TONOS 260 | 0xFFFD, //UNDEFINED 261 | }, 262 | } 263 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/cp1255.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | var cp1255 *charsetMap = &charsetMap{ 4 | sb: [256]rune{ 5 | 0x0000, //NULL 6 | 0x0001, //START OF HEADING 7 | 0x0002, //START OF TEXT 8 | 0x0003, //END OF TEXT 9 | 0x0004, //END OF TRANSMISSION 10 | 0x0005, //ENQUIRY 11 | 0x0006, //ACKNOWLEDGE 12 | 0x0007, //BELL 13 | 0x0008, //BACKSPACE 14 | 0x0009, //HORIZONTAL TABULATION 15 | 0x000A, //LINE FEED 16 | 0x000B, //VERTICAL TABULATION 17 | 0x000C, //FORM FEED 18 | 0x000D, //CARRIAGE RETURN 19 | 0x000E, //SHIFT OUT 20 | 0x000F, //SHIFT IN 21 | 0x0010, //DATA LINK ESCAPE 22 | 0x0011, //DEVICE CONTROL ONE 23 | 0x0012, //DEVICE CONTROL TWO 24 | 0x0013, //DEVICE CONTROL THREE 25 | 0x0014, //DEVICE CONTROL FOUR 26 | 0x0015, //NEGATIVE ACKNOWLEDGE 27 | 0x0016, //SYNCHRONOUS IDLE 28 | 0x0017, //END OF TRANSMISSION BLOCK 29 | 0x0018, //CANCEL 30 | 0x0019, //END OF MEDIUM 31 | 0x001A, //SUBSTITUTE 32 | 0x001B, //ESCAPE 33 | 0x001C, //FILE SEPARATOR 34 | 0x001D, //GROUP SEPARATOR 35 | 0x001E, //RECORD SEPARATOR 36 | 0x001F, //UNIT SEPARATOR 37 | 0x0020, //SPACE 38 | 0x0021, //EXCLAMATION MARK 39 | 0x0022, //QUOTATION MARK 40 | 0x0023, //NUMBER SIGN 41 | 0x0024, //DOLLAR SIGN 42 | 0x0025, //PERCENT SIGN 43 | 0x0026, //AMPERSAND 44 | 0x0027, //APOSTROPHE 45 | 0x0028, //LEFT PARENTHESIS 46 | 0x0029, //RIGHT PARENTHESIS 47 | 0x002A, //ASTERISK 48 | 0x002B, //PLUS SIGN 49 | 0x002C, //COMMA 50 | 0x002D, //HYPHEN-MINUS 51 | 0x002E, //FULL STOP 52 | 0x002F, //SOLIDUS 53 | 0x0030, //DIGIT ZERO 54 | 0x0031, //DIGIT ONE 55 | 0x0032, //DIGIT TWO 56 | 0x0033, //DIGIT THREE 57 | 0x0034, //DIGIT FOUR 58 | 0x0035, //DIGIT FIVE 59 | 0x0036, //DIGIT SIX 60 | 0x0037, //DIGIT SEVEN 61 | 0x0038, //DIGIT EIGHT 62 | 0x0039, //DIGIT NINE 63 | 0x003A, //COLON 64 | 0x003B, //SEMICOLON 65 | 0x003C, //LESS-THAN SIGN 66 | 0x003D, //EQUALS SIGN 67 | 0x003E, //GREATER-THAN SIGN 68 | 0x003F, //QUESTION MARK 69 | 0x0040, //COMMERCIAL AT 70 | 0x0041, //LATIN CAPITAL LETTER A 71 | 0x0042, //LATIN CAPITAL LETTER B 72 | 0x0043, //LATIN CAPITAL LETTER C 73 | 0x0044, //LATIN CAPITAL LETTER D 74 | 0x0045, //LATIN CAPITAL LETTER E 75 | 0x0046, //LATIN CAPITAL LETTER F 76 | 0x0047, //LATIN CAPITAL LETTER G 77 | 0x0048, //LATIN CAPITAL LETTER H 78 | 0x0049, //LATIN CAPITAL LETTER I 79 | 0x004A, //LATIN CAPITAL LETTER J 80 | 0x004B, //LATIN CAPITAL LETTER K 81 | 0x004C, //LATIN CAPITAL LETTER L 82 | 0x004D, //LATIN CAPITAL LETTER M 83 | 0x004E, //LATIN CAPITAL LETTER N 84 | 0x004F, //LATIN CAPITAL LETTER O 85 | 0x0050, //LATIN CAPITAL LETTER P 86 | 0x0051, //LATIN CAPITAL LETTER Q 87 | 0x0052, //LATIN CAPITAL LETTER R 88 | 0x0053, //LATIN CAPITAL LETTER S 89 | 0x0054, //LATIN CAPITAL LETTER T 90 | 0x0055, //LATIN CAPITAL LETTER U 91 | 0x0056, //LATIN CAPITAL LETTER V 92 | 0x0057, //LATIN CAPITAL LETTER W 93 | 0x0058, //LATIN CAPITAL LETTER X 94 | 0x0059, //LATIN CAPITAL LETTER Y 95 | 0x005A, //LATIN CAPITAL LETTER Z 96 | 0x005B, //LEFT SQUARE BRACKET 97 | 0x005C, //REVERSE SOLIDUS 98 | 0x005D, //RIGHT SQUARE BRACKET 99 | 0x005E, //CIRCUMFLEX ACCENT 100 | 0x005F, //LOW LINE 101 | 0x0060, //GRAVE ACCENT 102 | 0x0061, //LATIN SMALL LETTER A 103 | 0x0062, //LATIN SMALL LETTER B 104 | 0x0063, //LATIN SMALL LETTER C 105 | 0x0064, //LATIN SMALL LETTER D 106 | 0x0065, //LATIN SMALL LETTER E 107 | 0x0066, //LATIN SMALL LETTER F 108 | 0x0067, //LATIN SMALL LETTER G 109 | 0x0068, //LATIN SMALL LETTER H 110 | 0x0069, //LATIN SMALL LETTER I 111 | 0x006A, //LATIN SMALL LETTER J 112 | 0x006B, //LATIN SMALL LETTER K 113 | 0x006C, //LATIN SMALL LETTER L 114 | 0x006D, //LATIN SMALL LETTER M 115 | 0x006E, //LATIN SMALL LETTER N 116 | 0x006F, //LATIN SMALL LETTER O 117 | 0x0070, //LATIN SMALL LETTER P 118 | 0x0071, //LATIN SMALL LETTER Q 119 | 0x0072, //LATIN SMALL LETTER R 120 | 0x0073, //LATIN SMALL LETTER S 121 | 0x0074, //LATIN SMALL LETTER T 122 | 0x0075, //LATIN SMALL LETTER U 123 | 0x0076, //LATIN SMALL LETTER V 124 | 0x0077, //LATIN SMALL LETTER W 125 | 0x0078, //LATIN SMALL LETTER X 126 | 0x0079, //LATIN SMALL LETTER Y 127 | 0x007A, //LATIN SMALL LETTER Z 128 | 0x007B, //LEFT CURLY BRACKET 129 | 0x007C, //VERTICAL LINE 130 | 0x007D, //RIGHT CURLY BRACKET 131 | 0x007E, //TILDE 132 | 0x007F, //DELETE 133 | 0x20AC, //EURO SIGN 134 | 0xFFFD, //UNDEFINED 135 | 0x201A, //SINGLE LOW-9 QUOTATION MARK 136 | 0x0192, //LATIN SMALL LETTER F WITH HOOK 137 | 0x201E, //DOUBLE LOW-9 QUOTATION MARK 138 | 0x2026, //HORIZONTAL ELLIPSIS 139 | 0x2020, //DAGGER 140 | 0x2021, //DOUBLE DAGGER 141 | 0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT 142 | 0x2030, //PER MILLE SIGN 143 | 0xFFFD, //UNDEFINED 144 | 0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK 145 | 0xFFFD, //UNDEFINED 146 | 0xFFFD, //UNDEFINED 147 | 0xFFFD, //UNDEFINED 148 | 0xFFFD, //UNDEFINED 149 | 0xFFFD, //UNDEFINED 150 | 0x2018, //LEFT SINGLE QUOTATION MARK 151 | 0x2019, //RIGHT SINGLE QUOTATION MARK 152 | 0x201C, //LEFT DOUBLE QUOTATION MARK 153 | 0x201D, //RIGHT DOUBLE QUOTATION MARK 154 | 0x2022, //BULLET 155 | 0x2013, //EN DASH 156 | 0x2014, //EM DASH 157 | 0x02DC, //SMALL TILDE 158 | 0x2122, //TRADE MARK SIGN 159 | 0xFFFD, //UNDEFINED 160 | 0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK 161 | 0xFFFD, //UNDEFINED 162 | 0xFFFD, //UNDEFINED 163 | 0xFFFD, //UNDEFINED 164 | 0xFFFD, //UNDEFINED 165 | 0x00A0, //NO-BREAK SPACE 166 | 0x00A1, //INVERTED EXCLAMATION MARK 167 | 0x00A2, //CENT SIGN 168 | 0x00A3, //POUND SIGN 169 | 0x20AA, //NEW SHEQEL SIGN 170 | 0x00A5, //YEN SIGN 171 | 0x00A6, //BROKEN BAR 172 | 0x00A7, //SECTION SIGN 173 | 0x00A8, //DIAERESIS 174 | 0x00A9, //COPYRIGHT SIGN 175 | 0x00D7, //MULTIPLICATION SIGN 176 | 0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 177 | 0x00AC, //NOT SIGN 178 | 0x00AD, //SOFT HYPHEN 179 | 0x00AE, //REGISTERED SIGN 180 | 0x00AF, //MACRON 181 | 0x00B0, //DEGREE SIGN 182 | 0x00B1, //PLUS-MINUS SIGN 183 | 0x00B2, //SUPERSCRIPT TWO 184 | 0x00B3, //SUPERSCRIPT THREE 185 | 0x00B4, //ACUTE ACCENT 186 | 0x00B5, //MICRO SIGN 187 | 0x00B6, //PILCROW SIGN 188 | 0x00B7, //MIDDLE DOT 189 | 0x00B8, //CEDILLA 190 | 0x00B9, //SUPERSCRIPT ONE 191 | 0x00F7, //DIVISION SIGN 192 | 0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 193 | 0x00BC, //VULGAR FRACTION ONE QUARTER 194 | 0x00BD, //VULGAR FRACTION ONE HALF 195 | 0x00BE, //VULGAR FRACTION THREE QUARTERS 196 | 0x00BF, //INVERTED QUESTION MARK 197 | 0x05B0, //HEBREW POINT SHEVA 198 | 0x05B1, //HEBREW POINT HATAF SEGOL 199 | 0x05B2, //HEBREW POINT HATAF PATAH 200 | 0x05B3, //HEBREW POINT HATAF QAMATS 201 | 0x05B4, //HEBREW POINT HIRIQ 202 | 0x05B5, //HEBREW POINT TSERE 203 | 0x05B6, //HEBREW POINT SEGOL 204 | 0x05B7, //HEBREW POINT PATAH 205 | 0x05B8, //HEBREW POINT QAMATS 206 | 0x05B9, //HEBREW POINT HOLAM 207 | 0xFFFD, //UNDEFINED 208 | 0x05BB, //HEBREW POINT QUBUTS 209 | 0x05BC, //HEBREW POINT DAGESH OR MAPIQ 210 | 0x05BD, //HEBREW POINT METEG 211 | 0x05BE, //HEBREW PUNCTUATION MAQAF 212 | 0x05BF, //HEBREW POINT RAFE 213 | 0x05C0, //HEBREW PUNCTUATION PASEQ 214 | 0x05C1, //HEBREW POINT SHIN DOT 215 | 0x05C2, //HEBREW POINT SIN DOT 216 | 0x05C3, //HEBREW PUNCTUATION SOF PASUQ 217 | 0x05F0, //HEBREW LIGATURE YIDDISH DOUBLE VAV 218 | 0x05F1, //HEBREW LIGATURE YIDDISH VAV YOD 219 | 0x05F2, //HEBREW LIGATURE YIDDISH DOUBLE YOD 220 | 0x05F3, //HEBREW PUNCTUATION GERESH 221 | 0x05F4, //HEBREW PUNCTUATION GERSHAYIM 222 | 0xFFFD, //UNDEFINED 223 | 0xFFFD, //UNDEFINED 224 | 0xFFFD, //UNDEFINED 225 | 0xFFFD, //UNDEFINED 226 | 0xFFFD, //UNDEFINED 227 | 0xFFFD, //UNDEFINED 228 | 0xFFFD, //UNDEFINED 229 | 0x05D0, //HEBREW LETTER ALEF 230 | 0x05D1, //HEBREW LETTER BET 231 | 0x05D2, //HEBREW LETTER GIMEL 232 | 0x05D3, //HEBREW LETTER DALET 233 | 0x05D4, //HEBREW LETTER HE 234 | 0x05D5, //HEBREW LETTER VAV 235 | 0x05D6, //HEBREW LETTER ZAYIN 236 | 0x05D7, //HEBREW LETTER HET 237 | 0x05D8, //HEBREW LETTER TET 238 | 0x05D9, //HEBREW LETTER YOD 239 | 0x05DA, //HEBREW LETTER FINAL KAF 240 | 0x05DB, //HEBREW LETTER KAF 241 | 0x05DC, //HEBREW LETTER LAMED 242 | 0x05DD, //HEBREW LETTER FINAL MEM 243 | 0x05DE, //HEBREW LETTER MEM 244 | 0x05DF, //HEBREW LETTER FINAL NUN 245 | 0x05E0, //HEBREW LETTER NUN 246 | 0x05E1, //HEBREW LETTER SAMEKH 247 | 0x05E2, //HEBREW LETTER AYIN 248 | 0x05E3, //HEBREW LETTER FINAL PE 249 | 0x05E4, //HEBREW LETTER PE 250 | 0x05E5, //HEBREW LETTER FINAL TSADI 251 | 0x05E6, //HEBREW LETTER TSADI 252 | 0x05E7, //HEBREW LETTER QOF 253 | 0x05E8, //HEBREW LETTER RESH 254 | 0x05E9, //HEBREW LETTER SHIN 255 | 0x05EA, //HEBREW LETTER TAV 256 | 0xFFFD, //UNDEFINED 257 | 0xFFFD, //UNDEFINED 258 | 0x200E, //LEFT-TO-RIGHT MARK 259 | 0x200F, //RIGHT-TO-LEFT MARK 260 | 0xFFFD, //UNDEFINED 261 | }, 262 | } 263 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/cp1256.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | var cp1256 *charsetMap = &charsetMap{ 4 | sb: [256]rune{ 5 | 0x0000, //NULL 6 | 0x0001, //START OF HEADING 7 | 0x0002, //START OF TEXT 8 | 0x0003, //END OF TEXT 9 | 0x0004, //END OF TRANSMISSION 10 | 0x0005, //ENQUIRY 11 | 0x0006, //ACKNOWLEDGE 12 | 0x0007, //BELL 13 | 0x0008, //BACKSPACE 14 | 0x0009, //HORIZONTAL TABULATION 15 | 0x000A, //LINE FEED 16 | 0x000B, //VERTICAL TABULATION 17 | 0x000C, //FORM FEED 18 | 0x000D, //CARRIAGE RETURN 19 | 0x000E, //SHIFT OUT 20 | 0x000F, //SHIFT IN 21 | 0x0010, //DATA LINK ESCAPE 22 | 0x0011, //DEVICE CONTROL ONE 23 | 0x0012, //DEVICE CONTROL TWO 24 | 0x0013, //DEVICE CONTROL THREE 25 | 0x0014, //DEVICE CONTROL FOUR 26 | 0x0015, //NEGATIVE ACKNOWLEDGE 27 | 0x0016, //SYNCHRONOUS IDLE 28 | 0x0017, //END OF TRANSMISSION BLOCK 29 | 0x0018, //CANCEL 30 | 0x0019, //END OF MEDIUM 31 | 0x001A, //SUBSTITUTE 32 | 0x001B, //ESCAPE 33 | 0x001C, //FILE SEPARATOR 34 | 0x001D, //GROUP SEPARATOR 35 | 0x001E, //RECORD SEPARATOR 36 | 0x001F, //UNIT SEPARATOR 37 | 0x0020, //SPACE 38 | 0x0021, //EXCLAMATION MARK 39 | 0x0022, //QUOTATION MARK 40 | 0x0023, //NUMBER SIGN 41 | 0x0024, //DOLLAR SIGN 42 | 0x0025, //PERCENT SIGN 43 | 0x0026, //AMPERSAND 44 | 0x0027, //APOSTROPHE 45 | 0x0028, //LEFT PARENTHESIS 46 | 0x0029, //RIGHT PARENTHESIS 47 | 0x002A, //ASTERISK 48 | 0x002B, //PLUS SIGN 49 | 0x002C, //COMMA 50 | 0x002D, //HYPHEN-MINUS 51 | 0x002E, //FULL STOP 52 | 0x002F, //SOLIDUS 53 | 0x0030, //DIGIT ZERO 54 | 0x0031, //DIGIT ONE 55 | 0x0032, //DIGIT TWO 56 | 0x0033, //DIGIT THREE 57 | 0x0034, //DIGIT FOUR 58 | 0x0035, //DIGIT FIVE 59 | 0x0036, //DIGIT SIX 60 | 0x0037, //DIGIT SEVEN 61 | 0x0038, //DIGIT EIGHT 62 | 0x0039, //DIGIT NINE 63 | 0x003A, //COLON 64 | 0x003B, //SEMICOLON 65 | 0x003C, //LESS-THAN SIGN 66 | 0x003D, //EQUALS SIGN 67 | 0x003E, //GREATER-THAN SIGN 68 | 0x003F, //QUESTION MARK 69 | 0x0040, //COMMERCIAL AT 70 | 0x0041, //LATIN CAPITAL LETTER A 71 | 0x0042, //LATIN CAPITAL LETTER B 72 | 0x0043, //LATIN CAPITAL LETTER C 73 | 0x0044, //LATIN CAPITAL LETTER D 74 | 0x0045, //LATIN CAPITAL LETTER E 75 | 0x0046, //LATIN CAPITAL LETTER F 76 | 0x0047, //LATIN CAPITAL LETTER G 77 | 0x0048, //LATIN CAPITAL LETTER H 78 | 0x0049, //LATIN CAPITAL LETTER I 79 | 0x004A, //LATIN CAPITAL LETTER J 80 | 0x004B, //LATIN CAPITAL LETTER K 81 | 0x004C, //LATIN CAPITAL LETTER L 82 | 0x004D, //LATIN CAPITAL LETTER M 83 | 0x004E, //LATIN CAPITAL LETTER N 84 | 0x004F, //LATIN CAPITAL LETTER O 85 | 0x0050, //LATIN CAPITAL LETTER P 86 | 0x0051, //LATIN CAPITAL LETTER Q 87 | 0x0052, //LATIN CAPITAL LETTER R 88 | 0x0053, //LATIN CAPITAL LETTER S 89 | 0x0054, //LATIN CAPITAL LETTER T 90 | 0x0055, //LATIN CAPITAL LETTER U 91 | 0x0056, //LATIN CAPITAL LETTER V 92 | 0x0057, //LATIN CAPITAL LETTER W 93 | 0x0058, //LATIN CAPITAL LETTER X 94 | 0x0059, //LATIN CAPITAL LETTER Y 95 | 0x005A, //LATIN CAPITAL LETTER Z 96 | 0x005B, //LEFT SQUARE BRACKET 97 | 0x005C, //REVERSE SOLIDUS 98 | 0x005D, //RIGHT SQUARE BRACKET 99 | 0x005E, //CIRCUMFLEX ACCENT 100 | 0x005F, //LOW LINE 101 | 0x0060, //GRAVE ACCENT 102 | 0x0061, //LATIN SMALL LETTER A 103 | 0x0062, //LATIN SMALL LETTER B 104 | 0x0063, //LATIN SMALL LETTER C 105 | 0x0064, //LATIN SMALL LETTER D 106 | 0x0065, //LATIN SMALL LETTER E 107 | 0x0066, //LATIN SMALL LETTER F 108 | 0x0067, //LATIN SMALL LETTER G 109 | 0x0068, //LATIN SMALL LETTER H 110 | 0x0069, //LATIN SMALL LETTER I 111 | 0x006A, //LATIN SMALL LETTER J 112 | 0x006B, //LATIN SMALL LETTER K 113 | 0x006C, //LATIN SMALL LETTER L 114 | 0x006D, //LATIN SMALL LETTER M 115 | 0x006E, //LATIN SMALL LETTER N 116 | 0x006F, //LATIN SMALL LETTER O 117 | 0x0070, //LATIN SMALL LETTER P 118 | 0x0071, //LATIN SMALL LETTER Q 119 | 0x0072, //LATIN SMALL LETTER R 120 | 0x0073, //LATIN SMALL LETTER S 121 | 0x0074, //LATIN SMALL LETTER T 122 | 0x0075, //LATIN SMALL LETTER U 123 | 0x0076, //LATIN SMALL LETTER V 124 | 0x0077, //LATIN SMALL LETTER W 125 | 0x0078, //LATIN SMALL LETTER X 126 | 0x0079, //LATIN SMALL LETTER Y 127 | 0x007A, //LATIN SMALL LETTER Z 128 | 0x007B, //LEFT CURLY BRACKET 129 | 0x007C, //VERTICAL LINE 130 | 0x007D, //RIGHT CURLY BRACKET 131 | 0x007E, //TILDE 132 | 0x007F, //DELETE 133 | 0x20AC, //EURO SIGN 134 | 0x067E, //ARABIC LETTER PEH 135 | 0x201A, //SINGLE LOW-9 QUOTATION MARK 136 | 0x0192, //LATIN SMALL LETTER F WITH HOOK 137 | 0x201E, //DOUBLE LOW-9 QUOTATION MARK 138 | 0x2026, //HORIZONTAL ELLIPSIS 139 | 0x2020, //DAGGER 140 | 0x2021, //DOUBLE DAGGER 141 | 0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT 142 | 0x2030, //PER MILLE SIGN 143 | 0x0679, //ARABIC LETTER TTEH 144 | 0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK 145 | 0x0152, //LATIN CAPITAL LIGATURE OE 146 | 0x0686, //ARABIC LETTER TCHEH 147 | 0x0698, //ARABIC LETTER JEH 148 | 0x0688, //ARABIC LETTER DDAL 149 | 0x06AF, //ARABIC LETTER GAF 150 | 0x2018, //LEFT SINGLE QUOTATION MARK 151 | 0x2019, //RIGHT SINGLE QUOTATION MARK 152 | 0x201C, //LEFT DOUBLE QUOTATION MARK 153 | 0x201D, //RIGHT DOUBLE QUOTATION MARK 154 | 0x2022, //BULLET 155 | 0x2013, //EN DASH 156 | 0x2014, //EM DASH 157 | 0x06A9, //ARABIC LETTER KEHEH 158 | 0x2122, //TRADE MARK SIGN 159 | 0x0691, //ARABIC LETTER RREH 160 | 0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK 161 | 0x0153, //LATIN SMALL LIGATURE OE 162 | 0x200C, //ZERO WIDTH NON-JOINER 163 | 0x200D, //ZERO WIDTH JOINER 164 | 0x06BA, //ARABIC LETTER NOON GHUNNA 165 | 0x00A0, //NO-BREAK SPACE 166 | 0x060C, //ARABIC COMMA 167 | 0x00A2, //CENT SIGN 168 | 0x00A3, //POUND SIGN 169 | 0x00A4, //CURRENCY SIGN 170 | 0x00A5, //YEN SIGN 171 | 0x00A6, //BROKEN BAR 172 | 0x00A7, //SECTION SIGN 173 | 0x00A8, //DIAERESIS 174 | 0x00A9, //COPYRIGHT SIGN 175 | 0x06BE, //ARABIC LETTER HEH DOACHASHMEE 176 | 0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 177 | 0x00AC, //NOT SIGN 178 | 0x00AD, //SOFT HYPHEN 179 | 0x00AE, //REGISTERED SIGN 180 | 0x00AF, //MACRON 181 | 0x00B0, //DEGREE SIGN 182 | 0x00B1, //PLUS-MINUS SIGN 183 | 0x00B2, //SUPERSCRIPT TWO 184 | 0x00B3, //SUPERSCRIPT THREE 185 | 0x00B4, //ACUTE ACCENT 186 | 0x00B5, //MICRO SIGN 187 | 0x00B6, //PILCROW SIGN 188 | 0x00B7, //MIDDLE DOT 189 | 0x00B8, //CEDILLA 190 | 0x00B9, //SUPERSCRIPT ONE 191 | 0x061B, //ARABIC SEMICOLON 192 | 0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 193 | 0x00BC, //VULGAR FRACTION ONE QUARTER 194 | 0x00BD, //VULGAR FRACTION ONE HALF 195 | 0x00BE, //VULGAR FRACTION THREE QUARTERS 196 | 0x061F, //ARABIC QUESTION MARK 197 | 0x06C1, //ARABIC LETTER HEH GOAL 198 | 0x0621, //ARABIC LETTER HAMZA 199 | 0x0622, //ARABIC LETTER ALEF WITH MADDA ABOVE 200 | 0x0623, //ARABIC LETTER ALEF WITH HAMZA ABOVE 201 | 0x0624, //ARABIC LETTER WAW WITH HAMZA ABOVE 202 | 0x0625, //ARABIC LETTER ALEF WITH HAMZA BELOW 203 | 0x0626, //ARABIC LETTER YEH WITH HAMZA ABOVE 204 | 0x0627, //ARABIC LETTER ALEF 205 | 0x0628, //ARABIC LETTER BEH 206 | 0x0629, //ARABIC LETTER TEH MARBUTA 207 | 0x062A, //ARABIC LETTER TEH 208 | 0x062B, //ARABIC LETTER THEH 209 | 0x062C, //ARABIC LETTER JEEM 210 | 0x062D, //ARABIC LETTER HAH 211 | 0x062E, //ARABIC LETTER KHAH 212 | 0x062F, //ARABIC LETTER DAL 213 | 0x0630, //ARABIC LETTER THAL 214 | 0x0631, //ARABIC LETTER REH 215 | 0x0632, //ARABIC LETTER ZAIN 216 | 0x0633, //ARABIC LETTER SEEN 217 | 0x0634, //ARABIC LETTER SHEEN 218 | 0x0635, //ARABIC LETTER SAD 219 | 0x0636, //ARABIC LETTER DAD 220 | 0x00D7, //MULTIPLICATION SIGN 221 | 0x0637, //ARABIC LETTER TAH 222 | 0x0638, //ARABIC LETTER ZAH 223 | 0x0639, //ARABIC LETTER AIN 224 | 0x063A, //ARABIC LETTER GHAIN 225 | 0x0640, //ARABIC TATWEEL 226 | 0x0641, //ARABIC LETTER FEH 227 | 0x0642, //ARABIC LETTER QAF 228 | 0x0643, //ARABIC LETTER KAF 229 | 0x00E0, //LATIN SMALL LETTER A WITH GRAVE 230 | 0x0644, //ARABIC LETTER LAM 231 | 0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX 232 | 0x0645, //ARABIC LETTER MEEM 233 | 0x0646, //ARABIC LETTER NOON 234 | 0x0647, //ARABIC LETTER HEH 235 | 0x0648, //ARABIC LETTER WAW 236 | 0x00E7, //LATIN SMALL LETTER C WITH CEDILLA 237 | 0x00E8, //LATIN SMALL LETTER E WITH GRAVE 238 | 0x00E9, //LATIN SMALL LETTER E WITH ACUTE 239 | 0x00EA, //LATIN SMALL LETTER E WITH CIRCUMFLEX 240 | 0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS 241 | 0x0649, //ARABIC LETTER ALEF MAKSURA 242 | 0x064A, //ARABIC LETTER YEH 243 | 0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX 244 | 0x00EF, //LATIN SMALL LETTER I WITH DIAERESIS 245 | 0x064B, //ARABIC FATHATAN 246 | 0x064C, //ARABIC DAMMATAN 247 | 0x064D, //ARABIC KASRATAN 248 | 0x064E, //ARABIC FATHA 249 | 0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX 250 | 0x064F, //ARABIC DAMMA 251 | 0x0650, //ARABIC KASRA 252 | 0x00F7, //DIVISION SIGN 253 | 0x0651, //ARABIC SHADDA 254 | 0x00F9, //LATIN SMALL LETTER U WITH GRAVE 255 | 0x0652, //ARABIC SUKUN 256 | 0x00FB, //LATIN SMALL LETTER U WITH CIRCUMFLEX 257 | 0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS 258 | 0x200E, //LEFT-TO-RIGHT MARK 259 | 0x200F, //RIGHT-TO-LEFT MARK 260 | 0x06D2, //ARABIC LETTER YEH BARREE 261 | }, 262 | } 263 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/cp1257.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | var cp1257 *charsetMap = &charsetMap{ 4 | sb: [256]rune{ 5 | 0x0000, //NULL 6 | 0x0001, //START OF HEADING 7 | 0x0002, //START OF TEXT 8 | 0x0003, //END OF TEXT 9 | 0x0004, //END OF TRANSMISSION 10 | 0x0005, //ENQUIRY 11 | 0x0006, //ACKNOWLEDGE 12 | 0x0007, //BELL 13 | 0x0008, //BACKSPACE 14 | 0x0009, //HORIZONTAL TABULATION 15 | 0x000A, //LINE FEED 16 | 0x000B, //VERTICAL TABULATION 17 | 0x000C, //FORM FEED 18 | 0x000D, //CARRIAGE RETURN 19 | 0x000E, //SHIFT OUT 20 | 0x000F, //SHIFT IN 21 | 0x0010, //DATA LINK ESCAPE 22 | 0x0011, //DEVICE CONTROL ONE 23 | 0x0012, //DEVICE CONTROL TWO 24 | 0x0013, //DEVICE CONTROL THREE 25 | 0x0014, //DEVICE CONTROL FOUR 26 | 0x0015, //NEGATIVE ACKNOWLEDGE 27 | 0x0016, //SYNCHRONOUS IDLE 28 | 0x0017, //END OF TRANSMISSION BLOCK 29 | 0x0018, //CANCEL 30 | 0x0019, //END OF MEDIUM 31 | 0x001A, //SUBSTITUTE 32 | 0x001B, //ESCAPE 33 | 0x001C, //FILE SEPARATOR 34 | 0x001D, //GROUP SEPARATOR 35 | 0x001E, //RECORD SEPARATOR 36 | 0x001F, //UNIT SEPARATOR 37 | 0x0020, //SPACE 38 | 0x0021, //EXCLAMATION MARK 39 | 0x0022, //QUOTATION MARK 40 | 0x0023, //NUMBER SIGN 41 | 0x0024, //DOLLAR SIGN 42 | 0x0025, //PERCENT SIGN 43 | 0x0026, //AMPERSAND 44 | 0x0027, //APOSTROPHE 45 | 0x0028, //LEFT PARENTHESIS 46 | 0x0029, //RIGHT PARENTHESIS 47 | 0x002A, //ASTERISK 48 | 0x002B, //PLUS SIGN 49 | 0x002C, //COMMA 50 | 0x002D, //HYPHEN-MINUS 51 | 0x002E, //FULL STOP 52 | 0x002F, //SOLIDUS 53 | 0x0030, //DIGIT ZERO 54 | 0x0031, //DIGIT ONE 55 | 0x0032, //DIGIT TWO 56 | 0x0033, //DIGIT THREE 57 | 0x0034, //DIGIT FOUR 58 | 0x0035, //DIGIT FIVE 59 | 0x0036, //DIGIT SIX 60 | 0x0037, //DIGIT SEVEN 61 | 0x0038, //DIGIT EIGHT 62 | 0x0039, //DIGIT NINE 63 | 0x003A, //COLON 64 | 0x003B, //SEMICOLON 65 | 0x003C, //LESS-THAN SIGN 66 | 0x003D, //EQUALS SIGN 67 | 0x003E, //GREATER-THAN SIGN 68 | 0x003F, //QUESTION MARK 69 | 0x0040, //COMMERCIAL AT 70 | 0x0041, //LATIN CAPITAL LETTER A 71 | 0x0042, //LATIN CAPITAL LETTER B 72 | 0x0043, //LATIN CAPITAL LETTER C 73 | 0x0044, //LATIN CAPITAL LETTER D 74 | 0x0045, //LATIN CAPITAL LETTER E 75 | 0x0046, //LATIN CAPITAL LETTER F 76 | 0x0047, //LATIN CAPITAL LETTER G 77 | 0x0048, //LATIN CAPITAL LETTER H 78 | 0x0049, //LATIN CAPITAL LETTER I 79 | 0x004A, //LATIN CAPITAL LETTER J 80 | 0x004B, //LATIN CAPITAL LETTER K 81 | 0x004C, //LATIN CAPITAL LETTER L 82 | 0x004D, //LATIN CAPITAL LETTER M 83 | 0x004E, //LATIN CAPITAL LETTER N 84 | 0x004F, //LATIN CAPITAL LETTER O 85 | 0x0050, //LATIN CAPITAL LETTER P 86 | 0x0051, //LATIN CAPITAL LETTER Q 87 | 0x0052, //LATIN CAPITAL LETTER R 88 | 0x0053, //LATIN CAPITAL LETTER S 89 | 0x0054, //LATIN CAPITAL LETTER T 90 | 0x0055, //LATIN CAPITAL LETTER U 91 | 0x0056, //LATIN CAPITAL LETTER V 92 | 0x0057, //LATIN CAPITAL LETTER W 93 | 0x0058, //LATIN CAPITAL LETTER X 94 | 0x0059, //LATIN CAPITAL LETTER Y 95 | 0x005A, //LATIN CAPITAL LETTER Z 96 | 0x005B, //LEFT SQUARE BRACKET 97 | 0x005C, //REVERSE SOLIDUS 98 | 0x005D, //RIGHT SQUARE BRACKET 99 | 0x005E, //CIRCUMFLEX ACCENT 100 | 0x005F, //LOW LINE 101 | 0x0060, //GRAVE ACCENT 102 | 0x0061, //LATIN SMALL LETTER A 103 | 0x0062, //LATIN SMALL LETTER B 104 | 0x0063, //LATIN SMALL LETTER C 105 | 0x0064, //LATIN SMALL LETTER D 106 | 0x0065, //LATIN SMALL LETTER E 107 | 0x0066, //LATIN SMALL LETTER F 108 | 0x0067, //LATIN SMALL LETTER G 109 | 0x0068, //LATIN SMALL LETTER H 110 | 0x0069, //LATIN SMALL LETTER I 111 | 0x006A, //LATIN SMALL LETTER J 112 | 0x006B, //LATIN SMALL LETTER K 113 | 0x006C, //LATIN SMALL LETTER L 114 | 0x006D, //LATIN SMALL LETTER M 115 | 0x006E, //LATIN SMALL LETTER N 116 | 0x006F, //LATIN SMALL LETTER O 117 | 0x0070, //LATIN SMALL LETTER P 118 | 0x0071, //LATIN SMALL LETTER Q 119 | 0x0072, //LATIN SMALL LETTER R 120 | 0x0073, //LATIN SMALL LETTER S 121 | 0x0074, //LATIN SMALL LETTER T 122 | 0x0075, //LATIN SMALL LETTER U 123 | 0x0076, //LATIN SMALL LETTER V 124 | 0x0077, //LATIN SMALL LETTER W 125 | 0x0078, //LATIN SMALL LETTER X 126 | 0x0079, //LATIN SMALL LETTER Y 127 | 0x007A, //LATIN SMALL LETTER Z 128 | 0x007B, //LEFT CURLY BRACKET 129 | 0x007C, //VERTICAL LINE 130 | 0x007D, //RIGHT CURLY BRACKET 131 | 0x007E, //TILDE 132 | 0x007F, //DELETE 133 | 0x20AC, //EURO SIGN 134 | 0xFFFD, //UNDEFINED 135 | 0x201A, //SINGLE LOW-9 QUOTATION MARK 136 | 0xFFFD, //UNDEFINED 137 | 0x201E, //DOUBLE LOW-9 QUOTATION MARK 138 | 0x2026, //HORIZONTAL ELLIPSIS 139 | 0x2020, //DAGGER 140 | 0x2021, //DOUBLE DAGGER 141 | 0xFFFD, //UNDEFINED 142 | 0x2030, //PER MILLE SIGN 143 | 0xFFFD, //UNDEFINED 144 | 0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK 145 | 0xFFFD, //UNDEFINED 146 | 0x00A8, //DIAERESIS 147 | 0x02C7, //CARON 148 | 0x00B8, //CEDILLA 149 | 0xFFFD, //UNDEFINED 150 | 0x2018, //LEFT SINGLE QUOTATION MARK 151 | 0x2019, //RIGHT SINGLE QUOTATION MARK 152 | 0x201C, //LEFT DOUBLE QUOTATION MARK 153 | 0x201D, //RIGHT DOUBLE QUOTATION MARK 154 | 0x2022, //BULLET 155 | 0x2013, //EN DASH 156 | 0x2014, //EM DASH 157 | 0xFFFD, //UNDEFINED 158 | 0x2122, //TRADE MARK SIGN 159 | 0xFFFD, //UNDEFINED 160 | 0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK 161 | 0xFFFD, //UNDEFINED 162 | 0x00AF, //MACRON 163 | 0x02DB, //OGONEK 164 | 0xFFFD, //UNDEFINED 165 | 0x00A0, //NO-BREAK SPACE 166 | 0xFFFD, //UNDEFINED 167 | 0x00A2, //CENT SIGN 168 | 0x00A3, //POUND SIGN 169 | 0x00A4, //CURRENCY SIGN 170 | 0xFFFD, //UNDEFINED 171 | 0x00A6, //BROKEN BAR 172 | 0x00A7, //SECTION SIGN 173 | 0x00D8, //LATIN CAPITAL LETTER O WITH STROKE 174 | 0x00A9, //COPYRIGHT SIGN 175 | 0x0156, //LATIN CAPITAL LETTER R WITH CEDILLA 176 | 0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 177 | 0x00AC, //NOT SIGN 178 | 0x00AD, //SOFT HYPHEN 179 | 0x00AE, //REGISTERED SIGN 180 | 0x00C6, //LATIN CAPITAL LETTER AE 181 | 0x00B0, //DEGREE SIGN 182 | 0x00B1, //PLUS-MINUS SIGN 183 | 0x00B2, //SUPERSCRIPT TWO 184 | 0x00B3, //SUPERSCRIPT THREE 185 | 0x00B4, //ACUTE ACCENT 186 | 0x00B5, //MICRO SIGN 187 | 0x00B6, //PILCROW SIGN 188 | 0x00B7, //MIDDLE DOT 189 | 0x00F8, //LATIN SMALL LETTER O WITH STROKE 190 | 0x00B9, //SUPERSCRIPT ONE 191 | 0x0157, //LATIN SMALL LETTER R WITH CEDILLA 192 | 0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 193 | 0x00BC, //VULGAR FRACTION ONE QUARTER 194 | 0x00BD, //VULGAR FRACTION ONE HALF 195 | 0x00BE, //VULGAR FRACTION THREE QUARTERS 196 | 0x00E6, //LATIN SMALL LETTER AE 197 | 0x0104, //LATIN CAPITAL LETTER A WITH OGONEK 198 | 0x012E, //LATIN CAPITAL LETTER I WITH OGONEK 199 | 0x0100, //LATIN CAPITAL LETTER A WITH MACRON 200 | 0x0106, //LATIN CAPITAL LETTER C WITH ACUTE 201 | 0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS 202 | 0x00C5, //LATIN CAPITAL LETTER A WITH RING ABOVE 203 | 0x0118, //LATIN CAPITAL LETTER E WITH OGONEK 204 | 0x0112, //LATIN CAPITAL LETTER E WITH MACRON 205 | 0x010C, //LATIN CAPITAL LETTER C WITH CARON 206 | 0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE 207 | 0x0179, //LATIN CAPITAL LETTER Z WITH ACUTE 208 | 0x0116, //LATIN CAPITAL LETTER E WITH DOT ABOVE 209 | 0x0122, //LATIN CAPITAL LETTER G WITH CEDILLA 210 | 0x0136, //LATIN CAPITAL LETTER K WITH CEDILLA 211 | 0x012A, //LATIN CAPITAL LETTER I WITH MACRON 212 | 0x013B, //LATIN CAPITAL LETTER L WITH CEDILLA 213 | 0x0160, //LATIN CAPITAL LETTER S WITH CARON 214 | 0x0143, //LATIN CAPITAL LETTER N WITH ACUTE 215 | 0x0145, //LATIN CAPITAL LETTER N WITH CEDILLA 216 | 0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE 217 | 0x014C, //LATIN CAPITAL LETTER O WITH MACRON 218 | 0x00D5, //LATIN CAPITAL LETTER O WITH TILDE 219 | 0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS 220 | 0x00D7, //MULTIPLICATION SIGN 221 | 0x0172, //LATIN CAPITAL LETTER U WITH OGONEK 222 | 0x0141, //LATIN CAPITAL LETTER L WITH STROKE 223 | 0x015A, //LATIN CAPITAL LETTER S WITH ACUTE 224 | 0x016A, //LATIN CAPITAL LETTER U WITH MACRON 225 | 0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS 226 | 0x017B, //LATIN CAPITAL LETTER Z WITH DOT ABOVE 227 | 0x017D, //LATIN CAPITAL LETTER Z WITH CARON 228 | 0x00DF, //LATIN SMALL LETTER SHARP S 229 | 0x0105, //LATIN SMALL LETTER A WITH OGONEK 230 | 0x012F, //LATIN SMALL LETTER I WITH OGONEK 231 | 0x0101, //LATIN SMALL LETTER A WITH MACRON 232 | 0x0107, //LATIN SMALL LETTER C WITH ACUTE 233 | 0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS 234 | 0x00E5, //LATIN SMALL LETTER A WITH RING ABOVE 235 | 0x0119, //LATIN SMALL LETTER E WITH OGONEK 236 | 0x0113, //LATIN SMALL LETTER E WITH MACRON 237 | 0x010D, //LATIN SMALL LETTER C WITH CARON 238 | 0x00E9, //LATIN SMALL LETTER E WITH ACUTE 239 | 0x017A, //LATIN SMALL LETTER Z WITH ACUTE 240 | 0x0117, //LATIN SMALL LETTER E WITH DOT ABOVE 241 | 0x0123, //LATIN SMALL LETTER G WITH CEDILLA 242 | 0x0137, //LATIN SMALL LETTER K WITH CEDILLA 243 | 0x012B, //LATIN SMALL LETTER I WITH MACRON 244 | 0x013C, //LATIN SMALL LETTER L WITH CEDILLA 245 | 0x0161, //LATIN SMALL LETTER S WITH CARON 246 | 0x0144, //LATIN SMALL LETTER N WITH ACUTE 247 | 0x0146, //LATIN SMALL LETTER N WITH CEDILLA 248 | 0x00F3, //LATIN SMALL LETTER O WITH ACUTE 249 | 0x014D, //LATIN SMALL LETTER O WITH MACRON 250 | 0x00F5, //LATIN SMALL LETTER O WITH TILDE 251 | 0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS 252 | 0x00F7, //DIVISION SIGN 253 | 0x0173, //LATIN SMALL LETTER U WITH OGONEK 254 | 0x0142, //LATIN SMALL LETTER L WITH STROKE 255 | 0x015B, //LATIN SMALL LETTER S WITH ACUTE 256 | 0x016B, //LATIN SMALL LETTER U WITH MACRON 257 | 0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS 258 | 0x017C, //LATIN SMALL LETTER Z WITH DOT ABOVE 259 | 0x017E, //LATIN SMALL LETTER Z WITH CARON 260 | 0x02D9, //DOT ABOVE 261 | }, 262 | } 263 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/cp1258.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | var cp1258 *charsetMap = &charsetMap{ 4 | sb: [256]rune{ 5 | 0x0000, //NULL 6 | 0x0001, //START OF HEADING 7 | 0x0002, //START OF TEXT 8 | 0x0003, //END OF TEXT 9 | 0x0004, //END OF TRANSMISSION 10 | 0x0005, //ENQUIRY 11 | 0x0006, //ACKNOWLEDGE 12 | 0x0007, //BELL 13 | 0x0008, //BACKSPACE 14 | 0x0009, //HORIZONTAL TABULATION 15 | 0x000A, //LINE FEED 16 | 0x000B, //VERTICAL TABULATION 17 | 0x000C, //FORM FEED 18 | 0x000D, //CARRIAGE RETURN 19 | 0x000E, //SHIFT OUT 20 | 0x000F, //SHIFT IN 21 | 0x0010, //DATA LINK ESCAPE 22 | 0x0011, //DEVICE CONTROL ONE 23 | 0x0012, //DEVICE CONTROL TWO 24 | 0x0013, //DEVICE CONTROL THREE 25 | 0x0014, //DEVICE CONTROL FOUR 26 | 0x0015, //NEGATIVE ACKNOWLEDGE 27 | 0x0016, //SYNCHRONOUS IDLE 28 | 0x0017, //END OF TRANSMISSION BLOCK 29 | 0x0018, //CANCEL 30 | 0x0019, //END OF MEDIUM 31 | 0x001A, //SUBSTITUTE 32 | 0x001B, //ESCAPE 33 | 0x001C, //FILE SEPARATOR 34 | 0x001D, //GROUP SEPARATOR 35 | 0x001E, //RECORD SEPARATOR 36 | 0x001F, //UNIT SEPARATOR 37 | 0x0020, //SPACE 38 | 0x0021, //EXCLAMATION MARK 39 | 0x0022, //QUOTATION MARK 40 | 0x0023, //NUMBER SIGN 41 | 0x0024, //DOLLAR SIGN 42 | 0x0025, //PERCENT SIGN 43 | 0x0026, //AMPERSAND 44 | 0x0027, //APOSTROPHE 45 | 0x0028, //LEFT PARENTHESIS 46 | 0x0029, //RIGHT PARENTHESIS 47 | 0x002A, //ASTERISK 48 | 0x002B, //PLUS SIGN 49 | 0x002C, //COMMA 50 | 0x002D, //HYPHEN-MINUS 51 | 0x002E, //FULL STOP 52 | 0x002F, //SOLIDUS 53 | 0x0030, //DIGIT ZERO 54 | 0x0031, //DIGIT ONE 55 | 0x0032, //DIGIT TWO 56 | 0x0033, //DIGIT THREE 57 | 0x0034, //DIGIT FOUR 58 | 0x0035, //DIGIT FIVE 59 | 0x0036, //DIGIT SIX 60 | 0x0037, //DIGIT SEVEN 61 | 0x0038, //DIGIT EIGHT 62 | 0x0039, //DIGIT NINE 63 | 0x003A, //COLON 64 | 0x003B, //SEMICOLON 65 | 0x003C, //LESS-THAN SIGN 66 | 0x003D, //EQUALS SIGN 67 | 0x003E, //GREATER-THAN SIGN 68 | 0x003F, //QUESTION MARK 69 | 0x0040, //COMMERCIAL AT 70 | 0x0041, //LATIN CAPITAL LETTER A 71 | 0x0042, //LATIN CAPITAL LETTER B 72 | 0x0043, //LATIN CAPITAL LETTER C 73 | 0x0044, //LATIN CAPITAL LETTER D 74 | 0x0045, //LATIN CAPITAL LETTER E 75 | 0x0046, //LATIN CAPITAL LETTER F 76 | 0x0047, //LATIN CAPITAL LETTER G 77 | 0x0048, //LATIN CAPITAL LETTER H 78 | 0x0049, //LATIN CAPITAL LETTER I 79 | 0x004A, //LATIN CAPITAL LETTER J 80 | 0x004B, //LATIN CAPITAL LETTER K 81 | 0x004C, //LATIN CAPITAL LETTER L 82 | 0x004D, //LATIN CAPITAL LETTER M 83 | 0x004E, //LATIN CAPITAL LETTER N 84 | 0x004F, //LATIN CAPITAL LETTER O 85 | 0x0050, //LATIN CAPITAL LETTER P 86 | 0x0051, //LATIN CAPITAL LETTER Q 87 | 0x0052, //LATIN CAPITAL LETTER R 88 | 0x0053, //LATIN CAPITAL LETTER S 89 | 0x0054, //LATIN CAPITAL LETTER T 90 | 0x0055, //LATIN CAPITAL LETTER U 91 | 0x0056, //LATIN CAPITAL LETTER V 92 | 0x0057, //LATIN CAPITAL LETTER W 93 | 0x0058, //LATIN CAPITAL LETTER X 94 | 0x0059, //LATIN CAPITAL LETTER Y 95 | 0x005A, //LATIN CAPITAL LETTER Z 96 | 0x005B, //LEFT SQUARE BRACKET 97 | 0x005C, //REVERSE SOLIDUS 98 | 0x005D, //RIGHT SQUARE BRACKET 99 | 0x005E, //CIRCUMFLEX ACCENT 100 | 0x005F, //LOW LINE 101 | 0x0060, //GRAVE ACCENT 102 | 0x0061, //LATIN SMALL LETTER A 103 | 0x0062, //LATIN SMALL LETTER B 104 | 0x0063, //LATIN SMALL LETTER C 105 | 0x0064, //LATIN SMALL LETTER D 106 | 0x0065, //LATIN SMALL LETTER E 107 | 0x0066, //LATIN SMALL LETTER F 108 | 0x0067, //LATIN SMALL LETTER G 109 | 0x0068, //LATIN SMALL LETTER H 110 | 0x0069, //LATIN SMALL LETTER I 111 | 0x006A, //LATIN SMALL LETTER J 112 | 0x006B, //LATIN SMALL LETTER K 113 | 0x006C, //LATIN SMALL LETTER L 114 | 0x006D, //LATIN SMALL LETTER M 115 | 0x006E, //LATIN SMALL LETTER N 116 | 0x006F, //LATIN SMALL LETTER O 117 | 0x0070, //LATIN SMALL LETTER P 118 | 0x0071, //LATIN SMALL LETTER Q 119 | 0x0072, //LATIN SMALL LETTER R 120 | 0x0073, //LATIN SMALL LETTER S 121 | 0x0074, //LATIN SMALL LETTER T 122 | 0x0075, //LATIN SMALL LETTER U 123 | 0x0076, //LATIN SMALL LETTER V 124 | 0x0077, //LATIN SMALL LETTER W 125 | 0x0078, //LATIN SMALL LETTER X 126 | 0x0079, //LATIN SMALL LETTER Y 127 | 0x007A, //LATIN SMALL LETTER Z 128 | 0x007B, //LEFT CURLY BRACKET 129 | 0x007C, //VERTICAL LINE 130 | 0x007D, //RIGHT CURLY BRACKET 131 | 0x007E, //TILDE 132 | 0x007F, //DELETE 133 | 0x20AC, //EURO SIGN 134 | 0xFFFD, //UNDEFINED 135 | 0x201A, //SINGLE LOW-9 QUOTATION MARK 136 | 0x0192, //LATIN SMALL LETTER F WITH HOOK 137 | 0x201E, //DOUBLE LOW-9 QUOTATION MARK 138 | 0x2026, //HORIZONTAL ELLIPSIS 139 | 0x2020, //DAGGER 140 | 0x2021, //DOUBLE DAGGER 141 | 0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT 142 | 0x2030, //PER MILLE SIGN 143 | 0xFFFD, //UNDEFINED 144 | 0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK 145 | 0x0152, //LATIN CAPITAL LIGATURE OE 146 | 0xFFFD, //UNDEFINED 147 | 0xFFFD, //UNDEFINED 148 | 0xFFFD, //UNDEFINED 149 | 0xFFFD, //UNDEFINED 150 | 0x2018, //LEFT SINGLE QUOTATION MARK 151 | 0x2019, //RIGHT SINGLE QUOTATION MARK 152 | 0x201C, //LEFT DOUBLE QUOTATION MARK 153 | 0x201D, //RIGHT DOUBLE QUOTATION MARK 154 | 0x2022, //BULLET 155 | 0x2013, //EN DASH 156 | 0x2014, //EM DASH 157 | 0x02DC, //SMALL TILDE 158 | 0x2122, //TRADE MARK SIGN 159 | 0xFFFD, //UNDEFINED 160 | 0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK 161 | 0x0153, //LATIN SMALL LIGATURE OE 162 | 0xFFFD, //UNDEFINED 163 | 0xFFFD, //UNDEFINED 164 | 0x0178, //LATIN CAPITAL LETTER Y WITH DIAERESIS 165 | 0x00A0, //NO-BREAK SPACE 166 | 0x00A1, //INVERTED EXCLAMATION MARK 167 | 0x00A2, //CENT SIGN 168 | 0x00A3, //POUND SIGN 169 | 0x00A4, //CURRENCY SIGN 170 | 0x00A5, //YEN SIGN 171 | 0x00A6, //BROKEN BAR 172 | 0x00A7, //SECTION SIGN 173 | 0x00A8, //DIAERESIS 174 | 0x00A9, //COPYRIGHT SIGN 175 | 0x00AA, //FEMININE ORDINAL INDICATOR 176 | 0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 177 | 0x00AC, //NOT SIGN 178 | 0x00AD, //SOFT HYPHEN 179 | 0x00AE, //REGISTERED SIGN 180 | 0x00AF, //MACRON 181 | 0x00B0, //DEGREE SIGN 182 | 0x00B1, //PLUS-MINUS SIGN 183 | 0x00B2, //SUPERSCRIPT TWO 184 | 0x00B3, //SUPERSCRIPT THREE 185 | 0x00B4, //ACUTE ACCENT 186 | 0x00B5, //MICRO SIGN 187 | 0x00B6, //PILCROW SIGN 188 | 0x00B7, //MIDDLE DOT 189 | 0x00B8, //CEDILLA 190 | 0x00B9, //SUPERSCRIPT ONE 191 | 0x00BA, //MASCULINE ORDINAL INDICATOR 192 | 0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 193 | 0x00BC, //VULGAR FRACTION ONE QUARTER 194 | 0x00BD, //VULGAR FRACTION ONE HALF 195 | 0x00BE, //VULGAR FRACTION THREE QUARTERS 196 | 0x00BF, //INVERTED QUESTION MARK 197 | 0x00C0, //LATIN CAPITAL LETTER A WITH GRAVE 198 | 0x00C1, //LATIN CAPITAL LETTER A WITH ACUTE 199 | 0x00C2, //LATIN CAPITAL LETTER A WITH CIRCUMFLEX 200 | 0x0102, //LATIN CAPITAL LETTER A WITH BREVE 201 | 0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS 202 | 0x00C5, //LATIN CAPITAL LETTER A WITH RING ABOVE 203 | 0x00C6, //LATIN CAPITAL LETTER AE 204 | 0x00C7, //LATIN CAPITAL LETTER C WITH CEDILLA 205 | 0x00C8, //LATIN CAPITAL LETTER E WITH GRAVE 206 | 0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE 207 | 0x00CA, //LATIN CAPITAL LETTER E WITH CIRCUMFLEX 208 | 0x00CB, //LATIN CAPITAL LETTER E WITH DIAERESIS 209 | 0x0300, //COMBINING GRAVE ACCENT 210 | 0x00CD, //LATIN CAPITAL LETTER I WITH ACUTE 211 | 0x00CE, //LATIN CAPITAL LETTER I WITH CIRCUMFLEX 212 | 0x00CF, //LATIN CAPITAL LETTER I WITH DIAERESIS 213 | 0x0110, //LATIN CAPITAL LETTER D WITH STROKE 214 | 0x00D1, //LATIN CAPITAL LETTER N WITH TILDE 215 | 0x0309, //COMBINING HOOK ABOVE 216 | 0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE 217 | 0x00D4, //LATIN CAPITAL LETTER O WITH CIRCUMFLEX 218 | 0x01A0, //LATIN CAPITAL LETTER O WITH HORN 219 | 0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS 220 | 0x00D7, //MULTIPLICATION SIGN 221 | 0x00D8, //LATIN CAPITAL LETTER O WITH STROKE 222 | 0x00D9, //LATIN CAPITAL LETTER U WITH GRAVE 223 | 0x00DA, //LATIN CAPITAL LETTER U WITH ACUTE 224 | 0x00DB, //LATIN CAPITAL LETTER U WITH CIRCUMFLEX 225 | 0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS 226 | 0x01AF, //LATIN CAPITAL LETTER U WITH HORN 227 | 0x0303, //COMBINING TILDE 228 | 0x00DF, //LATIN SMALL LETTER SHARP S 229 | 0x00E0, //LATIN SMALL LETTER A WITH GRAVE 230 | 0x00E1, //LATIN SMALL LETTER A WITH ACUTE 231 | 0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX 232 | 0x0103, //LATIN SMALL LETTER A WITH BREVE 233 | 0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS 234 | 0x00E5, //LATIN SMALL LETTER A WITH RING ABOVE 235 | 0x00E6, //LATIN SMALL LETTER AE 236 | 0x00E7, //LATIN SMALL LETTER C WITH CEDILLA 237 | 0x00E8, //LATIN SMALL LETTER E WITH GRAVE 238 | 0x00E9, //LATIN SMALL LETTER E WITH ACUTE 239 | 0x00EA, //LATIN SMALL LETTER E WITH CIRCUMFLEX 240 | 0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS 241 | 0x0301, //COMBINING ACUTE ACCENT 242 | 0x00ED, //LATIN SMALL LETTER I WITH ACUTE 243 | 0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX 244 | 0x00EF, //LATIN SMALL LETTER I WITH DIAERESIS 245 | 0x0111, //LATIN SMALL LETTER D WITH STROKE 246 | 0x00F1, //LATIN SMALL LETTER N WITH TILDE 247 | 0x0323, //COMBINING DOT BELOW 248 | 0x00F3, //LATIN SMALL LETTER O WITH ACUTE 249 | 0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX 250 | 0x01A1, //LATIN SMALL LETTER O WITH HORN 251 | 0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS 252 | 0x00F7, //DIVISION SIGN 253 | 0x00F8, //LATIN SMALL LETTER O WITH STROKE 254 | 0x00F9, //LATIN SMALL LETTER U WITH GRAVE 255 | 0x00FA, //LATIN SMALL LETTER U WITH ACUTE 256 | 0x00FB, //LATIN SMALL LETTER U WITH CIRCUMFLEX 257 | 0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS 258 | 0x01B0, //LATIN SMALL LETTER U WITH HORN 259 | 0x20AB, //DONG SIGN 260 | 0x00FF, //LATIN SMALL LETTER Y WITH DIAERESIS 261 | }, 262 | } 263 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/cp874.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | var cp874 *charsetMap = &charsetMap{ 4 | sb: [256]rune{ 5 | 0x0000, //NULL 6 | 0x0001, //START OF HEADING 7 | 0x0002, //START OF TEXT 8 | 0x0003, //END OF TEXT 9 | 0x0004, //END OF TRANSMISSION 10 | 0x0005, //ENQUIRY 11 | 0x0006, //ACKNOWLEDGE 12 | 0x0007, //BELL 13 | 0x0008, //BACKSPACE 14 | 0x0009, //HORIZONTAL TABULATION 15 | 0x000A, //LINE FEED 16 | 0x000B, //VERTICAL TABULATION 17 | 0x000C, //FORM FEED 18 | 0x000D, //CARRIAGE RETURN 19 | 0x000E, //SHIFT OUT 20 | 0x000F, //SHIFT IN 21 | 0x0010, //DATA LINK ESCAPE 22 | 0x0011, //DEVICE CONTROL ONE 23 | 0x0012, //DEVICE CONTROL TWO 24 | 0x0013, //DEVICE CONTROL THREE 25 | 0x0014, //DEVICE CONTROL FOUR 26 | 0x0015, //NEGATIVE ACKNOWLEDGE 27 | 0x0016, //SYNCHRONOUS IDLE 28 | 0x0017, //END OF TRANSMISSION BLOCK 29 | 0x0018, //CANCEL 30 | 0x0019, //END OF MEDIUM 31 | 0x001A, //SUBSTITUTE 32 | 0x001B, //ESCAPE 33 | 0x001C, //FILE SEPARATOR 34 | 0x001D, //GROUP SEPARATOR 35 | 0x001E, //RECORD SEPARATOR 36 | 0x001F, //UNIT SEPARATOR 37 | 0x0020, //SPACE 38 | 0x0021, //EXCLAMATION MARK 39 | 0x0022, //QUOTATION MARK 40 | 0x0023, //NUMBER SIGN 41 | 0x0024, //DOLLAR SIGN 42 | 0x0025, //PERCENT SIGN 43 | 0x0026, //AMPERSAND 44 | 0x0027, //APOSTROPHE 45 | 0x0028, //LEFT PARENTHESIS 46 | 0x0029, //RIGHT PARENTHESIS 47 | 0x002A, //ASTERISK 48 | 0x002B, //PLUS SIGN 49 | 0x002C, //COMMA 50 | 0x002D, //HYPHEN-MINUS 51 | 0x002E, //FULL STOP 52 | 0x002F, //SOLIDUS 53 | 0x0030, //DIGIT ZERO 54 | 0x0031, //DIGIT ONE 55 | 0x0032, //DIGIT TWO 56 | 0x0033, //DIGIT THREE 57 | 0x0034, //DIGIT FOUR 58 | 0x0035, //DIGIT FIVE 59 | 0x0036, //DIGIT SIX 60 | 0x0037, //DIGIT SEVEN 61 | 0x0038, //DIGIT EIGHT 62 | 0x0039, //DIGIT NINE 63 | 0x003A, //COLON 64 | 0x003B, //SEMICOLON 65 | 0x003C, //LESS-THAN SIGN 66 | 0x003D, //EQUALS SIGN 67 | 0x003E, //GREATER-THAN SIGN 68 | 0x003F, //QUESTION MARK 69 | 0x0040, //COMMERCIAL AT 70 | 0x0041, //LATIN CAPITAL LETTER A 71 | 0x0042, //LATIN CAPITAL LETTER B 72 | 0x0043, //LATIN CAPITAL LETTER C 73 | 0x0044, //LATIN CAPITAL LETTER D 74 | 0x0045, //LATIN CAPITAL LETTER E 75 | 0x0046, //LATIN CAPITAL LETTER F 76 | 0x0047, //LATIN CAPITAL LETTER G 77 | 0x0048, //LATIN CAPITAL LETTER H 78 | 0x0049, //LATIN CAPITAL LETTER I 79 | 0x004A, //LATIN CAPITAL LETTER J 80 | 0x004B, //LATIN CAPITAL LETTER K 81 | 0x004C, //LATIN CAPITAL LETTER L 82 | 0x004D, //LATIN CAPITAL LETTER M 83 | 0x004E, //LATIN CAPITAL LETTER N 84 | 0x004F, //LATIN CAPITAL LETTER O 85 | 0x0050, //LATIN CAPITAL LETTER P 86 | 0x0051, //LATIN CAPITAL LETTER Q 87 | 0x0052, //LATIN CAPITAL LETTER R 88 | 0x0053, //LATIN CAPITAL LETTER S 89 | 0x0054, //LATIN CAPITAL LETTER T 90 | 0x0055, //LATIN CAPITAL LETTER U 91 | 0x0056, //LATIN CAPITAL LETTER V 92 | 0x0057, //LATIN CAPITAL LETTER W 93 | 0x0058, //LATIN CAPITAL LETTER X 94 | 0x0059, //LATIN CAPITAL LETTER Y 95 | 0x005A, //LATIN CAPITAL LETTER Z 96 | 0x005B, //LEFT SQUARE BRACKET 97 | 0x005C, //REVERSE SOLIDUS 98 | 0x005D, //RIGHT SQUARE BRACKET 99 | 0x005E, //CIRCUMFLEX ACCENT 100 | 0x005F, //LOW LINE 101 | 0x0060, //GRAVE ACCENT 102 | 0x0061, //LATIN SMALL LETTER A 103 | 0x0062, //LATIN SMALL LETTER B 104 | 0x0063, //LATIN SMALL LETTER C 105 | 0x0064, //LATIN SMALL LETTER D 106 | 0x0065, //LATIN SMALL LETTER E 107 | 0x0066, //LATIN SMALL LETTER F 108 | 0x0067, //LATIN SMALL LETTER G 109 | 0x0068, //LATIN SMALL LETTER H 110 | 0x0069, //LATIN SMALL LETTER I 111 | 0x006A, //LATIN SMALL LETTER J 112 | 0x006B, //LATIN SMALL LETTER K 113 | 0x006C, //LATIN SMALL LETTER L 114 | 0x006D, //LATIN SMALL LETTER M 115 | 0x006E, //LATIN SMALL LETTER N 116 | 0x006F, //LATIN SMALL LETTER O 117 | 0x0070, //LATIN SMALL LETTER P 118 | 0x0071, //LATIN SMALL LETTER Q 119 | 0x0072, //LATIN SMALL LETTER R 120 | 0x0073, //LATIN SMALL LETTER S 121 | 0x0074, //LATIN SMALL LETTER T 122 | 0x0075, //LATIN SMALL LETTER U 123 | 0x0076, //LATIN SMALL LETTER V 124 | 0x0077, //LATIN SMALL LETTER W 125 | 0x0078, //LATIN SMALL LETTER X 126 | 0x0079, //LATIN SMALL LETTER Y 127 | 0x007A, //LATIN SMALL LETTER Z 128 | 0x007B, //LEFT CURLY BRACKET 129 | 0x007C, //VERTICAL LINE 130 | 0x007D, //RIGHT CURLY BRACKET 131 | 0x007E, //TILDE 132 | 0x007F, //DELETE 133 | 0x20AC, //EURO SIGN 134 | 0xFFFD, //UNDEFINED 135 | 0xFFFD, //UNDEFINED 136 | 0xFFFD, //UNDEFINED 137 | 0xFFFD, //UNDEFINED 138 | 0x2026, //HORIZONTAL ELLIPSIS 139 | 0xFFFD, //UNDEFINED 140 | 0xFFFD, //UNDEFINED 141 | 0xFFFD, //UNDEFINED 142 | 0xFFFD, //UNDEFINED 143 | 0xFFFD, //UNDEFINED 144 | 0xFFFD, //UNDEFINED 145 | 0xFFFD, //UNDEFINED 146 | 0xFFFD, //UNDEFINED 147 | 0xFFFD, //UNDEFINED 148 | 0xFFFD, //UNDEFINED 149 | 0xFFFD, //UNDEFINED 150 | 0x2018, //LEFT SINGLE QUOTATION MARK 151 | 0x2019, //RIGHT SINGLE QUOTATION MARK 152 | 0x201C, //LEFT DOUBLE QUOTATION MARK 153 | 0x201D, //RIGHT DOUBLE QUOTATION MARK 154 | 0x2022, //BULLET 155 | 0x2013, //EN DASH 156 | 0x2014, //EM DASH 157 | 0xFFFD, //UNDEFINED 158 | 0xFFFD, //UNDEFINED 159 | 0xFFFD, //UNDEFINED 160 | 0xFFFD, //UNDEFINED 161 | 0xFFFD, //UNDEFINED 162 | 0xFFFD, //UNDEFINED 163 | 0xFFFD, //UNDEFINED 164 | 0xFFFD, //UNDEFINED 165 | 0x00A0, //NO-BREAK SPACE 166 | 0x0E01, //THAI CHARACTER KO KAI 167 | 0x0E02, //THAI CHARACTER KHO KHAI 168 | 0x0E03, //THAI CHARACTER KHO KHUAT 169 | 0x0E04, //THAI CHARACTER KHO KHWAI 170 | 0x0E05, //THAI CHARACTER KHO KHON 171 | 0x0E06, //THAI CHARACTER KHO RAKHANG 172 | 0x0E07, //THAI CHARACTER NGO NGU 173 | 0x0E08, //THAI CHARACTER CHO CHAN 174 | 0x0E09, //THAI CHARACTER CHO CHING 175 | 0x0E0A, //THAI CHARACTER CHO CHANG 176 | 0x0E0B, //THAI CHARACTER SO SO 177 | 0x0E0C, //THAI CHARACTER CHO CHOE 178 | 0x0E0D, //THAI CHARACTER YO YING 179 | 0x0E0E, //THAI CHARACTER DO CHADA 180 | 0x0E0F, //THAI CHARACTER TO PATAK 181 | 0x0E10, //THAI CHARACTER THO THAN 182 | 0x0E11, //THAI CHARACTER THO NANGMONTHO 183 | 0x0E12, //THAI CHARACTER THO PHUTHAO 184 | 0x0E13, //THAI CHARACTER NO NEN 185 | 0x0E14, //THAI CHARACTER DO DEK 186 | 0x0E15, //THAI CHARACTER TO TAO 187 | 0x0E16, //THAI CHARACTER THO THUNG 188 | 0x0E17, //THAI CHARACTER THO THAHAN 189 | 0x0E18, //THAI CHARACTER THO THONG 190 | 0x0E19, //THAI CHARACTER NO NU 191 | 0x0E1A, //THAI CHARACTER BO BAIMAI 192 | 0x0E1B, //THAI CHARACTER PO PLA 193 | 0x0E1C, //THAI CHARACTER PHO PHUNG 194 | 0x0E1D, //THAI CHARACTER FO FA 195 | 0x0E1E, //THAI CHARACTER PHO PHAN 196 | 0x0E1F, //THAI CHARACTER FO FAN 197 | 0x0E20, //THAI CHARACTER PHO SAMPHAO 198 | 0x0E21, //THAI CHARACTER MO MA 199 | 0x0E22, //THAI CHARACTER YO YAK 200 | 0x0E23, //THAI CHARACTER RO RUA 201 | 0x0E24, //THAI CHARACTER RU 202 | 0x0E25, //THAI CHARACTER LO LING 203 | 0x0E26, //THAI CHARACTER LU 204 | 0x0E27, //THAI CHARACTER WO WAEN 205 | 0x0E28, //THAI CHARACTER SO SALA 206 | 0x0E29, //THAI CHARACTER SO RUSI 207 | 0x0E2A, //THAI CHARACTER SO SUA 208 | 0x0E2B, //THAI CHARACTER HO HIP 209 | 0x0E2C, //THAI CHARACTER LO CHULA 210 | 0x0E2D, //THAI CHARACTER O ANG 211 | 0x0E2E, //THAI CHARACTER HO NOKHUK 212 | 0x0E2F, //THAI CHARACTER PAIYANNOI 213 | 0x0E30, //THAI CHARACTER SARA A 214 | 0x0E31, //THAI CHARACTER MAI HAN-AKAT 215 | 0x0E32, //THAI CHARACTER SARA AA 216 | 0x0E33, //THAI CHARACTER SARA AM 217 | 0x0E34, //THAI CHARACTER SARA I 218 | 0x0E35, //THAI CHARACTER SARA II 219 | 0x0E36, //THAI CHARACTER SARA UE 220 | 0x0E37, //THAI CHARACTER SARA UEE 221 | 0x0E38, //THAI CHARACTER SARA U 222 | 0x0E39, //THAI CHARACTER SARA UU 223 | 0x0E3A, //THAI CHARACTER PHINTHU 224 | 0xFFFD, //UNDEFINED 225 | 0xFFFD, //UNDEFINED 226 | 0xFFFD, //UNDEFINED 227 | 0xFFFD, //UNDEFINED 228 | 0x0E3F, //THAI CURRENCY SYMBOL BAHT 229 | 0x0E40, //THAI CHARACTER SARA E 230 | 0x0E41, //THAI CHARACTER SARA AE 231 | 0x0E42, //THAI CHARACTER SARA O 232 | 0x0E43, //THAI CHARACTER SARA AI MAIMUAN 233 | 0x0E44, //THAI CHARACTER SARA AI MAIMALAI 234 | 0x0E45, //THAI CHARACTER LAKKHANGYAO 235 | 0x0E46, //THAI CHARACTER MAIYAMOK 236 | 0x0E47, //THAI CHARACTER MAITAIKHU 237 | 0x0E48, //THAI CHARACTER MAI EK 238 | 0x0E49, //THAI CHARACTER MAI THO 239 | 0x0E4A, //THAI CHARACTER MAI TRI 240 | 0x0E4B, //THAI CHARACTER MAI CHATTAWA 241 | 0x0E4C, //THAI CHARACTER THANTHAKHAT 242 | 0x0E4D, //THAI CHARACTER NIKHAHIT 243 | 0x0E4E, //THAI CHARACTER YAMAKKAN 244 | 0x0E4F, //THAI CHARACTER FONGMAN 245 | 0x0E50, //THAI DIGIT ZERO 246 | 0x0E51, //THAI DIGIT ONE 247 | 0x0E52, //THAI DIGIT TWO 248 | 0x0E53, //THAI DIGIT THREE 249 | 0x0E54, //THAI DIGIT FOUR 250 | 0x0E55, //THAI DIGIT FIVE 251 | 0x0E56, //THAI DIGIT SIX 252 | 0x0E57, //THAI DIGIT SEVEN 253 | 0x0E58, //THAI DIGIT EIGHT 254 | 0x0E59, //THAI DIGIT NINE 255 | 0x0E5A, //THAI CHARACTER ANGKHANKHU 256 | 0x0E5B, //THAI CHARACTER KHOMUT 257 | 0xFFFD, //UNDEFINED 258 | 0xFFFD, //UNDEFINED 259 | 0xFFFD, //UNDEFINED 260 | 0xFFFD, //UNDEFINED 261 | }, 262 | } 263 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/decimal.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "encoding/binary" 5 | "errors" 6 | "math" 7 | "math/big" 8 | ) 9 | 10 | // http://msdn.microsoft.com/en-us/library/ee780893.aspx 11 | type Decimal struct { 12 | integer [4]uint32 13 | positive bool 14 | prec uint8 15 | scale uint8 16 | } 17 | 18 | var scaletblflt64 [39]float64 19 | 20 | func (d Decimal) ToFloat64() float64 { 21 | val := float64(0) 22 | for i := 3; i >= 0; i-- { 23 | val *= 0x100000000 24 | val += float64(d.integer[i]) 25 | } 26 | if !d.positive { 27 | val = -val 28 | } 29 | if d.scale != 0 { 30 | val /= scaletblflt64[d.scale] 31 | } 32 | return val 33 | } 34 | 35 | func Float64ToDecimal(f float64) (Decimal, error) { 36 | var dec Decimal 37 | if math.IsNaN(f) { 38 | return dec, errors.New("NaN") 39 | } 40 | if math.IsInf(f, 0) { 41 | return dec, errors.New("Infinity can't be converted to decimal") 42 | } 43 | dec.positive = f >= 0 44 | if !dec.positive { 45 | f = math.Abs(f) 46 | } 47 | if f > 3.402823669209385e+38 { 48 | return dec, errors.New("Float value is out of range") 49 | } 50 | dec.prec = 20 51 | var integer float64 52 | for dec.scale = 0; dec.scale <= 20; dec.scale++ { 53 | integer = f * scaletblflt64[dec.scale] 54 | _, frac := math.Modf(integer) 55 | if frac == 0 { 56 | break 57 | } 58 | } 59 | for i := 0; i < 4; i++ { 60 | mod := math.Mod(integer, 0x100000000) 61 | integer -= mod 62 | integer /= 0x100000000 63 | dec.integer[i] = uint32(mod) 64 | } 65 | return dec, nil 66 | } 67 | 68 | func init() { 69 | var acc float64 = 1 70 | for i := 0; i <= 38; i++ { 71 | scaletblflt64[i] = acc 72 | acc *= 10 73 | } 74 | } 75 | 76 | func (d Decimal) Bytes() []byte { 77 | bytes := make([]byte, 16) 78 | binary.BigEndian.PutUint32(bytes[0:4], d.integer[3]) 79 | binary.BigEndian.PutUint32(bytes[4:8], d.integer[2]) 80 | binary.BigEndian.PutUint32(bytes[8:12], d.integer[1]) 81 | binary.BigEndian.PutUint32(bytes[12:16], d.integer[0]) 82 | var x big.Int 83 | x.SetBytes(bytes) 84 | if !d.positive { 85 | x.Neg(&x) 86 | } 87 | return scaleBytes(x.String(), d.scale) 88 | } 89 | 90 | func scaleBytes(s string, scale uint8) []byte { 91 | z := make([]byte, 0, len(s)+1) 92 | if s[0] == '-' || s[0] == '+' { 93 | z = append(z, byte(s[0])) 94 | s = s[1:] 95 | } 96 | pos := len(s) - int(scale) 97 | if pos <= 0 { 98 | z = append(z, byte('0')) 99 | } else if pos > 0 { 100 | z = append(z, []byte(s[:pos])...) 101 | } 102 | if scale > 0 { 103 | z = append(z, byte('.')) 104 | for pos < 0 { 105 | z = append(z, byte('0')) 106 | pos++ 107 | } 108 | z = append(z, []byte(s[pos:])...) 109 | } 110 | return z 111 | } 112 | 113 | func (d Decimal) String() string { 114 | return string(d.Bytes()) 115 | } 116 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/error.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Error struct { 8 | Number int32 9 | State uint8 10 | Class uint8 11 | Message string 12 | ServerName string 13 | ProcName string 14 | LineNo int32 15 | } 16 | 17 | func (e Error) Error() string { 18 | return "mssql: " + e.Message 19 | } 20 | 21 | type StreamError struct { 22 | Message string 23 | } 24 | 25 | func (e StreamError) Error() string { 26 | return e.Message 27 | } 28 | 29 | func streamErrorf(format string, v ...interface{}) StreamError { 30 | return StreamError{"Invalid TDS stream: " + fmt.Sprintf(format, v...)} 31 | } 32 | 33 | func badStreamPanic(err error) { 34 | panic(err) 35 | } 36 | 37 | func badStreamPanicf(format string, v ...interface{}) { 38 | panic(streamErrorf(format, v...)) 39 | } 40 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/examples/simple.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import _ "github.com/denisenkom/go-mssqldb" 4 | import "database/sql" 5 | import "log" 6 | import "fmt" 7 | import "flag" 8 | 9 | var debug = flag.Bool("debug", false, "enable debugging") 10 | var password = flag.String("password", "", "the database password") 11 | var port *int = flag.Int("port", 1433, "the database port") 12 | var server = flag.String("server", "", "the database server") 13 | var user = flag.String("user", "", "the database user") 14 | 15 | func main() { 16 | flag.Parse() // parse the command line args 17 | 18 | if *debug { 19 | fmt.Printf(" password:%s\n", *password) 20 | fmt.Printf(" port:%d\n", *port) 21 | fmt.Printf(" server:%s\n", *server) 22 | fmt.Printf(" user:%s\n", *user) 23 | } 24 | 25 | connString := fmt.Sprintf("server=%s;user id=%s;password=%s;port=%d", *server, *user, *password, *port) 26 | if *debug { 27 | fmt.Printf(" connString:%s\n", connString) 28 | } 29 | conn, err := sql.Open("mssql", connString) 30 | if err != nil { 31 | log.Fatal("Open connection failed:", err.Error()) 32 | } 33 | defer conn.Close() 34 | 35 | stmt, err := conn.Prepare("select 1, 'abc'") 36 | if err != nil { 37 | log.Fatal("Prepare failed:", err.Error()) 38 | } 39 | defer stmt.Close() 40 | 41 | row := stmt.QueryRow() 42 | var somenumber int64 43 | var somechars string 44 | err = row.Scan(&somenumber, &somechars) 45 | if err != nil { 46 | log.Fatal("Scan failed:", err.Error()) 47 | } 48 | fmt.Printf("somenumber:%d\n", somenumber) 49 | fmt.Printf("somechars:%s\n", somechars) 50 | 51 | fmt.Printf("bye\n") 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/examples/tsql.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "database/sql" 6 | "flag" 7 | "fmt" 8 | "io" 9 | "os" 10 | "time" 11 | 12 | _ "github.com/denisenkom/go-mssqldb" 13 | ) 14 | 15 | func main() { 16 | var ( 17 | userid = flag.String("U", "", "login_id") 18 | password = flag.String("P", "", "password") 19 | server = flag.String("S", "localhost", "server_name[\\instance_name]") 20 | database = flag.String("d", "", "db_name") 21 | ) 22 | flag.Parse() 23 | 24 | dsn := "server=" + *server + ";user id=" + *userid + ";password=" + *password + ";database=" + *database 25 | db, err := sql.Open("mssql", dsn) 26 | if err != nil { 27 | fmt.Println("Cannot connect: ", err.Error()) 28 | return 29 | } 30 | err = db.Ping() 31 | if err != nil { 32 | fmt.Println("Cannot connect: ", err.Error()) 33 | return 34 | } 35 | defer db.Close() 36 | r := bufio.NewReader(os.Stdin) 37 | for { 38 | _, err = os.Stdout.Write([]byte("> ")) 39 | if err != nil { 40 | fmt.Println(err) 41 | return 42 | } 43 | cmd, err := r.ReadString('\n') 44 | if err != nil { 45 | if err == io.EOF { 46 | fmt.Println() 47 | return 48 | } 49 | fmt.Println(err) 50 | return 51 | } 52 | err = exec(db, cmd) 53 | if err != nil { 54 | fmt.Println(err) 55 | } 56 | } 57 | } 58 | 59 | func exec(db *sql.DB, cmd string) error { 60 | rows, err := db.Query(cmd) 61 | if err != nil { 62 | return err 63 | } 64 | defer rows.Close() 65 | cols, err := rows.Columns() 66 | if err != nil { 67 | return err 68 | } 69 | if cols == nil { 70 | return nil 71 | } 72 | vals := make([]interface{}, len(cols)) 73 | for i := 0; i < len(cols); i++ { 74 | vals[i] = new(interface{}) 75 | if i != 0 { 76 | fmt.Print("\t") 77 | } 78 | fmt.Print(cols[i]) 79 | } 80 | fmt.Println() 81 | for rows.Next() { 82 | err = rows.Scan(vals...) 83 | if err != nil { 84 | fmt.Println(err) 85 | continue 86 | } 87 | for i := 0; i < len(vals); i++ { 88 | if i != 0 { 89 | fmt.Print("\t") 90 | } 91 | printValue(vals[i].(*interface{})) 92 | } 93 | fmt.Println() 94 | 95 | } 96 | if rows.Err() != nil { 97 | return rows.Err() 98 | } 99 | return nil 100 | } 101 | 102 | func printValue(pval *interface{}) { 103 | switch v := (*pval).(type) { 104 | case nil: 105 | fmt.Print("NULL") 106 | case bool: 107 | if v { 108 | fmt.Print("1") 109 | } else { 110 | fmt.Print("0") 111 | } 112 | case []byte: 113 | fmt.Print(string(v)) 114 | case time.Time: 115 | fmt.Print(v.Format("2006-01-02 15:04:05.999")) 116 | default: 117 | fmt.Print(v) 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/log.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "log" 5 | ) 6 | 7 | type Logger log.Logger 8 | 9 | func (logger *Logger) Printf(format string, v ...interface{}) { 10 | if logger != nil { 11 | (*log.Logger)(logger).Printf(format, v...) 12 | } else { 13 | log.Printf(format, v...) 14 | } 15 | } 16 | 17 | func (logger *Logger) Println(v ...interface{}) { 18 | if logger != nil { 19 | (*log.Logger)(logger).Println(v...) 20 | } else { 21 | log.Println(v...) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/mssql_go1.3.go: -------------------------------------------------------------------------------- 1 | // +build go1.3 2 | 3 | package mssql 4 | 5 | import ( 6 | "net" 7 | ) 8 | 9 | func createDialer(p *connectParams) *net.Dialer { 10 | return &net.Dialer{Timeout: p.dial_timeout, KeepAlive: p.keepAlive} 11 | } 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/mssql_go1.3pre.go: -------------------------------------------------------------------------------- 1 | // +build !go1.3 2 | 3 | package mssql 4 | 5 | import ( 6 | "net" 7 | ) 8 | 9 | func createDialer(p *connectParams) *net.Dialer { 10 | return &net.Dialer{Timeout: p.dial_timeout} 11 | } 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/net.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "time" 7 | ) 8 | 9 | type timeoutConn struct { 10 | c net.Conn 11 | timeout time.Duration 12 | buf *tdsBuffer 13 | packetPending bool 14 | continueRead bool 15 | } 16 | 17 | func NewTimeoutConn(conn net.Conn, timeout time.Duration) *timeoutConn { 18 | return &timeoutConn{ 19 | c: conn, 20 | timeout: timeout, 21 | } 22 | } 23 | 24 | func (c *timeoutConn) Read(b []byte) (n int, err error) { 25 | if c.buf != nil { 26 | if c.packetPending { 27 | c.packetPending = false 28 | err = c.buf.FinishPacket() 29 | if err != nil { 30 | err = fmt.Errorf("Cannot send handshake packet: %s", err.Error()) 31 | return 32 | } 33 | c.continueRead = false 34 | } 35 | if !c.continueRead { 36 | var packet uint8 37 | packet, err = c.buf.BeginRead() 38 | if err != nil { 39 | err = fmt.Errorf("Cannot read handshake packet: %s", err.Error()) 40 | return 41 | } 42 | if packet != packPrelogin { 43 | err = fmt.Errorf("unexpected packet %d, expecting prelogin", packet) 44 | return 45 | } 46 | c.continueRead = true 47 | } 48 | n, err = c.buf.Read(b) 49 | return 50 | } 51 | err = c.c.SetDeadline(time.Now().Add(c.timeout)) 52 | if err != nil { 53 | return 54 | } 55 | return c.c.Read(b) 56 | } 57 | 58 | func (c *timeoutConn) Write(b []byte) (n int, err error) { 59 | if c.buf != nil { 60 | if !c.packetPending { 61 | c.buf.BeginPacket(packPrelogin) 62 | c.packetPending = true 63 | } 64 | n, err = c.buf.Write(b) 65 | if err != nil { 66 | return 67 | } 68 | return 69 | } 70 | err = c.c.SetDeadline(time.Now().Add(c.timeout)) 71 | if err != nil { 72 | return 73 | } 74 | return c.c.Write(b) 75 | } 76 | 77 | func (c timeoutConn) Close() error { 78 | return c.c.Close() 79 | } 80 | 81 | func (c timeoutConn) LocalAddr() net.Addr { 82 | return c.c.LocalAddr() 83 | } 84 | 85 | func (c timeoutConn) RemoteAddr() net.Addr { 86 | return c.c.RemoteAddr() 87 | } 88 | 89 | func (c timeoutConn) SetDeadline(t time.Time) error { 90 | panic("Not implemented") 91 | } 92 | 93 | func (c timeoutConn) SetReadDeadline(t time.Time) error { 94 | panic("Not implemented") 95 | } 96 | 97 | func (c timeoutConn) SetWriteDeadline(t time.Time) error { 98 | panic("Not implemented") 99 | } 100 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/parser.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "strconv" 7 | ) 8 | 9 | type parser struct { 10 | r *bytes.Reader 11 | w bytes.Buffer 12 | paramCount int 13 | paramMax int 14 | } 15 | 16 | func (p *parser) next() (rune, bool) { 17 | ch, _, err := p.r.ReadRune() 18 | if err != nil { 19 | if err != io.EOF { 20 | panic(err) 21 | } 22 | return 0, false 23 | } 24 | return ch, true 25 | } 26 | 27 | func (p *parser) unread() { 28 | err := p.r.UnreadRune() 29 | if err != nil { 30 | panic(err) 31 | } 32 | } 33 | 34 | func (p *parser) write(ch rune) { 35 | p.w.WriteRune(ch) 36 | } 37 | 38 | type stateFunc func(*parser) stateFunc 39 | 40 | func parseParams(query string) (string, int) { 41 | p := &parser{ 42 | r: bytes.NewReader([]byte(query)), 43 | } 44 | state := parseNormal 45 | for state != nil { 46 | state = state(p) 47 | } 48 | return p.w.String(), p.paramMax 49 | } 50 | 51 | func parseNormal(p *parser) stateFunc { 52 | for { 53 | ch, ok := p.next() 54 | if !ok { 55 | return nil 56 | } 57 | if ch == '?' { 58 | return parseParameter 59 | } else if ch == '$' || ch == ':' { 60 | ch2, ok := p.next() 61 | if !ok { 62 | p.write(ch) 63 | return nil 64 | } 65 | p.unread() 66 | if ch2 >= '0' && ch2 <= '9' { 67 | return parseParameter 68 | } 69 | } 70 | p.write(ch) 71 | switch ch { 72 | case '\'': 73 | return parseQuote 74 | case '"': 75 | return parseDoubleQuote 76 | case '[': 77 | return parseBracket 78 | case '-': 79 | return parseLineComment 80 | case '/': 81 | return parseComment 82 | } 83 | } 84 | } 85 | 86 | func parseParameter(p *parser) stateFunc { 87 | var paramN int 88 | var ok bool 89 | for { 90 | var ch rune 91 | ch, ok = p.next() 92 | if ok && ch >= '0' && ch <= '9' { 93 | paramN = paramN*10 + int(ch-'0') 94 | } else { 95 | break 96 | } 97 | } 98 | if ok { 99 | p.unread() 100 | } 101 | if paramN == 0 { 102 | p.paramCount++ 103 | paramN = p.paramCount 104 | } 105 | if paramN > p.paramMax { 106 | p.paramMax = paramN 107 | } 108 | p.w.WriteString("@p") 109 | p.w.WriteString(strconv.Itoa(paramN)) 110 | if !ok { 111 | return nil 112 | } 113 | return parseNormal 114 | } 115 | 116 | func parseQuote(p *parser) stateFunc { 117 | for { 118 | ch, ok := p.next() 119 | if !ok { 120 | return nil 121 | } 122 | p.write(ch) 123 | if ch == '\'' { 124 | return parseNormal 125 | } 126 | } 127 | } 128 | 129 | func parseDoubleQuote(p *parser) stateFunc { 130 | for { 131 | ch, ok := p.next() 132 | if !ok { 133 | return nil 134 | } 135 | p.write(ch) 136 | if ch == '"' { 137 | return parseNormal 138 | } 139 | } 140 | } 141 | 142 | func parseBracket(p *parser) stateFunc { 143 | for { 144 | ch, ok := p.next() 145 | if !ok { 146 | return nil 147 | } 148 | p.write(ch) 149 | if ch == ']' { 150 | ch, ok = p.next() 151 | if !ok { 152 | return nil 153 | } 154 | if ch != ']' { 155 | p.unread() 156 | return parseNormal 157 | } 158 | p.write(ch) 159 | } 160 | } 161 | } 162 | 163 | func parseLineComment(p *parser) stateFunc { 164 | ch, ok := p.next() 165 | if !ok { 166 | return nil 167 | } 168 | if ch != '-' { 169 | p.unread() 170 | return parseNormal 171 | } 172 | p.write(ch) 173 | for { 174 | ch, ok = p.next() 175 | if !ok { 176 | return nil 177 | } 178 | p.write(ch) 179 | if ch == '\n' { 180 | return parseNormal 181 | } 182 | } 183 | } 184 | 185 | func parseComment(p *parser) stateFunc { 186 | var nested int 187 | ch, ok := p.next() 188 | if !ok { 189 | return nil 190 | } 191 | if ch != '*' { 192 | p.unread() 193 | return parseNormal 194 | } 195 | p.write(ch) 196 | for { 197 | ch, ok = p.next() 198 | if !ok { 199 | return nil 200 | } 201 | p.write(ch) 202 | for ch == '*' { 203 | ch, ok = p.next() 204 | if !ok { 205 | return nil 206 | } 207 | p.write(ch) 208 | if ch == '/' { 209 | if nested == 0 { 210 | return parseNormal 211 | } else { 212 | nested-- 213 | } 214 | } 215 | } 216 | for ch == '/' { 217 | ch, ok = p.next() 218 | if !ok { 219 | return nil 220 | } 221 | p.write(ch) 222 | if ch == '*' { 223 | nested++ 224 | } 225 | } 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/rpc.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "encoding/binary" 5 | ) 6 | 7 | type ProcId struct { 8 | id uint16 9 | name string 10 | } 11 | 12 | // parameter flags 13 | const ( 14 | fByRevValue = 1 15 | fDefaultValue = 2 16 | ) 17 | 18 | type Param struct { 19 | Name string 20 | Flags uint8 21 | ti typeInfo 22 | buffer []byte 23 | } 24 | 25 | func MakeProcId(name string) (res ProcId) { 26 | res.name = name 27 | if len(name) == 0 { 28 | panic("Proc name shouln't be empty") 29 | } 30 | if len(name) >= 0xffff { 31 | panic("Invalid length of procedure name, should be less than 0xffff") 32 | } 33 | return res 34 | } 35 | 36 | const ( 37 | fWithRecomp = 1 38 | fNoMetaData = 2 39 | fReuseMetaData = 4 40 | ) 41 | 42 | var ( 43 | Sp_Cursor = ProcId{1, ""} 44 | Sp_CursorOpen = ProcId{2, ""} 45 | Sp_CursorPrepare = ProcId{3, ""} 46 | Sp_CursorExecute = ProcId{4, ""} 47 | Sp_CursorPrepExec = ProcId{5, ""} 48 | Sp_CursorUnprepare = ProcId{6, ""} 49 | Sp_CursorFetch = ProcId{7, ""} 50 | Sp_CursorOption = ProcId{8, ""} 51 | Sp_CursorClose = ProcId{9, ""} 52 | Sp_ExecuteSql = ProcId{10, ""} 53 | Sp_Prepare = ProcId{11, ""} 54 | Sp_PrepExec = ProcId{13, ""} 55 | Sp_PrepExecRpc = ProcId{14, ""} 56 | Sp_Unprepare = ProcId{15, ""} 57 | ) 58 | 59 | // http://msdn.microsoft.com/en-us/library/dd357576.aspx 60 | func sendRpc(buf *tdsBuffer, headers []headerStruct, proc ProcId, flags uint16, params []Param) (err error) { 61 | buf.BeginPacket(packRPCRequest) 62 | writeAllHeaders(buf, headers) 63 | if len(proc.name) == 0 { 64 | var idswitch uint16 = 0xffff 65 | err = binary.Write(buf, binary.LittleEndian, &idswitch) 66 | if err != nil { 67 | return 68 | } 69 | err = binary.Write(buf, binary.LittleEndian, &proc.id) 70 | if err != nil { 71 | return 72 | } 73 | } else { 74 | err = writeUsVarChar(buf, proc.name) 75 | if err != nil { 76 | return 77 | } 78 | } 79 | err = binary.Write(buf, binary.LittleEndian, &flags) 80 | if err != nil { 81 | return 82 | } 83 | for _, param := range params { 84 | if err = writeBVarChar(buf, param.Name); err != nil { 85 | return 86 | } 87 | if err = binary.Write(buf, binary.LittleEndian, param.Flags); err != nil { 88 | return 89 | } 90 | err = writeTypeInfo(buf, ¶m.ti) 91 | if err != nil { 92 | return 93 | } 94 | err = param.ti.Writer(buf, param.ti, param.buffer) 95 | if err != nil { 96 | return 97 | } 98 | } 99 | return buf.FinishPacket() 100 | } 101 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/sspi_windows.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | var ( 11 | secur32_dll = syscall.NewLazyDLL("secur32.dll") 12 | initSecurityInterface = secur32_dll.NewProc("InitSecurityInterfaceW") 13 | sec_fn *SecurityFunctionTable 14 | ) 15 | 16 | func init() { 17 | ptr, _, _ := initSecurityInterface.Call() 18 | sec_fn = (*SecurityFunctionTable)(unsafe.Pointer(ptr)) 19 | } 20 | 21 | const ( 22 | SEC_E_OK = 0 23 | SECPKG_CRED_OUTBOUND = 2 24 | SEC_WINNT_AUTH_IDENTITY_UNICODE = 2 25 | ISC_REQ_DELEGATE = 0x00000001 26 | ISC_REQ_REPLAY_DETECT = 0x00000004 27 | ISC_REQ_SEQUENCE_DETECT = 0x00000008 28 | ISC_REQ_CONFIDENTIALITY = 0x00000010 29 | ISC_REQ_CONNECTION = 0x00000800 30 | SECURITY_NETWORK_DREP = 0 31 | SEC_I_CONTINUE_NEEDED = 0x00090312 32 | SEC_I_COMPLETE_NEEDED = 0x00090313 33 | SEC_I_COMPLETE_AND_CONTINUE = 0x00090314 34 | SECBUFFER_VERSION = 0 35 | SECBUFFER_TOKEN = 2 36 | NTLMBUF_LEN = 12000 37 | ) 38 | 39 | const ISC_REQ = ISC_REQ_CONFIDENTIALITY | 40 | ISC_REQ_REPLAY_DETECT | 41 | ISC_REQ_SEQUENCE_DETECT | 42 | ISC_REQ_CONNECTION | 43 | ISC_REQ_DELEGATE 44 | 45 | type SecurityFunctionTable struct { 46 | dwVersion uint32 47 | EnumerateSecurityPackages uintptr 48 | QueryCredentialsAttributes uintptr 49 | AcquireCredentialsHandle uintptr 50 | FreeCredentialsHandle uintptr 51 | Reserved2 uintptr 52 | InitializeSecurityContext uintptr 53 | AcceptSecurityContext uintptr 54 | CompleteAuthToken uintptr 55 | DeleteSecurityContext uintptr 56 | ApplyControlToken uintptr 57 | QueryContextAttributes uintptr 58 | ImpersonateSecurityContext uintptr 59 | RevertSecurityContext uintptr 60 | MakeSignature uintptr 61 | VerifySignature uintptr 62 | FreeContextBuffer uintptr 63 | QuerySecurityPackageInfo uintptr 64 | Reserved3 uintptr 65 | Reserved4 uintptr 66 | Reserved5 uintptr 67 | Reserved6 uintptr 68 | Reserved7 uintptr 69 | Reserved8 uintptr 70 | QuerySecurityContextToken uintptr 71 | EncryptMessage uintptr 72 | DecryptMessage uintptr 73 | } 74 | 75 | type SEC_WINNT_AUTH_IDENTITY struct { 76 | User *uint16 77 | UserLength uint32 78 | Domain *uint16 79 | DomainLength uint32 80 | Password *uint16 81 | PasswordLength uint32 82 | Flags uint32 83 | } 84 | 85 | type TimeStamp struct { 86 | LowPart uint32 87 | HighPart int32 88 | } 89 | 90 | type SecHandle struct { 91 | dwLower uintptr 92 | dwUpper uintptr 93 | } 94 | 95 | type SecBuffer struct { 96 | cbBuffer uint32 97 | BufferType uint32 98 | pvBuffer *byte 99 | } 100 | 101 | type SecBufferDesc struct { 102 | ulVersion uint32 103 | cBuffers uint32 104 | pBuffers *SecBuffer 105 | } 106 | 107 | type SSPIAuth struct { 108 | Domain string 109 | UserName string 110 | Password string 111 | Service string 112 | cred SecHandle 113 | ctxt SecHandle 114 | } 115 | 116 | func getAuth(user, password, service, workstation string) (Auth, bool) { 117 | if user == "" { 118 | return &SSPIAuth{Service: service}, true 119 | } 120 | if !strings.ContainsRune(user, '\\') { 121 | return nil, false 122 | } 123 | domain_user := strings.SplitN(user, "\\", 2) 124 | return &SSPIAuth{ 125 | Domain: domain_user[0], 126 | UserName: domain_user[1], 127 | Password: password, 128 | Service: service, 129 | }, true 130 | } 131 | 132 | func (auth *SSPIAuth) InitialBytes() ([]byte, error) { 133 | var identity *SEC_WINNT_AUTH_IDENTITY 134 | if auth.UserName != "" { 135 | identity = &SEC_WINNT_AUTH_IDENTITY{ 136 | Flags: SEC_WINNT_AUTH_IDENTITY_UNICODE, 137 | Password: syscall.StringToUTF16Ptr(auth.Password), 138 | PasswordLength: uint32(len(auth.Password)), 139 | Domain: syscall.StringToUTF16Ptr(auth.Domain), 140 | DomainLength: uint32(len(auth.Domain)), 141 | User: syscall.StringToUTF16Ptr(auth.UserName), 142 | UserLength: uint32(len(auth.UserName)), 143 | } 144 | } 145 | var ts TimeStamp 146 | sec_ok, _, _ := syscall.Syscall9(sec_fn.AcquireCredentialsHandle, 147 | 9, 148 | 0, 149 | uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("Negotiate"))), 150 | SECPKG_CRED_OUTBOUND, 151 | 0, 152 | uintptr(unsafe.Pointer(identity)), 153 | 0, 154 | 0, 155 | uintptr(unsafe.Pointer(&auth.cred)), 156 | uintptr(unsafe.Pointer(&ts))) 157 | if sec_ok != SEC_E_OK { 158 | return nil, fmt.Errorf("AcquireCredentialsHandle failed %x", sec_ok) 159 | } 160 | 161 | var buf SecBuffer 162 | var desc SecBufferDesc 163 | desc.ulVersion = SECBUFFER_VERSION 164 | desc.cBuffers = 1 165 | desc.pBuffers = &buf 166 | 167 | outbuf := make([]byte, NTLMBUF_LEN) 168 | buf.cbBuffer = NTLMBUF_LEN 169 | buf.BufferType = SECBUFFER_TOKEN 170 | buf.pvBuffer = &outbuf[0] 171 | 172 | var attrs uint32 173 | sec_ok, _, _ = syscall.Syscall12(sec_fn.InitializeSecurityContext, 174 | 12, 175 | uintptr(unsafe.Pointer(&auth.cred)), 176 | 0, 177 | uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(auth.Service))), 178 | ISC_REQ, 179 | 0, 180 | SECURITY_NETWORK_DREP, 181 | 0, 182 | 0, 183 | uintptr(unsafe.Pointer(&auth.ctxt)), 184 | uintptr(unsafe.Pointer(&desc)), 185 | uintptr(unsafe.Pointer(&attrs)), 186 | uintptr(unsafe.Pointer(&ts))) 187 | if sec_ok == SEC_I_COMPLETE_AND_CONTINUE || 188 | sec_ok == SEC_I_COMPLETE_NEEDED { 189 | syscall.Syscall6(sec_fn.CompleteAuthToken, 190 | 2, 191 | uintptr(unsafe.Pointer(&auth.ctxt)), 192 | uintptr(unsafe.Pointer(&desc)), 193 | 0, 0, 0, 0) 194 | } else if sec_ok != SEC_E_OK && 195 | sec_ok != SEC_I_CONTINUE_NEEDED { 196 | syscall.Syscall6(sec_fn.FreeCredentialsHandle, 197 | 1, 198 | uintptr(unsafe.Pointer(&auth.cred)), 199 | 0, 0, 0, 0, 0) 200 | return nil, fmt.Errorf("InitialBytes InitializeSecurityContext failed %x", sec_ok) 201 | } 202 | return outbuf[:buf.cbBuffer], nil 203 | } 204 | 205 | func (auth *SSPIAuth) NextBytes(bytes []byte) ([]byte, error) { 206 | var in_buf, out_buf SecBuffer 207 | var in_desc, out_desc SecBufferDesc 208 | 209 | in_desc.ulVersion = SECBUFFER_VERSION 210 | in_desc.cBuffers = 1 211 | in_desc.pBuffers = &in_buf 212 | 213 | out_desc.ulVersion = SECBUFFER_VERSION 214 | out_desc.cBuffers = 1 215 | out_desc.pBuffers = &out_buf 216 | 217 | in_buf.BufferType = SECBUFFER_TOKEN 218 | in_buf.pvBuffer = &bytes[0] 219 | in_buf.cbBuffer = uint32(len(bytes)) 220 | 221 | outbuf := make([]byte, NTLMBUF_LEN) 222 | out_buf.BufferType = SECBUFFER_TOKEN 223 | out_buf.pvBuffer = &outbuf[0] 224 | out_buf.cbBuffer = NTLMBUF_LEN 225 | 226 | var attrs uint32 227 | var ts TimeStamp 228 | sec_ok, _, _ := syscall.Syscall12(sec_fn.InitializeSecurityContext, 229 | 12, 230 | uintptr(unsafe.Pointer(&auth.cred)), 231 | uintptr(unsafe.Pointer(&auth.ctxt)), 232 | uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(auth.Service))), 233 | ISC_REQ, 234 | 0, 235 | SECURITY_NETWORK_DREP, 236 | uintptr(unsafe.Pointer(&in_desc)), 237 | 0, 238 | uintptr(unsafe.Pointer(&auth.ctxt)), 239 | uintptr(unsafe.Pointer(&out_desc)), 240 | uintptr(unsafe.Pointer(&attrs)), 241 | uintptr(unsafe.Pointer(&ts))) 242 | if sec_ok == SEC_I_COMPLETE_AND_CONTINUE || 243 | sec_ok == SEC_I_COMPLETE_NEEDED { 244 | syscall.Syscall6(sec_fn.CompleteAuthToken, 245 | 2, 246 | uintptr(unsafe.Pointer(&auth.ctxt)), 247 | uintptr(unsafe.Pointer(&out_desc)), 248 | 0, 0, 0, 0) 249 | } else if sec_ok != SEC_E_OK && 250 | sec_ok != SEC_I_CONTINUE_NEEDED { 251 | return nil, fmt.Errorf("NextBytes InitializeSecurityContext failed %x", sec_ok) 252 | } 253 | 254 | return outbuf[:out_buf.cbBuffer], nil 255 | } 256 | 257 | func (auth *SSPIAuth) Free() { 258 | syscall.Syscall6(sec_fn.DeleteSecurityContext, 259 | 1, 260 | uintptr(unsafe.Pointer(&auth.ctxt)), 261 | 0, 0, 0, 0, 0) 262 | syscall.Syscall6(sec_fn.FreeCredentialsHandle, 263 | 1, 264 | uintptr(unsafe.Pointer(&auth.cred)), 265 | 0, 0, 0, 0, 0) 266 | } 267 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/zensqlmonitor/go-mssqldb/tran.go: -------------------------------------------------------------------------------- 1 | // Transaction Manager requests 2 | // http://msdn.microsoft.com/en-us/library/dd339887.aspx 3 | package mssql 4 | 5 | import ( 6 | "encoding/binary" 7 | ) 8 | 9 | const ( 10 | tmGetDtcAddr = 0 11 | tmPropagateXact = 1 12 | tmBeginXact = 5 13 | tmPromoteXact = 6 14 | tmCommitXact = 7 15 | tmRollbackXact = 8 16 | tmSaveXact = 9 17 | ) 18 | 19 | func sendBeginXact(buf *tdsBuffer, headers []headerStruct, isolation uint8, 20 | name string) (err error) { 21 | buf.BeginPacket(packTransMgrReq) 22 | writeAllHeaders(buf, headers) 23 | var rqtype uint16 = tmBeginXact 24 | err = binary.Write(buf, binary.LittleEndian, &rqtype) 25 | if err != nil { 26 | return 27 | } 28 | err = binary.Write(buf, binary.LittleEndian, &isolation) 29 | if err != nil { 30 | return 31 | } 32 | err = writeBVarChar(buf, name) 33 | if err != nil { 34 | return 35 | } 36 | return buf.FinishPacket() 37 | } 38 | 39 | const ( 40 | fBeginXact = 1 41 | ) 42 | 43 | func sendCommitXact(buf *tdsBuffer, headers []headerStruct, name string, flags uint8, isolation uint8, newname string) error { 44 | buf.BeginPacket(packTransMgrReq) 45 | writeAllHeaders(buf, headers) 46 | var rqtype uint16 = tmCommitXact 47 | err := binary.Write(buf, binary.LittleEndian, &rqtype) 48 | if err != nil { 49 | return err 50 | } 51 | err = writeBVarChar(buf, name) 52 | if err != nil { 53 | return err 54 | } 55 | err = binary.Write(buf, binary.LittleEndian, &flags) 56 | if err != nil { 57 | return err 58 | } 59 | if flags&fBeginXact != 0 { 60 | err = binary.Write(buf, binary.LittleEndian, &isolation) 61 | if err != nil { 62 | return err 63 | } 64 | err = writeBVarChar(buf, name) 65 | if err != nil { 66 | return err 67 | } 68 | } 69 | return buf.FinishPacket() 70 | } 71 | 72 | func sendRollbackXact(buf *tdsBuffer, headers []headerStruct, name string, flags uint8, isolation uint8, newname string) error { 73 | buf.BeginPacket(packTransMgrReq) 74 | writeAllHeaders(buf, headers) 75 | var rqtype uint16 = tmRollbackXact 76 | err := binary.Write(buf, binary.LittleEndian, &rqtype) 77 | if err != nil { 78 | return err 79 | } 80 | err = writeBVarChar(buf, name) 81 | if err != nil { 82 | return err 83 | } 84 | err = binary.Write(buf, binary.LittleEndian, &flags) 85 | if err != nil { 86 | return err 87 | } 88 | if flags&fBeginXact != 0 { 89 | err = binary.Write(buf, binary.LittleEndian, &isolation) 90 | if err != nil { 91 | return err 92 | } 93 | err = writeBVarChar(buf, name) 94 | if err != nil { 95 | return err 96 | } 97 | } 98 | return buf.FinishPacket() 99 | } 100 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/crypto/md4/md4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package md4 implements the MD4 hash algorithm as defined in RFC 1320. 6 | package md4 7 | 8 | import ( 9 | "crypto" 10 | "hash" 11 | ) 12 | 13 | func init() { 14 | crypto.RegisterHash(crypto.MD4, New) 15 | } 16 | 17 | // The size of an MD4 checksum in bytes. 18 | const Size = 16 19 | 20 | // The blocksize of MD4 in bytes. 21 | const BlockSize = 64 22 | 23 | const ( 24 | _Chunk = 64 25 | _Init0 = 0x67452301 26 | _Init1 = 0xEFCDAB89 27 | _Init2 = 0x98BADCFE 28 | _Init3 = 0x10325476 29 | ) 30 | 31 | // digest represents the partial evaluation of a checksum. 32 | type digest struct { 33 | s [4]uint32 34 | x [_Chunk]byte 35 | nx int 36 | len uint64 37 | } 38 | 39 | func (d *digest) Reset() { 40 | d.s[0] = _Init0 41 | d.s[1] = _Init1 42 | d.s[2] = _Init2 43 | d.s[3] = _Init3 44 | d.nx = 0 45 | d.len = 0 46 | } 47 | 48 | // New returns a new hash.Hash computing the MD4 checksum. 49 | func New() hash.Hash { 50 | d := new(digest) 51 | d.Reset() 52 | return d 53 | } 54 | 55 | func (d *digest) Size() int { return Size } 56 | 57 | func (d *digest) BlockSize() int { return BlockSize } 58 | 59 | func (d *digest) Write(p []byte) (nn int, err error) { 60 | nn = len(p) 61 | d.len += uint64(nn) 62 | if d.nx > 0 { 63 | n := len(p) 64 | if n > _Chunk-d.nx { 65 | n = _Chunk - d.nx 66 | } 67 | for i := 0; i < n; i++ { 68 | d.x[d.nx+i] = p[i] 69 | } 70 | d.nx += n 71 | if d.nx == _Chunk { 72 | _Block(d, d.x[0:]) 73 | d.nx = 0 74 | } 75 | p = p[n:] 76 | } 77 | n := _Block(d, p) 78 | p = p[n:] 79 | if len(p) > 0 { 80 | d.nx = copy(d.x[:], p) 81 | } 82 | return 83 | } 84 | 85 | func (d0 *digest) Sum(in []byte) []byte { 86 | // Make a copy of d0, so that caller can keep writing and summing. 87 | d := new(digest) 88 | *d = *d0 89 | 90 | // Padding. Add a 1 bit and 0 bits until 56 bytes mod 64. 91 | len := d.len 92 | var tmp [64]byte 93 | tmp[0] = 0x80 94 | if len%64 < 56 { 95 | d.Write(tmp[0 : 56-len%64]) 96 | } else { 97 | d.Write(tmp[0 : 64+56-len%64]) 98 | } 99 | 100 | // Length in bits. 101 | len <<= 3 102 | for i := uint(0); i < 8; i++ { 103 | tmp[i] = byte(len >> (8 * i)) 104 | } 105 | d.Write(tmp[0:8]) 106 | 107 | if d.nx != 0 { 108 | panic("d.nx != 0") 109 | } 110 | 111 | for _, s := range d.s { 112 | in = append(in, byte(s>>0)) 113 | in = append(in, byte(s>>8)) 114 | in = append(in, byte(s>>16)) 115 | in = append(in, byte(s>>24)) 116 | } 117 | return in 118 | } 119 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/crypto/md4/md4block.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // MD4 block step. 6 | // In its own file so that a faster assembly or C version 7 | // can be substituted easily. 8 | 9 | package md4 10 | 11 | var shift1 = []uint{3, 7, 11, 19} 12 | var shift2 = []uint{3, 5, 9, 13} 13 | var shift3 = []uint{3, 9, 11, 15} 14 | 15 | var xIndex2 = []uint{0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15} 16 | var xIndex3 = []uint{0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15} 17 | 18 | func _Block(dig *digest, p []byte) int { 19 | a := dig.s[0] 20 | b := dig.s[1] 21 | c := dig.s[2] 22 | d := dig.s[3] 23 | n := 0 24 | var X [16]uint32 25 | for len(p) >= _Chunk { 26 | aa, bb, cc, dd := a, b, c, d 27 | 28 | j := 0 29 | for i := 0; i < 16; i++ { 30 | X[i] = uint32(p[j]) | uint32(p[j+1])<<8 | uint32(p[j+2])<<16 | uint32(p[j+3])<<24 31 | j += 4 32 | } 33 | 34 | // If this needs to be made faster in the future, 35 | // the usual trick is to unroll each of these 36 | // loops by a factor of 4; that lets you replace 37 | // the shift[] lookups with constants and, 38 | // with suitable variable renaming in each 39 | // unrolled body, delete the a, b, c, d = d, a, b, c 40 | // (or you can let the optimizer do the renaming). 41 | // 42 | // The index variables are uint so that % by a power 43 | // of two can be optimized easily by a compiler. 44 | 45 | // Round 1. 46 | for i := uint(0); i < 16; i++ { 47 | x := i 48 | s := shift1[i%4] 49 | f := ((c ^ d) & b) ^ d 50 | a += f + X[x] 51 | a = a<>(32-s) 52 | a, b, c, d = d, a, b, c 53 | } 54 | 55 | // Round 2. 56 | for i := uint(0); i < 16; i++ { 57 | x := xIndex2[i] 58 | s := shift2[i%4] 59 | g := (b & c) | (b & d) | (c & d) 60 | a += g + X[x] + 0x5a827999 61 | a = a<>(32-s) 62 | a, b, c, d = d, a, b, c 63 | } 64 | 65 | // Round 3. 66 | for i := uint(0); i < 16; i++ { 67 | x := xIndex3[i] 68 | s := shift3[i%4] 69 | h := b ^ c ^ d 70 | a += h + X[x] + 0x6ed9eba1 71 | a = a<>(32-s) 72 | a, b, c, d = d, a, b, c 73 | } 74 | 75 | a += aa 76 | b += bb 77 | c += cc 78 | d += dd 79 | 80 | p = p[_Chunk:] 81 | n += _Chunk 82 | } 83 | 84 | dig.s[0] = a 85 | dig.s[1] = b 86 | dig.s[2] = c 87 | dig.s[3] = d 88 | return n 89 | } 90 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Quentin ZINNEN 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [Twitter](https://twitter.com/zensqlmonitor) | 2 | [Email](mailto:sqlzen@hotmail.com) 3 | 4 | # influxdb-sqlserver 5 | Collect Microsoft SQL Server metrics, send to InfluxDB and visualize with Grafana 6 | 7 | ![influxdb-grafana](https://cloud.githubusercontent.com/assets/16494280/13547132/aca6b6ca-e2c5-11e5-9f97-d6ff90918daa.png) 8 | 9 | 10 | ## Getting Started 11 | 12 | - InfluxDB: 13 | - [Install InfluxDB](https://influxdb.com/docs/v0.9/introduction/installation.html) 14 | - [Create database SQLSERVER](https://influxdb.com/docs/v0.9/introduction/getting_started.html)
15 | - Grafana: 16 | - [Install Grafana](http://docs.grafana.org/installation/) 17 | - Import dashboard from file provided in the [repository](https://github.com/zensqlmonitor/influxdb-sqlserver/tree/master/grafana)
18 | - influxdb-sqlserver: 19 | - [Install GO](https://golang.org/doc/install) 20 | - [Setup you GOPATH](https://golang.org/doc/code.html#GOPATH) 21 | - Run ``` go get github.com/zensqlmonitor/influxdb-sqlserver ``` 22 | - Edit the configuration to match your needs
23 | - SQL Server: 24 | - Create a login - with a strong password - in every SQL Server instance you want to monitor:
25 | ```SQL 26 | USE master; 27 | GO 28 | CREATE LOGIN [linuxuser] WITH PASSWORD = N'mystrongpassword'; 29 | GO 30 | GRANT VIEW SERVER STATE TO [linuxuser]; 31 | GO 32 | GRANT VIEW ANY DEFINITION TO [linuxuser]; 33 | GO 34 | ``` 35 | 36 | ### How to use GO code 37 | 38 | - Run in background: ``` go run influxdb-sqlserver.go & ``` 39 | - Build in the current directory: ``` go build influxdb-sqlserver.go ``` 40 | - Install in $GOPATH/bin: ``` go install influxdb-sqlserver.go ``` 41 | 42 | ### Dependencies 43 | 44 | - Go 1.5 45 | - Microsoft SQL server driver (https://github.com/denisenkom/go-mssqldb) 46 | - TOML parser (https://github.com/BurntSushi/toml) 47 | 48 | ### Command-line flags 49 | ``` 50 | -config (string) = the configuration filepath in toml format (default="influxdb-sqlserver.conf") 51 | -h = usage 52 | ``` 53 | 54 | ## T-SQL Scripts provided 55 | Scripts provided are lightweight and use Dynamic Management Views supplied by SQL Server 56 | 57 | - getperfcounters.sql: 1000+ metrics from sys.dm_os_performance_counters 58 | - getperfmetrics.sql: some special performance metrics 59 | - getwaitstatscat.sql: list of wait tasks categorized from sys.dm_os_wait_stats 60 | - getmemoryclerksplit.sql: memory breakdown from sys.dm_os_memory_clerks 61 | - getmemory.sql: available and used memory from sys.dm_os_sys_memory 62 | - getdatabasesizetrend.sql: database size trend, datafile and logfile from sys.dm_io_virtual_file_stats 63 | - getdatabaseio.sql: database I/O from sys.dm_io_virtual_file_stats 64 | - getcpu.sql: cpu usage from sys.dm_os_ring_buffers 65 | 66 | 67 | ##### Note 68 | 69 | influxdb-sqlserver uses InfluxDB line protocol. If you add a sql query you have to return one column formatted with this protocol. 70 | For more details, see scripts provided in the repository and the InfluxDB [documentation](https://influxdb.com/docs/v0.9/write_protocols/line.html) 71 | 72 | 73 | 74 | ## License 75 | 76 | MIT-LICENSE. See LICENSE file provided in the repository for details 77 | 78 | -------------------------------------------------------------------------------- /config/config.go: -------------------------------------------------------------------------------- 1 | // Package config provides the influxdb-sqlserver specific configuration options. 2 | package config 3 | 4 | import () 5 | 6 | // Defaults for config variables which are not set 7 | const ( 8 | DefaultLogFileName string = "influxdb-sqlserver.log" 9 | DefaultModes string = "file" 10 | DefaultBufferLen int = 10000 11 | DefaultLevelConsole string = "Trace" 12 | DefaultLevelFile string = "Warn" 13 | DefaultFormatting bool = true 14 | DefaultLogRotate bool = true 15 | DefaultMaxLines int = 1000000 16 | DefaultMaxSizeShift int = 28 17 | DefaultDailyRotate bool = true 18 | DefaultMaxDays int = 7 19 | 20 | DefaultSqlScriptPath string = "/usr/local/influxdb-sqlserver/sqlscripts/" 21 | 22 | DefaultPollingInterval int = 15 23 | DefaultPollingIntervalIfError int = 60 24 | 25 | DefaultInfluxDBUrl string = "http://localhost:8086" 26 | DefaultInfluxDBTimeOut int = 0 27 | DefaultInfluxDBDatabase string = "SQLSERVER" 28 | DefaultInfluxDBPrecision string = "ms" 29 | ) 30 | 31 | type TOMLConfig struct { 32 | InfluxDB influxDB 33 | Servers map[string]Server 34 | Scripts map[string]*script 35 | Polling polling 36 | Logging logging 37 | } 38 | type polling struct { 39 | Interval int 40 | IntervalIfError int 41 | } 42 | type influxDB struct { 43 | Url string 44 | Database string 45 | Username string 46 | Password string 47 | Precision string 48 | TimeOut int 49 | } 50 | type logging struct { 51 | Modes string 52 | BufferLen int 53 | LevelConsole string 54 | LevelFile string 55 | FileName string 56 | Formatting bool 57 | LogRotate bool 58 | MaxLines int 59 | MaxSizeShift int 60 | DailyRotate bool 61 | MaxDays int 62 | } 63 | type Server struct { 64 | IP string 65 | Port int 66 | Username string 67 | Password string 68 | } 69 | type script struct { 70 | Name string 71 | Interval int 72 | } 73 | -------------------------------------------------------------------------------- /etl/etl.go: -------------------------------------------------------------------------------- 1 | package etl 2 | 3 | import ( 4 | "bytes" 5 | "database/sql" 6 | "errors" 7 | "fmt" 8 | "io/ioutil" 9 | "net/http" 10 | "strings" 11 | 12 | _ "github.com/zensqlmonitor/go-mssqldb" 13 | ) 14 | 15 | type Extracter interface { 16 | Extract() error 17 | } 18 | 19 | type extracter struct { 20 | connString string 21 | query string 22 | Result string 23 | } 24 | 25 | var _ Extracter = (*extracter)(nil) 26 | 27 | func NewExtracter(connString, query string) extracter { 28 | ext := extracter{} 29 | ext.connString = connString 30 | ext.query = query 31 | return ext 32 | } 33 | 34 | func (ext *extracter) Extract() error { 35 | // deferred opening 36 | conn, err := sql.Open("mssql", ext.connString) 37 | if err != nil { 38 | // Handle error 39 | return errors.New(err.Error()) 40 | } 41 | // verify that a connection can be made before making a query 42 | err = conn.Ping() 43 | if err != nil { 44 | // Handle error 45 | return errors.New(err.Error()) 46 | } 47 | defer conn.Close() 48 | 49 | // execute query 50 | rows, err := conn.Query(ext.query) 51 | if err != nil { 52 | // Handle error 53 | return errors.New(err.Error()) 54 | } 55 | defer rows.Close() 56 | 57 | for rows.Next() { 58 | var result string 59 | if err := rows.Scan(&result); err != nil { 60 | // Handle error 61 | return errors.New(err.Error()) 62 | } 63 | // write string 64 | ext.Result += fmt.Sprintf("%s\n", result) 65 | } 66 | if err := rows.Err(); err != nil { 67 | // Handle error 68 | return errors.New(err.Error()) 69 | } 70 | 71 | return nil 72 | } 73 | 74 | type Loader interface { 75 | Load() error 76 | } 77 | 78 | type loader struct { 79 | url string 80 | database string 81 | username string 82 | password string 83 | precision string 84 | result string 85 | } 86 | 87 | var _ Loader = (*loader)(nil) 88 | 89 | func NewLoader(url, result string) loader { 90 | loa := loader{} 91 | loa.url = url 92 | loa.result = result 93 | return loa 94 | } 95 | 96 | // 2xx: If it's HTTP 204 No Content, success! 97 | // If it's HTTP 200 OK, InfluxDB understood the request but couldn't complete it. 98 | // 4xx: InfluxDB could not understand the request. 99 | // 5xx: The system is overloaded or significantly impaired 100 | func (loa *loader) Load() error { 101 | 102 | client := &http.Client{} 103 | req, err := http.NewRequest("POST", loa.url, bytes.NewBufferString(loa.result)) 104 | req.Header.Set("Content-Type", "application/text") 105 | if len(loa.username) > 0 { 106 | req.SetBasicAuth(loa.username, loa.password) 107 | } 108 | params := req.URL.Query() 109 | if len(loa.precision) > 0 { 110 | params.Set("precision", loa.precision) 111 | } 112 | req.URL.RawQuery = params.Encode() 113 | resp, err := client.Do(req) 114 | 115 | if err != nil { 116 | // Handle error 117 | return errors.New(err.Error()) 118 | } 119 | defer resp.Body.Close() 120 | 121 | // read response 122 | htmlData, err := ioutil.ReadAll(resp.Body) 123 | if err != nil { 124 | // Handle error 125 | return errors.New(err.Error()) 126 | } 127 | // check for success 128 | if !strings.Contains(resp.Status, "204") { 129 | // Handle error 130 | return errors.New(string(htmlData)) 131 | } 132 | return nil 133 | 134 | } 135 | -------------------------------------------------------------------------------- /influxdb-sqlserver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zensqlmonitor/influxdb-sqlserver/58c5833ed096741673d6272b12c5f7950e1e1fe6/influxdb-sqlserver -------------------------------------------------------------------------------- /influxdb-sqlserver.conf: -------------------------------------------------------------------------------- 1 | ### Welcome to the influxdb-sqlserver configuration file. 2 | ### 3 | ### Polling 4 | ### 5 | ### Controls polling interval 6 | ### 7 | [polling] 8 | ## Default polling interval (in seconds) - minimum of 15 9 | #interval=15 10 | #intervaliferror=60 11 | 12 | ### 13 | ### InfluxDB 14 | ### 15 | ### Controls InfluxDB api endpoint 16 | [influxdb] 17 | # url="http://localhost:8086" 18 | # database="SQLSERVER" 19 | 20 | ## Precision of writes, valid values are n, u, ms, s, m, and h 21 | # precision= "ms" 22 | 23 | ## Connection timeout (in seconds). If not provided, will default to 0 (no timeout) 24 | # timeout=5 25 | 26 | ## Credentials 27 | # username="influxdb-sqlserver" 28 | # password="influxdb-sqlservermetrics" 29 | 30 | 31 | ### 32 | ### Servers 33 | ### 34 | ### Controls instances to monitor 35 | ### 36 | ### All instances have to added here with format [servers.name] 37 | ### At least one instance is required 38 | ### The SQL Server Authentication user id or the Windows Authentication user id in the DOMAIN\User format. 39 | ### On Windows, if user id is empty or missing Single-Sign-On is used. 40 | [servers] 41 | 42 | [servers.win8-dev1] 43 | ip = "192.168.1.30" 44 | port = 1433 45 | username="telegraf" 46 | password="T$l$gr@f69*" 47 | 48 | [servers.win8-dev2] 49 | ip = "192.168.1.30" 50 | port = 2222 51 | username="telegraf" 52 | password="T$l$gr@f69*" 53 | 54 | ### 55 | ### Scripts 56 | ### 57 | ### Controls the T-SQL scripts to execute 58 | ### 59 | ### 60 | ### At least one script is required 61 | [scripts] 62 | 63 | [scripts.PerformanceCounters] 64 | name="getperfcounters.sql" 65 | interval=15 66 | 67 | [scripts.PerformanceMetrics] 68 | name="getperfmetrics.sql" 69 | interval=15 70 | 71 | [scripts.WaitStats] 72 | name="getwaitstatscat.sql" 73 | interval=15 74 | 75 | [scripts.Memory] 76 | name="getmemory.sql" 77 | interval=15 78 | 79 | [scripts.MemoryClerk] 80 | name="getmemoryclerksplit.sql" 81 | interval=15 82 | 83 | [scripts.DatabaseIO] 84 | name="getdatabaseio.sql" 85 | interval=15 86 | 87 | [scripts.DatabaseSizeTrend] 88 | name="getdatabasesizetrend.sql" 89 | interval=15 90 | 91 | [scripts.CPU] 92 | name="getcpu.sql" 93 | interval=15 94 | 95 | 96 | ### 97 | ### Logging 98 | ### 99 | ### Controls Logging 100 | ### 101 | [logging] 102 | # File name 103 | #filename="influxdb-sqlserver.log" 104 | 105 | # Either "console", "file", default is "file" 106 | # Use comma to separate multiple modes, e.g. "console, file" 107 | modes="console, file" 108 | 109 | # Buffer length of channel, keep it as it is if you don't know what it is. 110 | bufferlen=10000 111 | 112 | # Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace" 113 | levelconsole="Trace" 114 | 115 | # Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace" 116 | levelfile="Warn" 117 | 118 | # Set formatting to "false" to disable color formatting of console logs 119 | formatting=true 120 | 121 | # This enables automated log rotate(switch of following options), default is true 122 | logrotate=true 123 | 124 | # Max line number of single file, default is 1000000 125 | maxlines=1000000 126 | 127 | # Max size shift of single file, default is 28 means 1 << 28, 256MB 128 | maxsizeshift=28 129 | 130 | # Segment log daily, default is true 131 | dailyrotate=true 132 | 133 | # Expired days of log file(delete after max days), default is 7 134 | maxdays=7 135 | 136 | 137 | ### End -------------------------------------------------------------------------------- /log/console.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Gogs Authors. All rights reserved. 2 | // Use of this source code is governed by a MIT-style 3 | // license that can be found in the LICENSE file. 4 | package log 5 | 6 | import ( 7 | "encoding/json" 8 | "fmt" 9 | "log" 10 | "os" 11 | "runtime" 12 | ) 13 | 14 | type Brush func(string) string 15 | 16 | func NewBrush(color string) Brush { 17 | pre := "\033[" 18 | reset := "\033[0m" 19 | return func(text string) string { 20 | return pre + color + "m" + text + reset 21 | } 22 | } 23 | 24 | var ( 25 | Red = NewBrush("1;31") 26 | Purple = NewBrush("1;35") 27 | Yellow = NewBrush("1;33") 28 | Green = NewBrush("1;32") 29 | Blue = NewBrush("1;34") 30 | Cyan = NewBrush("1;36") 31 | 32 | colors = []Brush{ 33 | Cyan, // Trace cyan 34 | Blue, // Debug blue 35 | Green, // Info green 36 | Yellow, // Warn yellow 37 | Red, // Error red 38 | Purple, // Critical purple 39 | Red, // Fatal red 40 | } 41 | consoleWriter = &ConsoleWriter{lg: log.New(os.Stdout, "", 0), 42 | Level: TRACE} 43 | ) 44 | 45 | // ConsoleWriter implements LoggerInterface and writes messages to terminal. 46 | type ConsoleWriter struct { 47 | lg *log.Logger 48 | Level int `json:"level"` 49 | Formatting bool `json:"formatting"` 50 | } 51 | 52 | // create ConsoleWriter returning as LoggerInterface. 53 | func NewConsole() LoggerInterface { 54 | return &ConsoleWriter{ 55 | lg: log.New(os.Stderr, "", log.Ldate|log.Ltime), 56 | Level: TRACE, 57 | Formatting: true, 58 | } 59 | } 60 | 61 | func (cw *ConsoleWriter) Init(config string) error { 62 | return json.Unmarshal([]byte(config), cw) 63 | } 64 | 65 | func (cw *ConsoleWriter) WriteMsg(msg string, skip, level int) error { 66 | if cw.Level > level { 67 | return nil 68 | } 69 | if runtime.GOOS == "windows" || !cw.Formatting { 70 | cw.lg.Println(msg) 71 | } else { 72 | cw.lg.Println(colors[level](msg)) 73 | } 74 | return nil 75 | } 76 | 77 | func (_ *ConsoleWriter) Flush() { 78 | 79 | } 80 | 81 | func (_ *ConsoleWriter) Destroy() { 82 | } 83 | 84 | func printConsole(level int, msg string) { 85 | consoleWriter.WriteMsg(msg, 0, level) 86 | } 87 | 88 | func printfConsole(level int, format string, v ...interface{}) { 89 | consoleWriter.WriteMsg(fmt.Sprintf(format, v...), 0, level) 90 | } 91 | 92 | // ConsoleTrace prints to stdout using TRACE colors 93 | func ConsoleTrace(s string) { 94 | printConsole(TRACE, s) 95 | } 96 | 97 | // ConsoleTracef prints a formatted string to stdout using TRACE colors 98 | func ConsoleTracef(format string, v ...interface{}) { 99 | printfConsole(TRACE, format, v...) 100 | } 101 | 102 | // ConsoleDebug prints to stdout using DEBUG colors 103 | func ConsoleDebug(s string) { 104 | printConsole(DEBUG, s) 105 | } 106 | 107 | // ConsoleDebugf prints a formatted string to stdout using DEBUG colors 108 | func ConsoleDebugf(format string, v ...interface{}) { 109 | printfConsole(DEBUG, format, v...) 110 | } 111 | 112 | // ConsoleInfo prints to stdout using INFO colors 113 | func ConsoleInfo(s string) { 114 | printConsole(INFO, s) 115 | } 116 | 117 | // ConsoleInfof prints a formatted string to stdout using INFO colors 118 | func ConsoleInfof(format string, v ...interface{}) { 119 | printfConsole(INFO, format, v...) 120 | } 121 | 122 | // ConsoleWarn prints to stdout using WARN colors 123 | func ConsoleWarn(s string) { 124 | printConsole(WARN, s) 125 | } 126 | 127 | // ConsoleWarnf prints a formatted string to stdout using WARN colors 128 | func ConsoleWarnf(format string, v ...interface{}) { 129 | printfConsole(WARN, format, v...) 130 | } 131 | 132 | // ConsoleError prints to stdout using ERROR colors 133 | func ConsoleError(s string) { 134 | printConsole(ERROR, s) 135 | } 136 | 137 | // ConsoleErrorf prints a formatted string to stdout using ERROR colors 138 | func ConsoleErrorf(format string, v ...interface{}) { 139 | printfConsole(ERROR, format, v...) 140 | } 141 | 142 | // ConsoleFatal prints to stdout using FATAL colors 143 | func ConsoleFatal(s string) { 144 | printConsole(FATAL, s) 145 | os.Exit(1) 146 | } 147 | 148 | // ConsoleFatalf prints a formatted string to stdout using FATAL colors 149 | func ConsoleFatalf(format string, v ...interface{}) { 150 | printfConsole(FATAL, format, v...) 151 | os.Exit(1) 152 | } 153 | 154 | func init() { 155 | Register("console", NewConsole) 156 | } 157 | -------------------------------------------------------------------------------- /log/file.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Gogs Authors. All rights reserved. 2 | // Use of this source code is governed by a MIT-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package log 6 | 7 | import ( 8 | "encoding/json" 9 | "errors" 10 | "fmt" 11 | "io/ioutil" 12 | "log" 13 | "os" 14 | "path/filepath" 15 | "strings" 16 | "sync" 17 | "time" 18 | ) 19 | 20 | // FileLogWriter implements LoggerInterface. 21 | // It writes messages by lines limit, file size limit, or time frequency. 22 | type FileLogWriter struct { 23 | *log.Logger 24 | mw *MuxWriter 25 | // The opened file 26 | Filename string `json:"filename"` 27 | 28 | Maxlines int `json:"maxlines"` 29 | maxlines_curlines int 30 | 31 | // Rotate at size 32 | Maxsize int `json:"maxsize"` 33 | maxsize_cursize int 34 | 35 | // Rotate daily 36 | Daily bool `json:"daily"` 37 | Maxdays int64 `json:"maxdays"` 38 | daily_opendate int 39 | 40 | Rotate bool `json:"rotate"` 41 | 42 | startLock sync.Mutex // Only one log can write to the file 43 | 44 | Level int `json:"level"` 45 | } 46 | 47 | // an *os.File writer with locker. 48 | type MuxWriter struct { 49 | sync.Mutex 50 | fd *os.File 51 | } 52 | 53 | // write to os.File. 54 | func (l *MuxWriter) Write(b []byte) (int, error) { 55 | l.Lock() 56 | defer l.Unlock() 57 | return l.fd.Write(b) 58 | } 59 | 60 | // set os.File in writer. 61 | func (l *MuxWriter) SetFd(fd *os.File) { 62 | if l.fd != nil { 63 | l.fd.Close() 64 | } 65 | l.fd = fd 66 | } 67 | 68 | // create a FileLogWriter returning as LoggerInterface. 69 | func NewFileWriter() LoggerInterface { 70 | w := &FileLogWriter{ 71 | Filename: "", 72 | Maxlines: 1000000, 73 | Maxsize: 1 << 28, //256 MB 74 | Daily: true, 75 | Maxdays: 7, 76 | Rotate: true, 77 | Level: TRACE, 78 | } 79 | // use MuxWriter instead direct use os.File for lock write when rotate 80 | w.mw = new(MuxWriter) 81 | // set MuxWriter as Logger's io.Writer 82 | w.Logger = log.New(w.mw, "", log.Ldate|log.Ltime) 83 | return w 84 | } 85 | 86 | // Init file logger with json config. 87 | // config like: 88 | // { 89 | // "filename":"log/gogs.log", 90 | // "maxlines":10000, 91 | // "maxsize":1<<30, 92 | // "daily":true, 93 | // "maxdays":15, 94 | // "rotate":true 95 | // } 96 | func (w *FileLogWriter) Init(config string) error { 97 | if err := json.Unmarshal([]byte(config), w); err != nil { 98 | return err 99 | } 100 | if len(w.Filename) == 0 { 101 | return errors.New("config must have filename") 102 | } 103 | return w.StartLogger() 104 | } 105 | 106 | // start file logger. create log file and set to locker-inside file writer. 107 | func (w *FileLogWriter) StartLogger() error { 108 | fd, err := w.createLogFile() 109 | if err != nil { 110 | return err 111 | } 112 | w.mw.SetFd(fd) 113 | if err = w.initFd(); err != nil { 114 | return err 115 | } 116 | return nil 117 | } 118 | 119 | func (w *FileLogWriter) docheck(size int) { 120 | w.startLock.Lock() 121 | defer w.startLock.Unlock() 122 | if w.Rotate && ((w.Maxlines > 0 && w.maxlines_curlines >= w.Maxlines) || 123 | (w.Maxsize > 0 && w.maxsize_cursize >= w.Maxsize) || 124 | (w.Daily && time.Now().Day() != w.daily_opendate)) { 125 | if err := w.DoRotate(); err != nil { 126 | fmt.Fprintf(os.Stderr, "FileLogWriter(%q): %s\n", w.Filename, err) 127 | return 128 | } 129 | } 130 | w.maxlines_curlines++ 131 | w.maxsize_cursize += size 132 | } 133 | 134 | // write logger message into file. 135 | func (w *FileLogWriter) WriteMsg(msg string, skip, level int) error { 136 | if level < w.Level { 137 | return nil 138 | } 139 | n := 24 + len(msg) // 24 stand for the length "2013/06/23 21:00:22 [T] " 140 | w.docheck(n) 141 | w.Logger.Println(msg) 142 | return nil 143 | } 144 | 145 | func (w *FileLogWriter) createLogFile() (*os.File, error) { 146 | // Open the log file 147 | return os.OpenFile(w.Filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) 148 | } 149 | 150 | func (w *FileLogWriter) initFd() error { 151 | fd := w.mw.fd 152 | finfo, err := fd.Stat() 153 | if err != nil { 154 | return fmt.Errorf("get stat: %s\n", err) 155 | } 156 | w.maxsize_cursize = int(finfo.Size()) 157 | w.daily_opendate = time.Now().Day() 158 | if finfo.Size() > 0 { 159 | content, err := ioutil.ReadFile(w.Filename) 160 | if err != nil { 161 | return err 162 | } 163 | w.maxlines_curlines = len(strings.Split(string(content), "\n")) 164 | } else { 165 | w.maxlines_curlines = 0 166 | } 167 | return nil 168 | } 169 | 170 | // DoRotate means it need to write file in new file. 171 | // new file name like xx.log.2013-01-01.2 172 | func (w *FileLogWriter) DoRotate() error { 173 | _, err := os.Lstat(w.Filename) 174 | if err == nil { // file exists 175 | // Find the next available number 176 | num := 1 177 | fname := "" 178 | for ; err == nil && num <= 999; num++ { 179 | fname = w.Filename + fmt.Sprintf(".%s.%03d", time.Now().Format("2006-01-02"), num) 180 | _, err = os.Lstat(fname) 181 | } 182 | // return error if the last file checked still existed 183 | if err == nil { 184 | return fmt.Errorf("rotate: cannot find free log number to rename %s\n", w.Filename) 185 | } 186 | 187 | // block Logger's io.Writer 188 | w.mw.Lock() 189 | defer w.mw.Unlock() 190 | 191 | fd := w.mw.fd 192 | fd.Close() 193 | 194 | // close fd before rename 195 | // Rename the file to its newfound home 196 | if err = os.Rename(w.Filename, fname); err != nil { 197 | return fmt.Errorf("Rotate: %s\n", err) 198 | } 199 | 200 | // re-start logger 201 | if err = w.StartLogger(); err != nil { 202 | return fmt.Errorf("Rotate StartLogger: %s\n", err) 203 | } 204 | 205 | go w.deleteOldLog() 206 | } 207 | 208 | return nil 209 | } 210 | 211 | func (w *FileLogWriter) deleteOldLog() { 212 | dir := filepath.Dir(w.Filename) 213 | filepath.Walk(dir, func(path string, info os.FileInfo, err error) (returnErr error) { 214 | defer func() { 215 | if r := recover(); r != nil { 216 | returnErr = fmt.Errorf("Unable to delete old log '%s', error: %+v", path, r) 217 | } 218 | }() 219 | 220 | if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.Maxdays) { 221 | if strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) { 222 | os.Remove(path) 223 | } 224 | } 225 | return returnErr 226 | }) 227 | } 228 | 229 | // destroy file logger, close file writer. 230 | func (w *FileLogWriter) Destroy() { 231 | w.mw.fd.Close() 232 | } 233 | 234 | // flush file logger. 235 | // there are no buffering messages in file logger in memory. 236 | // flush file means sync file from disk. 237 | func (w *FileLogWriter) Flush() { 238 | w.mw.fd.Sync() 239 | } 240 | 241 | func init() { 242 | Register("file", NewFileWriter) 243 | } 244 | -------------------------------------------------------------------------------- /log/log.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Gogs Authors. All rights reserved. 2 | // Use of this source code is governed by a MIT-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package log 6 | 7 | import ( 8 | "fmt" 9 | "os" 10 | "path/filepath" 11 | "runtime" 12 | "strings" 13 | "sync" 14 | ) 15 | 16 | var LogLevels = map[string]int{ 17 | "Trace": 0, 18 | "Debug": 1, 19 | "Info": 2, 20 | "Warn": 3, 21 | "Error": 4, 22 | "Critical": 5, 23 | } 24 | 25 | var ( 26 | loggers []*Logger 27 | ) 28 | 29 | func NewLogger(bufLen int64, mode, config string) { 30 | logger := newLogger(bufLen) 31 | 32 | isExist := false 33 | for _, l := range loggers { 34 | if l.adapter == mode { 35 | isExist = true 36 | l = logger 37 | } 38 | } 39 | if !isExist { 40 | loggers = append(loggers, logger) 41 | } 42 | if err := logger.SetLogger(mode, config); err != nil { 43 | Fatal(1, "Fail to set logger(%s): %v", mode, err) 44 | } 45 | } 46 | 47 | func Trace(format string, v ...interface{}) { 48 | for _, logger := range loggers { 49 | logger.Trace(format, v...) 50 | } 51 | } 52 | 53 | func Debug(format string, v ...interface{}) { 54 | for _, logger := range loggers { 55 | logger.Debug(format, v...) 56 | } 57 | } 58 | 59 | func Info(format string, v ...interface{}) { 60 | for _, logger := range loggers { 61 | logger.Info(format, v...) 62 | } 63 | } 64 | 65 | func Warn(format string, v ...interface{}) { 66 | for _, logger := range loggers { 67 | logger.Warn(format, v...) 68 | } 69 | } 70 | 71 | func Error(skip int, format string, v ...interface{}) { 72 | for _, logger := range loggers { 73 | logger.Error(skip, format, v...) 74 | } 75 | } 76 | 77 | func Critical(skip int, format string, v ...interface{}) { 78 | for _, logger := range loggers { 79 | logger.Critical(skip, format, v...) 80 | } 81 | } 82 | 83 | func Fatal(skip int, format string, v ...interface{}) { 84 | Error(skip, format, v...) 85 | for _, l := range loggers { 86 | l.Close() 87 | } 88 | os.Exit(1) 89 | } 90 | 91 | func Close() { 92 | for _, l := range loggers { 93 | l.Close() 94 | // delete the logger. 95 | l = nil 96 | } 97 | // clear the loggers slice. 98 | loggers = nil 99 | } 100 | 101 | // .___ __ _____ 102 | // | | _____/ |_ ____________/ ____\____ ____ ____ 103 | // | |/ \ __\/ __ \_ __ \ __\\__ \ _/ ___\/ __ \ 104 | // | | | \ | \ ___/| | \/| | / __ \\ \__\ ___/ 105 | // |___|___| /__| \___ >__| |__| (____ /\___ >___ > 106 | // \/ \/ \/ \/ \/ 107 | 108 | type LogLevel int 109 | 110 | const ( 111 | TRACE = iota 112 | DEBUG 113 | INFO 114 | WARN 115 | ERROR 116 | CRITICAL 117 | FATAL 118 | ) 119 | 120 | // LoggerInterface represents behaviors of a logger provider. 121 | type LoggerInterface interface { 122 | Init(config string) error 123 | WriteMsg(msg string, skip, level int) error 124 | Destroy() 125 | Flush() 126 | } 127 | 128 | type loggerType func() LoggerInterface 129 | 130 | var adapters = make(map[string]loggerType) 131 | 132 | // Register registers given logger provider to adapters. 133 | func Register(name string, log loggerType) { 134 | if log == nil { 135 | panic("log: register provider is nil") 136 | } 137 | if _, dup := adapters[name]; dup { 138 | panic("log: register called twice for provider \"" + name + "\"") 139 | } 140 | adapters[name] = log 141 | } 142 | 143 | type logMsg struct { 144 | skip, level int 145 | msg string 146 | } 147 | 148 | // Logger is default logger in beego application. 149 | // it can contain several providers and log message into all providers. 150 | type Logger struct { 151 | adapter string 152 | lock sync.Mutex 153 | level int 154 | msg chan *logMsg 155 | outputs map[string]LoggerInterface 156 | quit chan bool 157 | } 158 | 159 | // newLogger initializes and returns a new logger. 160 | func newLogger(buffer int64) *Logger { 161 | l := &Logger{ 162 | msg: make(chan *logMsg, buffer), 163 | outputs: make(map[string]LoggerInterface), 164 | quit: make(chan bool), 165 | } 166 | go l.StartLogger() 167 | return l 168 | } 169 | 170 | // SetLogger sets new logger instanse with given logger adapter and config. 171 | func (l *Logger) SetLogger(adapter string, config string) error { 172 | l.lock.Lock() 173 | defer l.lock.Unlock() 174 | if log, ok := adapters[adapter]; ok { 175 | lg := log() 176 | if err := lg.Init(config); err != nil { 177 | return err 178 | } 179 | l.outputs[adapter] = lg 180 | l.adapter = adapter 181 | } else { 182 | panic("log: unknown adapter \"" + adapter + "\" (forgotten register?)") 183 | } 184 | return nil 185 | } 186 | 187 | // DelLogger removes a logger adapter instance. 188 | func (l *Logger) DelLogger(adapter string) error { 189 | l.lock.Lock() 190 | defer l.lock.Unlock() 191 | if lg, ok := l.outputs[adapter]; ok { 192 | lg.Destroy() 193 | delete(l.outputs, adapter) 194 | } else { 195 | panic("log: unknown adapter \"" + adapter + "\" (forgotten register?)") 196 | } 197 | return nil 198 | } 199 | 200 | func (l *Logger) writerMsg(skip, level int, msg string) error { 201 | if l.level > level { 202 | return nil 203 | } 204 | lm := &logMsg{ 205 | skip: skip, 206 | level: level, 207 | } 208 | 209 | // Only error information needs locate position for debugging. 210 | if lm.level >= ERROR { 211 | pc, file, line, ok := runtime.Caller(skip) 212 | if ok { 213 | // Get caller function name. 214 | fn := runtime.FuncForPC(pc) 215 | var fnName string 216 | if fn == nil { 217 | fnName = "?()" 218 | } else { 219 | fnName = strings.TrimLeft(filepath.Ext(fn.Name()), ".") + "()" 220 | } 221 | 222 | lm.msg = fmt.Sprintf("[%s:%d %s] %s", filepath.Base(file), line, fnName, msg) 223 | } else { 224 | lm.msg = msg 225 | } 226 | } else { 227 | lm.msg = msg 228 | } 229 | l.msg <- lm 230 | return nil 231 | } 232 | 233 | // StartLogger starts logger chan reading. 234 | func (l *Logger) StartLogger() { 235 | for { 236 | select { 237 | case bm := <-l.msg: 238 | for _, l := range l.outputs { 239 | if err := l.WriteMsg(bm.msg, bm.skip, bm.level); err != nil { 240 | fmt.Println("ERROR, unable to WriteMsg:", err) 241 | } 242 | } 243 | case <-l.quit: 244 | return 245 | } 246 | } 247 | } 248 | 249 | // Flush flushs all chan data. 250 | func (l *Logger) Flush() { 251 | for _, l := range l.outputs { 252 | l.Flush() 253 | } 254 | } 255 | 256 | // Close closes logger, flush all chan data and destroy all adapter instances. 257 | func (l *Logger) Close() { 258 | l.quit <- true 259 | for { 260 | if len(l.msg) > 0 { 261 | bm := <-l.msg 262 | for _, l := range l.outputs { 263 | if err := l.WriteMsg(bm.msg, bm.skip, bm.level); err != nil { 264 | fmt.Println("ERROR, unable to WriteMsg:", err) 265 | } 266 | } 267 | } else { 268 | break 269 | } 270 | } 271 | for _, l := range l.outputs { 272 | l.Flush() 273 | l.Destroy() 274 | } 275 | } 276 | 277 | func (l *Logger) Trace(format string, v ...interface{}) { 278 | msg := fmt.Sprintf("[T] "+format, v...) 279 | l.writerMsg(0, TRACE, msg) 280 | } 281 | 282 | func (l *Logger) Debug(format string, v ...interface{}) { 283 | msg := fmt.Sprintf("[D] "+format, v...) 284 | l.writerMsg(0, DEBUG, msg) 285 | } 286 | 287 | func (l *Logger) Info(format string, v ...interface{}) { 288 | msg := fmt.Sprintf("[I] "+format, v...) 289 | l.writerMsg(0, INFO, msg) 290 | } 291 | 292 | func (l *Logger) Warn(format string, v ...interface{}) { 293 | msg := fmt.Sprintf("[W] "+format, v...) 294 | l.writerMsg(0, WARN, msg) 295 | } 296 | 297 | func (l *Logger) Error(skip int, format string, v ...interface{}) { 298 | msg := fmt.Sprintf("[E] "+format, v...) 299 | l.writerMsg(skip, ERROR, msg) 300 | } 301 | 302 | func (l *Logger) Critical(skip int, format string, v ...interface{}) { 303 | msg := fmt.Sprintf("[C] "+format, v...) 304 | l.writerMsg(skip, CRITICAL, msg) 305 | } 306 | 307 | func (l *Logger) Fatal(skip int, format string, v ...interface{}) { 308 | msg := fmt.Sprintf("[F] "+format, v...) 309 | l.writerMsg(skip, FATAL, msg) 310 | l.Close() 311 | os.Exit(1) 312 | } 313 | -------------------------------------------------------------------------------- /scripts/influxdb-sqlserver: -------------------------------------------------------------------------------- 1 | /var/log/influxdb-sqlserver/influxdb-sqlserver.log { 2 | daily 3 | rotate 7 4 | missingok 5 | dateext 6 | copytruncate 7 | compress 8 | } -------------------------------------------------------------------------------- /scripts/influxdb-sqlserver.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Collect Microsoft SQL Server metrics for reporting into InfluxDB 3 | After=network.target 4 | 5 | [Service] 6 | CPUShares=512 7 | MemoryLimit=128M 8 | Environment='STDOUT=/dev/null' 9 | Environment='STDERR=/var/log/influxdb-sqlserver/influxdb-sqlserver.log' 10 | ExecStart=/opt/influxdb-sqlserver/influxdb-sqlserver -config /etc/influxdb-sqlserver/influxdb-sqlserver.conf >> ${STDOUT} 2>> ${STDERR} 11 | KillMode=process 12 | Restart=on-failure 13 | 14 | [Install] 15 | WantedBy=multi-user.target 16 | Alias=influxdb-sqlserver.service -------------------------------------------------------------------------------- /scripts/init.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | # chkconfig: 2345 99 01 4 | # description: influxdb-sqlserver daemon 5 | 6 | ### BEGIN INIT INFO 7 | # Provides: influxdb-sqlserver 8 | # Required-Start: $all 9 | # Required-Stop: $remote_fs $syslog 10 | # Default-Start: 2 3 4 5 11 | # Default-Stop: 0 1 6 12 | # Short-Description: Start influxdb-sqlserver at boot time 13 | ### END INIT INFO 14 | 15 | # this init script supports three different variations: 16 | # 1. New lsb that define start-stop-daemon 17 | # 2. Old lsb that don't have start-stop-daemon but define, log, pidofproc and killproc 18 | # 3. Centos installations without lsb-core installed 19 | # 20 | # In the third case we have to define our own functions which are very dumb 21 | # and expect the args to be positioned correctly. 22 | 23 | # Command-line options that can be set in /etc/default/influxdb-sqlserver. These will override 24 | # any config file values. 25 | influxdb_sqlserver_OPTS= 26 | USER=influxdb-sqlserver 27 | GROUP=influxdb-sqlserver 28 | 29 | if [ -r /lib/lsb/init-functions ]; then 30 | source /lib/lsb/init-functions 31 | fi 32 | 33 | DEFAULT=/etc/default/influxdb-sqlserver 34 | 35 | if [ -r $DEFAULT ]; then 36 | source $DEFAULT 37 | fi 38 | 39 | if [ -z "$STDOUT" ]; then 40 | STDOUT=/dev/null 41 | fi 42 | if [ ! -f "$STDOUT" ]; then 43 | mkdir -p `dirname $STDOUT` 44 | fi 45 | 46 | if [ -z "$STDERR" ]; then 47 | STDERR=/var/log/influxdb-sqlserver/influxdb-sqlserver.log 48 | fi 49 | if [ ! -f "$STDERR" ]; then 50 | mkdir -p `dirname $STDERR` 51 | fi 52 | 53 | 54 | OPEN_FILE_LIMIT=65536 55 | 56 | function pidofproc() { 57 | if [ $# -ne 3 ]; then 58 | echo "Expected three arguments, e.g. $0 -p pidfile daemon-name" 59 | fi 60 | 61 | if [ ! -f "$2" ]; then 62 | return 1 63 | fi 64 | 65 | local pidfile=`cat $2` 66 | 67 | if [ "x$pidfile" == "x" ]; then 68 | return 1 69 | fi 70 | 71 | if ps --pid "$pidfile" | grep -q $(basename $3); then 72 | return 0 73 | fi 74 | 75 | return 1 76 | } 77 | 78 | function killproc() { 79 | if [ $# -ne 3 ]; then 80 | echo "Expected three arguments, e.g. $0 -p pidfile signal" 81 | fi 82 | 83 | pid=`cat $2` 84 | 85 | kill -s $3 $pid 86 | } 87 | 88 | function log_failure_msg() { 89 | echo "$@" "[ FAILED ]" 90 | } 91 | 92 | function log_success_msg() { 93 | echo "$@" "[ OK ]" 94 | } 95 | 96 | # Process name ( For display ) 97 | name=influxdb-sqlserver 98 | 99 | # Daemon name, where is the actual executable 100 | daemon=/opt/influxdb-sqlserver/influxdb-sqlserver 101 | 102 | # pid file for the daemon 103 | pidfile=/var/run/influxdb-sqlserver/influxdb-sqlserver.pid 104 | piddir='dirname $pidfile' 105 | 106 | if [ ! -d "$piddir" ]; then 107 | mkdir -p $piddir 108 | chown $GROUP:$USER $piddir 109 | fi 110 | 111 | # Configuration file 112 | config=/etc/influxdb-sqlserver/influxdb-sqlserver.conf 113 | confdir=/etc/influxdb-sqlserver/influxdb-sqlserver.d 114 | 115 | # If the daemon is not there, then exit. 116 | [ -x $daemon ] || exit 5 117 | 118 | case $1 in 119 | start) 120 | # Checked the PID file exists and check the actual status of process 121 | if [ -e $pidfile ]; then 122 | pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?" 123 | # If the status is SUCCESS then don't need to start again. 124 | if [ "x$status" = "x0" ]; then 125 | log_failure_msg "$name process is running" 126 | exit 0 # Exit 127 | fi 128 | fi 129 | 130 | # Bump the file limits, before launching the daemon. These will carry over to 131 | # launched processes. 132 | ulimit -n $OPEN_FILE_LIMIT 133 | if [ $? -ne 0 ]; then 134 | log_failure_msg "set open file limit to $OPEN_FILE_LIMIT" 135 | fi 136 | 137 | log_success_msg "Starting the process" "$name" 138 | if which start-stop-daemon > /dev/null 2>&1; then 139 | start-stop-daemon --chuid $GROUP:$USER --start --quiet --pidfile $pidfile --exec $daemon -- -pidfile $pidfile -config $config -configdirectory $confdir $influxdb_sqlserver_OPTS >>$STDOUT 2>>$STDERR & 140 | else 141 | nohup $daemon -pidfile $pidfile -config $config -configdirectory $confdir $influxdb_sqlserver_OPTS >>$STDOUT 2>>$STDERR & 142 | fi 143 | log_success_msg "$name process was started" 144 | ;; 145 | 146 | stop) 147 | # Stop the daemon. 148 | if [ -e $pidfile ]; then 149 | pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?" 150 | if [ "$status" = 0 ]; then 151 | if killproc -p $pidfile SIGTERM && /bin/rm -rf $pidfile; then 152 | log_success_msg "$name process was stopped" 153 | else 154 | log_failure_msg "$name failed to stop service" 155 | fi 156 | fi 157 | else 158 | log_failure_msg "$name process is not running" 159 | fi 160 | ;; 161 | 162 | restart) 163 | # Restart the daemon. 164 | $0 stop && sleep 2 && $0 start 165 | ;; 166 | 167 | status) 168 | # Check the status of the process. 169 | if [ -e $pidfile ]; then 170 | if pidofproc -p $pidfile $daemon > /dev/null; then 171 | log_success_msg "$name Process is running" 172 | exit 0 173 | else 174 | log_failure_msg "$name Process is not running" 175 | exit 1 176 | fi 177 | else 178 | log_failure_msg "$name Process is not running" 179 | exit 3 180 | fi 181 | ;; 182 | 183 | version) 184 | $daemon version 185 | ;; 186 | 187 | *) 188 | # For invalid arguments, print the usage message. 189 | echo "Usage: $0 {start|stop|restart|status|version}" 190 | exit 2 191 | ;; 192 | esac -------------------------------------------------------------------------------- /sqlscripts/getcpu.sql: -------------------------------------------------------------------------------- 1 | SET NOCOUNT ON; 2 | SET ARITHABORT ON; 3 | SET QUOTED_IDENTIFIER ON; 4 | SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED 5 | 6 | DECLARE @ms_ticks bigint; 7 | SET @ms_ticks = (Select ms_ticks From sys.dm_os_sys_info); 8 | DECLARE @maxEvents int = 1 9 | 10 | SELECT 11 | -- measurement 12 | 'CPU' 13 | -- tags 14 | + ',servername=' + REPLACE(@@SERVERNAME, '\', ':') + '' 15 | + ',type=CPU' 16 | -- value 17 | + ' SQLProcessUtilization=' + CAST(ProcessUtilization as varchar(8)) 18 | + ',ExternalProcessUtilization=' + CAST(100 - SystemIdle - ProcessUtilization as varchar(8)) 19 | + ',SystemIdle=' + CAST( SystemIdle as varchar(8)) 20 | --+ ' ' + CAST(DATEDIFF(SECOND,{d '1970-01-01'}, EventTime) as varchar(32)) 21 | FROM 22 | ( 23 | Select Top (@maxEvents) 24 | EventTime = CAST(DateAdd(ms, -1 * (@ms_ticks - timestamp_ms), GetUTCDate()) as datetime) 25 | , ProcessUtilization = CAST(ProcessUtilization as int) 26 | , SystemIdle = CAST(SystemIdle as int) 27 | From (Select Record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') as SystemIdle, 28 | Record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') as ProcessUtilization, 29 | timestamp as timestamp_ms 30 | From (Select timestamp, convert(xml, record) As Record 31 | From sys.dm_os_ring_buffers 32 | Where ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR' 33 | And record Like '%%') x) y 34 | Order By timestamp_ms Desc 35 | ) as T; 36 | -------------------------------------------------------------------------------- /sqlscripts/getdatabaseio.sql: -------------------------------------------------------------------------------- 1 | SET NOCOUNT ON; 2 | SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED 3 | DECLARE @secondsBetween tinyint = 5; 4 | DECLARE @delayInterval char(8) = CONVERT(Char(8), DATEADD(SECOND, @secondsBetween, '00:00:00'), 108); 5 | 6 | IF OBJECT_ID('tempdb..#baseline') IS NOT NULL 7 | DROP TABLE #baseline; 8 | IF OBJECT_ID('tempdb..#baselinewritten') IS NOT NULL 9 | DROP TABLE #baselinewritten; 10 | 11 | SELECT DB_NAME(mf.database_id) AS databaseName , 12 | mf.physical_name , 13 | divfs.num_of_reads , 14 | divfs.num_of_bytes_read , 15 | divfs.io_stall_read_ms , 16 | divfs.num_of_writes , 17 | divfs.num_of_bytes_written , 18 | divfs.io_stall_write_ms , 19 | divfs.io_stall , 20 | size_on_disk_bytes , 21 | GETDATE() AS baselineDate 22 | INTO #baseline 23 | FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS divfs 24 | INNER JOIN sys.master_files AS mf ON mf.database_id = divfs.database_id 25 | AND mf.file_id = divfs.file_id 26 | 27 | WAITFOR DELAY @delayInterval; 28 | 29 | ;WITH currentLine AS 30 | ( 31 | SELECT DB_NAME(mf.database_id) AS databaseName , 32 | mf.physical_name , 33 | type_desc, 34 | num_of_reads , 35 | num_of_bytes_read , 36 | io_stall_read_ms , 37 | num_of_writes , 38 | num_of_bytes_written , 39 | io_stall_write_ms , 40 | io_stall , 41 | size_on_disk_bytes , 42 | GETDATE() AS currentlineDate 43 | FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS divfs 44 | INNER JOIN sys.master_files AS mf ON mf.database_id = divfs.database_id 45 | AND mf.file_id = divfs.file_id 46 | ) 47 | 48 | SELECT database_name 49 | , datafile_type 50 | , num_of_bytes_read_persec = SUM(num_of_bytes_read_persec) 51 | , num_of_bytes_written_persec = SUM(num_of_bytes_written_persec) 52 | INTO #baselinewritten 53 | FROM 54 | ( 55 | SELECT 56 | database_name = currentLine.databaseName 57 | , datafile_type = type_desc 58 | , num_of_bytes_read_persec = (currentLine.num_of_bytes_read - T1.num_of_bytes_read) / (1 * DATEDIFF(SECOND,baseLineDate,currentLineDate)) 59 | , num_of_bytes_written_persec = (currentLine.num_of_bytes_written - T1.num_of_bytes_written) / (1 * DATEDIFF(SECOND,baseLineDate,currentLineDate)) 60 | FROM currentLine 61 | INNER JOIN #baseline T1 ON T1.databaseName = currentLine.databaseName 62 | AND T1.physical_name = currentLine.physical_name 63 | ) as T 64 | GROUP BY database_name, datafile_type 65 | 66 | 67 | DECLARE @DynamicPivotQuery AS NVARCHAR(MAX) 68 | DECLARE @ColumnName AS NVARCHAR(MAX), @ColumnName2 AS NVARCHAR(MAX) 69 | 70 | SELECT @ColumnName= ISNULL(@ColumnName + ',','') + QUOTENAME(database_name) 71 | FROM (SELECT DISTINCT database_name FROM #baselinewritten) AS bl 72 | SELECT @ColumnName2= ISNULL(@ColumnName2+ '+','') + ''',' + database_name + '=''' + + ' + CAST(' + QUOTENAME(database_name) + ' as varchar(16))' 73 | FROM (SELECT DISTINCT database_name FROM #baselinewritten) AS bl 74 | 75 | --Prepare the PIVOT query using the dynamic 76 | SET @DynamicPivotQuery = N' 77 | SELECT ''DatabaseIO'' + '',servername='' + REPLACE(@@SERVERNAME, ''\'', '':'') + '''' + '',type=DatabaseLogBytesWritten'' 78 | + '' '' + ' + STUFF(@ColumnName2, 1, 2, '''') + ' FROM 79 | ( 80 | SELECT database_name, num_of_bytes_written_persec 81 | FROM #baselinewritten 82 | WHERE datafile_type = ''LOG'' 83 | ) as V 84 | PIVOT(SUM(num_of_bytes_written_persec) FOR database_name IN (' + @ColumnName + ')) AS PVTTable 85 | 86 | UNION ALL 87 | 88 | SELECT ''DatabaseIO'' + '',servername='' + REPLACE(@@SERVERNAME, ''\'', '':'') + '''' + '',type=DatabaseRowsBytesWritten'' 89 | + '' '' + ' + STUFF(@ColumnName2, 1, 2, '''') + ' FROM 90 | ( 91 | SELECT database_name, num_of_bytes_written_persec 92 | FROM #baselinewritten 93 | WHERE datafile_type = ''ROWS'' 94 | ) as V 95 | PIVOT(SUM(num_of_bytes_written_persec) FOR database_name IN (' + @ColumnName + ')) AS PVTTable 96 | 97 | UNION ALL 98 | 99 | SELECT ''DatabaseIO'' + '',servername='' + REPLACE(@@SERVERNAME, ''\'', '':'') + '''' + '',type=DatabaseLogBytesRead'' 100 | + '' '' + ' + STUFF(@ColumnName2, 1, 2, '''') + ' FROM 101 | ( 102 | SELECT database_name, num_of_bytes_read_persec 103 | FROM #baselinewritten 104 | WHERE datafile_type = ''LOG'' 105 | ) as V 106 | PIVOT(SUM(num_of_bytes_read_persec) FOR database_name IN (' + @ColumnName + ')) AS PVTTable 107 | 108 | UNION ALL 109 | 110 | SELECT ''DatabaseIO'' + '',servername='' + REPLACE(@@SERVERNAME, ''\'', '':'') + '''' + '',type=DatabaseRowsBytesRead'' 111 | + '' '' + ' + STUFF(@ColumnName2, 1, 2, '''') + ' FROM 112 | ( 113 | SELECT database_name, num_of_bytes_read_persec 114 | FROM #baselinewritten 115 | WHERE datafile_type = ''ROWS'' 116 | ) as V 117 | PIVOT(SUM(num_of_bytes_read_persec) FOR database_name IN (' + @ColumnName + ')) AS PVTTable 118 | ' 119 | --PRINT @DynamicPivotQuery 120 | EXEC sp_executesql @DynamicPivotQuery; 121 | -------------------------------------------------------------------------------- /sqlscripts/getdatabasesizetrend.sql: -------------------------------------------------------------------------------- 1 | SET NOCOUNT ON; 2 | SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED 3 | IF OBJECT_ID('tempdb..#baseline') IS NOT NULL 4 | DROP TABLE #baseline; 5 | SELECT 6 | DB_NAME(mf.database_id) AS database_name , 7 | mf.physical_name , 8 | divfs.num_of_reads , 9 | divfs.num_of_bytes_read , 10 | divfs.io_stall_read_ms , 11 | divfs.num_of_writes , 12 | divfs.num_of_bytes_written , 13 | divfs.io_stall_write_ms , 14 | divfs.io_stall , 15 | size_on_disk_bytes , 16 | type_desc as datafile_type, 17 | GETDATE() AS baselineDate 18 | INTO #baseline 19 | FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS divfs 20 | INNER JOIN sys.master_files AS mf ON mf.database_id = divfs.database_id 21 | AND mf.file_id = divfs.file_id 22 | 23 | DECLARE @DynamicPivotQuery AS NVARCHAR(MAX) 24 | DECLARE @ColumnName AS NVARCHAR(MAX), @ColumnName2 AS NVARCHAR(MAX) 25 | 26 | SELECT @ColumnName= ISNULL(@ColumnName + ',','') + QUOTENAME(database_name) 27 | FROM (SELECT DISTINCT database_name FROM #baseline) AS bl 28 | SELECT @ColumnName2= ISNULL(@ColumnName2+ '+','') + ''',' + database_name + '=''' + + ' + CAST(' + QUOTENAME(database_name) + ' as varchar(16))' 29 | FROM (SELECT DISTINCT database_name FROM #baseline) AS bl 30 | 31 | --Prepare the PIVOT query using the dynamic 32 | SET @DynamicPivotQuery = N' 33 | SELECT ''DatabaseSizeTrend'' + '',servername='' + REPLACE(@@SERVERNAME, ''\'', '':'') + '''' + '',type=DatabaseLogSizeTrend'' 34 | + '' '' + ' + STUFF(@ColumnName2, 1, 2, '''') + ' FROM 35 | ( 36 | SELECT database_name, size_on_disk_bytes 37 | FROM #baseline 38 | WHERE datafile_type = ''LOG'' 39 | ) as V 40 | PIVOT(SUM(size_on_disk_bytes) FOR database_name IN (' + @ColumnName + ')) AS PVTTable 41 | 42 | UNION ALL 43 | 44 | SELECT ''DatabaseSizeTrend'' + '',servername='' + REPLACE(@@SERVERNAME, ''\'', '':'') + '''' + '',type=DatabaseRowsSizeTrend'' 45 | + '' '' + ' + STUFF(@ColumnName2, 1, 2, '''') + ' FROM 46 | ( 47 | SELECT database_name, size_on_disk_bytes 48 | FROM #baseline 49 | WHERE datafile_type = ''ROWS'' 50 | ) as V 51 | PIVOT(SUM(size_on_disk_bytes) FOR database_name IN (' + @ColumnName + ')) AS PVTTable 52 | ' 53 | --PRINT @DynamicPivotQuery 54 | EXEC sp_executesql @DynamicPivotQuery; 55 | -------------------------------------------------------------------------------- /sqlscripts/getmemory.sql: -------------------------------------------------------------------------------- 1 | SET NOCOUNT ON; 2 | SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; 3 | SELECT 4 | -- measurement 5 | 'PhysicalMemory' 6 | -- tags 7 | + ',servername=' + REPLACE(@@SERVERNAME, '\', ':') + '' 8 | + ',type=Memory' 9 | -- value 10 | + ' TotalMemory=' + CAST(TotalMemory as varchar(16)) 11 | + ',AvailableMemory=' + CAST(AvailableMemory as varchar(16)) 12 | FROM 13 | ( 14 | SELECT 15 | TotalMemory = total_physical_memory_kb * 1024 16 | , AvailableMemory = available_physical_memory_kb * 1024 17 | FROM sys.dm_os_sys_memory 18 | ) as T; -------------------------------------------------------------------------------- /sqlscripts/getmemoryclerksplit.sql: -------------------------------------------------------------------------------- 1 | SET NOCOUNT ON; 2 | SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; 3 | DECLARE @sqlVers numeric(4,2) 4 | SELECT @sqlVers = LEFT(CAST(SERVERPROPERTY('productversion') as varchar), 4) 5 | IF OBJECT_ID('tempdb..#MemoryClerk') IS NOT NULL 6 | DROP TABLE #MemoryClerk; 7 | CREATE TABLE #MemoryClerk ( 8 | ClerkCategory nvarchar(64) NOT NULL, 9 | UsedPercent decimal(9,2) NOT NULL, 10 | UsedBytes bigint NOT NULL 11 | ); 12 | DECLARE @DynamicClerkQuery AS NVARCHAR(MAX) 13 | IF @sqlVers < 11 14 | BEGIN 15 | SET @DynamicClerkQuery = N' 16 | INSERT #MemoryClerk (ClerkCategory, UsedPercent, UsedBytes) 17 | SELECT ClerkCategory 18 | , UsedPercent = SUM(UsedPercent) 19 | , UsedBytes = SUM(UsedBytes) 20 | FROM 21 | ( 22 | SELECT ClerkCategory = CASE MC.[type] 23 | WHEN ''MEMORYCLERK_SQLBUFFERPOOL'' THEN ''Buffer pool'' 24 | WHEN ''CACHESTORE_SQLCP'' THEN ''Cache (sql plans)'' 25 | WHEN ''CACHESTORE_OBJCP'' THEN ''Cache (objects)'' 26 | ELSE ''Other'' END 27 | , SUM((single_pages_kb + multi_pages_kb) * 1024) AS UsedBytes 28 | , Cast(100 * Sum((single_pages_kb + multi_pages_kb))*1.0/(Select Sum((single_pages_kb + multi_pages_kb)) From sys.dm_os_memory_clerks) as Decimal(7, 4)) UsedPercent 29 | FROM sys.dm_os_memory_clerks MC 30 | WHERE (single_pages_kb + multi_pages_kb) > 0 31 | GROUP BY CASE MC.[type] 32 | WHEN ''MEMORYCLERK_SQLBUFFERPOOL'' THEN ''Buffer pool'' 33 | WHEN ''CACHESTORE_SQLCP'' THEN ''Cache (sql plans)'' 34 | WHEN ''CACHESTORE_OBJCP'' THEN ''Cache (objects)'' 35 | ELSE ''Other'' END 36 | ) as T 37 | GROUP BY ClerkCategory;' 38 | END 39 | ELSE 40 | BEGIN 41 | SET @DynamicClerkQuery = N' 42 | INSERT #MemoryClerk (ClerkCategory, UsedPercent, UsedBytes) 43 | SELECT ClerkCategory 44 | , UsedPercent = SUM(UsedPercent) 45 | , UsedBytes = SUM(UsedBytes) 46 | FROM 47 | ( 48 | SELECT ClerkCategory = CASE MC.[type] 49 | WHEN ''MEMORYCLERK_SQLBUFFERPOOL'' THEN ''Buffer pool'' 50 | WHEN ''CACHESTORE_SQLCP'' THEN ''Cache (sql plans)'' 51 | WHEN ''CACHESTORE_OBJCP'' THEN ''Cache (objects)'' 52 | ELSE ''Other'' END 53 | , SUM(pages_kb * 1024) AS UsedBytes 54 | , Cast(100 * Sum(pages_kb)*1.0/(Select Sum(pages_kb) From sys.dm_os_memory_clerks) as Decimal(7, 4)) UsedPercent 55 | FROM sys.dm_os_memory_clerks MC 56 | WHERE pages_kb > 0 57 | GROUP BY CASE MC.[type] 58 | WHEN ''MEMORYCLERK_SQLBUFFERPOOL'' THEN ''Buffer pool'' 59 | WHEN ''CACHESTORE_SQLCP'' THEN ''Cache (sql plans)'' 60 | WHEN ''CACHESTORE_OBJCP'' THEN ''Cache (objects)'' 61 | ELSE ''Other'' END 62 | ) as T 63 | GROUP BY ClerkCategory;' 64 | END 65 | EXEC sp_executesql @DynamicClerkQuery; 66 | 67 | SELECT 68 | -- measurement 69 | Measurement 70 | -- tags 71 | + ',servername=' + REPLACE(@@SERVERNAME, '\', ':') + '' 72 | + ',type=MemoryClerk' 73 | -- value 74 | + ' BufferPool=' + [Buffer Pool] 75 | + ',Cache(objects)=' + [Cache (objects)] 76 | + ',Cache(sqlplans)=' + [Cache (sql plans)] 77 | + ',Other=' + [Other] 78 | FROM 79 | ( 80 | SELECT Measurement = 'UsedPercent' 81 | , [Buffer Pool] = CAST(ISNULL(ROUND([Buffer Pool], 1), 0) as varchar(16)) 82 | , [Cache (objects)] = CAST(ISNULL(ROUND([Cache (objects)], 1), 0) as varchar(16)) 83 | , [Cache (sql plans)] = CAST(ISNULL(ROUND([Cache (sql plans)], 1), 0) as varchar(16)) 84 | , [Other] = CAST(ISNULL(ROUND([Other], 1), 0) as varchar(16)) 85 | FROM (SELECT ClerkCategory, UsedPercent FROM #MemoryClerk) as G1 86 | PIVOT 87 | ( 88 | SUM(UsedPercent) 89 | FOR ClerkCategory IN ([Buffer Pool], [Cache (objects)], [Cache (sql plans)], [Other]) 90 | ) AS PivotTable 91 | 92 | UNION ALL 93 | 94 | SELECT 'UsedBytes' 95 | , [Buffer Pool] = CAST(ISNULL(ROUND([Buffer Pool], 1), 0) as varchar(16)) 96 | , [Cache (objects)] = CAST(ISNULL(ROUND([Cache (objects)], 1), 0) as varchar(16)) 97 | , [Cache (sql plans)] = CAST(ISNULL(ROUND([Cache (sql plans)], 1), 0) as varchar(16)) 98 | , [Other] = CAST(ISNULL(ROUND([Other], 1), 0) as varchar(16)) 99 | FROM (SELECT ClerkCategory, UsedBytes FROM #MemoryClerk) as G2 100 | PIVOT 101 | ( 102 | SUM(UsedBytes) 103 | FOR ClerkCategory IN ([Buffer Pool], [Cache (objects)], [Cache (sql plans)], [Other]) 104 | ) AS PivotTable 105 | ) as T 106 | 107 | IF OBJECT_ID('tempdb..#MemoryClerk') IS NOT NULL 108 | DROP TABLE #MemoryClerk; 109 | -------------------------------------------------------------------------------- /sqlscripts/getperfcounters.sql: -------------------------------------------------------------------------------- 1 | SET NOCOUNT ON; 2 | SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; 3 | 4 | IF OBJECT_ID('tempdb..#PCounters') IS NOT NULL DROP TABLE #PCounters 5 | CREATE TABLE #PCounters 6 | ( 7 | object_name nvarchar(128), 8 | counter_name nvarchar(128), 9 | instance_name nvarchar(128), 10 | cntr_value bigint, 11 | cntr_type INT, 12 | Primary Key(object_name, counter_name, instance_name) 13 | ); 14 | INSERT #PCounters 15 | SELECT RTrim(spi.object_name) object_name 16 | , RTrim(spi.counter_name) counter_name 17 | , RTrim(spi.instance_name) instance_name 18 | , spi.cntr_value 19 | , spi.cntr_type 20 | FROM sys.dm_os_performance_counters spi 21 | WHERE spi.object_name NOT LIKE 'SQLServer:Backup Device%' 22 | AND NOT EXISTS (SELECT 1 FROM sys.databases WHERE Name = spi.instance_name); 23 | 24 | WAITFOR DELAY '00:00:01'; 25 | 26 | IF OBJECT_ID('tempdb..#CCounters') IS NOT NULL DROP TABLE #CCounters 27 | CREATE TABLE #CCounters 28 | ( 29 | object_name nvarchar(128), 30 | counter_name nvarchar(128), 31 | instance_name nvarchar(128), 32 | cntr_value bigint, 33 | cntr_type INT, 34 | Primary Key(object_name, counter_name, instance_name) 35 | ); 36 | INSERT #CCounters 37 | SELECT RTrim(spi.object_name) object_name 38 | , RTrim(spi.counter_name) counter_name 39 | , RTrim(spi.instance_name) instance_name 40 | , spi.cntr_value 41 | , spi.cntr_type 42 | FROM sys.dm_os_performance_counters spi 43 | WHERE spi.object_name NOT LIKE 'SQLServer:Backup Device%' 44 | AND NOT EXISTS (SELECT 1 FROM sys.databases WHERE Name = spi.instance_name); 45 | 46 | 47 | -- [,=...] =[,=...] [unix-nano-timestamp] 48 | 49 | 50 | SELECT 51 | -- measurement 52 | result = REPLACE(cc.counter_name + CASE WHEN LEN(cc.instance_name) > 0 THEN ' | ' + REPLACE(cc.instance_name, ' ', '\ ') ELSE '' END , ' ', '\ ') 53 | -- tags 54 | + ',servername=' + REPLACE(@@SERVERNAME, '\', ':') + '' 55 | + ',objectname="' + REPLACE(cc.object_name, ' ', '') + '"' 56 | -- value 57 | + ' value=' + CAST(CAST(Case cc.cntr_type 58 | When 65792 Then cc.cntr_value -- Count 59 | When 537003264 Then IsNull(Cast(cc.cntr_value as Money) / NullIf(cbc.cntr_value, 0), 0) -- Ratio 60 | When 272696576 Then cc.cntr_value - pc.cntr_value -- Per Second 61 | When 1073874176 Then IsNull(Cast(cc.cntr_value - pc.cntr_value as Money) / NullIf(cbc.cntr_value - pbc.cntr_value, 0), 0) -- Avg 62 | When 1073939712 Then cc.cntr_value - pc.cntr_value -- Base 63 | Else cc.cntr_value End as bigint) as varchar(19)) 64 | --+ ' ' + CAST(DATEDIFF(SECOND,{d '1970-01-01'}, GETDATE()) as varchar(32)) + '000000000' 65 | FROM #CCounters cc 66 | INNER JOIN #PCounters pc On cc.object_name = pc.object_name 67 | And cc.counter_name = pc.counter_name 68 | And cc.instance_name = pc.instance_name 69 | And cc.cntr_type = pc.cntr_type 70 | LEFT JOIN #CCounters cbc On cc.object_name = cbc.object_name 71 | And (Case When cc.counter_name Like '%(ms)' Then Replace(cc.counter_name, ' (ms)',' Base') 72 | When cc.object_name = 'SQLServer:FileTable' Then Replace(cc.counter_name, 'Avg ','') + ' base' 73 | When cc.counter_name = 'Worktables From Cache Ratio' Then 'Worktables From Cache Base' 74 | When cc.counter_name = 'Avg. Length of Batched Writes' Then 'Avg. Length of Batched Writes BS' 75 | Else cc.counter_name + ' base' 76 | End) = cbc.counter_name 77 | And cc.instance_name = cbc.instance_name 78 | And cc.cntr_type In (537003264, 1073874176) 79 | And cbc.cntr_type = 1073939712 80 | LEFT JOIN #PCounters pbc On pc.object_name = pbc.object_name 81 | And pc.instance_name = pbc.instance_name 82 | And (Case When pc.counter_name Like '%(ms)' Then Replace(pc.counter_name, ' (ms)',' Base') 83 | When pc.object_name = 'SQLServer:FileTable' Then Replace(pc.counter_name, 'Avg ','') + ' base' 84 | When pc.counter_name = 'Worktables From Cache Ratio' Then 'Worktables From Cache Base' 85 | When pc.counter_name = 'Avg. Length of Batched Writes' Then 'Avg. Length of Batched Writes BS' 86 | Else pc.counter_name + ' base' 87 | End) = pbc.counter_name 88 | And pc.cntr_type In (537003264, 1073874176) 89 | And pbc.cntr_type = 1073939712 90 | --WHERE cc.counter_name LIKE 'Batch Requests/sec' 91 | ORDER BY 1 92 | IF OBJECT_ID('tempdb..#CCounters') IS NOT NULL DROP TABLE #CCounters; 93 | IF OBJECT_ID('tempdb..#PCounters') IS NOT NULL DROP TABLE #PCounters; 94 | 95 | -------------------------------------------------------------------------------- /sqlscripts/getperfmetrics.sql: -------------------------------------------------------------------------------- 1 | SET NOCOUNT ON; 2 | SET ARITHABORT ON; 3 | SET QUOTED_IDENTIFIER ON; 4 | SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED 5 | 6 | DECLARE @PCounters TABLE( 7 | counter_name nvarchar(64), 8 | cntr_value bigint, 9 | Primary Key(counter_name) 10 | ); 11 | INSERT @PCounters (counter_name, cntr_value) 12 | SELECT 'PageFileUsagePercent', CAST(100 * (1 - available_page_file_kb * 1. / total_page_file_kb) as decimal(9,2)) as PageFileUsagePercent 13 | FROM sys.dm_os_sys_memory 14 | UNION ALL 15 | SELECT 'ConnectionMemoryBytesPerUserConnection', Ratio = CAST((cntr_value / (SELECT 1.0 * cntr_value FROM sys.dm_os_performance_counters WHERE counter_name = 'User Connections')) * 1024 as int) 16 | FROM sys.dm_os_performance_counters 17 | WHERE counter_name = 'Connection Memory (KB)' 18 | UNION ALL 19 | SELECT 'AvailablePhysicalMemoryInBytes', available_physical_memory_kb * 1024 20 | FROM sys.dm_os_sys_memory 21 | UNION ALL 22 | SELECT 'SignalWaitPercent', SignalWaitPercent = CAST(100.0 * SUM(signal_wait_time_ms) / SUM (wait_time_ms) AS NUMERIC(20,2)) 23 | FROM sys.dm_os_wait_stats 24 | UNION ALL 25 | SELECT 'SqlCompilationPercent', SqlCompilationPercent = 100.0 * cntr_value / (SELECT 1.0*cntr_value FROM sys.dm_os_performance_counters WHERE counter_name = 'Batch Requests/sec') 26 | FROM sys.dm_os_performance_counters 27 | WHERE counter_name = 'SQL Compilations/sec' 28 | UNION ALL 29 | SELECT 'SqlReCompilationPercent', SqlReCompilationPercent = 100.0 *cntr_value / (SELECT 1.0*cntr_value FROM sys.dm_os_performance_counters WHERE counter_name = 'Batch Requests/sec') 30 | FROM sys.dm_os_performance_counters 31 | WHERE counter_name = 'SQL Re-Compilations/sec' 32 | UNION ALL 33 | SELECT 'PageLookupPercent',PageLookupPercent = 100.0 * cntr_value / (SELECT 1.0*cntr_value FROM sys.dm_os_performance_counters WHERE counter_name = 'Batch Requests/sec') 34 | FROM sys.dm_os_performance_counters 35 | WHERE counter_name = 'Page lookups/sec' 36 | UNION ALL 37 | SELECT 'PageSplitPercent',PageSplitPercent = 100.0 * cntr_value / (SELECT 1.0*cntr_value FROM sys.dm_os_performance_counters WHERE counter_name = 'Batch Requests/sec') 38 | FROM sys.dm_os_performance_counters 39 | WHERE counter_name = 'Page splits/sec' 40 | UNION ALL 41 | SELECT 'AverageTasks', AverageTaskCount = (SELECT AVG(current_tasks_count) FROM sys.dm_os_schedulers WITH (NOLOCK) WHERE scheduler_id < 255 ) 42 | UNION ALL 43 | SELECT 'AverageRunnableTasks', AverageRunnableTaskCount = (SELECT AVG(runnable_tasks_count) FROM sys.dm_os_schedulers WITH (NOLOCK) WHERE scheduler_id < 255 ) 44 | UNION ALL 45 | SELECT 'AveragePendingDiskIO', AveragePendingDiskIOCount = (SELECT AVG(pending_disk_io_count) FROM sys.dm_os_schedulers WITH (NOLOCK) WHERE scheduler_id < 255 ) 46 | UNION ALL 47 | SELECT 'BufferPoolRate', BufferPoolRate = (1.0*cntr_value * 8 * 1024) / 48 | (SELECT 1.0*cntr_value FROM sys.dm_os_performance_counters WHERE object_name like '%Buffer Manager%' AND lower(counter_name) = 'Page life expectancy') 49 | FROM sys.dm_os_performance_counters 50 | WHERE object_name like '%Buffer Manager%' 51 | AND counter_name = 'database pages' 52 | UNION ALL 53 | SELECT 'MemoryGrantPending', MemoryGrantPending = cntr_value 54 | FROM sys.dm_os_performance_counters 55 | WHERE counter_name = 'Memory Grants Pending' 56 | UNION ALL 57 | SELECT 'ReadaheadPercent', SqlReCompilationPercent = 100.0 *cntr_value / (SELECT 1.0*cntr_value FROM sys.dm_os_performance_counters WHERE counter_name = 'Page Reads/sec') 58 | FROM sys.dm_os_performance_counters 59 | WHERE counter_name = 'Readahead pages/sec' 60 | UNION ALL 61 | SELECT 'TotalTargetMemoryRatio', TotalTargetMemoryRatio = 100.0 * cntr_value / (SELECT 1.0*cntr_value FROM sys.dm_os_performance_counters WHERE counter_name = 'Target Server Memory (KB)') 62 | FROM sys.dm_os_performance_counters 63 | WHERE counter_name = 'Total Server Memory (KB)' 64 | 65 | 66 | IF OBJECT_ID('tempdb..#PCounters') IS NOT NULL DROP TABLE #PCounters; 67 | SELECT * INTO #PCounters FROM @PCounters 68 | 69 | DECLARE @DynamicPivotQuery AS NVARCHAR(MAX) 70 | DECLARE @ColumnName AS NVARCHAR(MAX), @ColumnName2 AS NVARCHAR(MAX) 71 | SELECT @ColumnName= ISNULL(@ColumnName + ',','') + QUOTENAME(counter_name) 72 | FROM (SELECT DISTINCT counter_name FROM @PCounters) AS bl 73 | SELECT @ColumnName2= ISNULL(@ColumnName2+ '+','') + ''',' + counter_name + '=''' + + ' + CAST(' + QUOTENAME(counter_name) + ' as varchar(16))' 74 | FROM (SELECT DISTINCT counter_name FROM @PCounters) AS bl 75 | 76 | SET @DynamicPivotQuery = N' 77 | SELECT ''PerformanceMetrics'' + '',servername='' + REPLACE(@@SERVERNAME, ''\'', '':'') + '''' + '',type=PerformanceMetrics'' 78 | + '' '' + ' + STUFF(@ColumnName2, 1, 2, '''') + ' FROM 79 | ( 80 | SELECT counter_name, cntr_value 81 | FROM #PCounters 82 | ) as V 83 | PIVOT(SUM(cntr_value) FOR counter_name IN (' + @ColumnName + ')) AS PVTTable 84 | ' 85 | EXEC sp_executesql @DynamicPivotQuery; 86 | -------------------------------------------------------------------------------- /sqlscripts/getwaitstats.sql: -------------------------------------------------------------------------------- 1 | SET NOCOUNT ON; 2 | SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED 3 | DECLARE @secondsBetween tinyint = 15 4 | DECLARE @delayInterval char(8) = CONVERT(Char(8), DATEADD(SECOND, @secondsBetween, '00:00:00'), 108); 5 | DECLARE @w1 TABLE 6 | ( 7 | WaitType varchar(64) NOT NULL, 8 | WaitTimeInMs bigint NOT NULL, 9 | WaitTaskCount bigint NOT NULL, 10 | CollectionDate datetime NOT NULL 11 | ) 12 | DECLARE @w2 TABLE 13 | ( 14 | WaitType varchar(64) NOT NULL, 15 | WaitTimeInMs bigint NOT NULL, 16 | WaitTaskCount bigint NOT NULL, 17 | CollectionDate datetime NOT NULL 18 | ) 19 | INSERT @w1 (WaitType, WaitTimeInMs, WaitTaskCount, CollectionDate) 20 | SELECT 21 | WaitType = wait_type 22 | , WaitTimeInMs = SUM(wait_time_ms) 23 | , WaitTaskCount = SUM(waiting_tasks_count) 24 | , CollectionDate = GETDATE() 25 | FROM sys.dm_os_wait_stats 26 | WHERE [wait_type] NOT IN ( 27 | N'QDS_SHUTDOWN_QUEUE', 28 | N'BROKER_EVENTHANDLER', N'BROKER_RECEIVE_WAITFOR', 29 | N'BROKER_TASK_STOP', N'BROKER_TO_FLUSH', 30 | N'BROKER_TRANSMITTER', N'CHECKPOINT_QUEUE', 31 | N'CHKPT', N'CLR_AUTO_EVENT', 32 | N'CLR_MANUAL_EVENT', N'CLR_SEMAPHORE', 33 | N'DBMIRROR_DBM_EVENT', N'DBMIRROR_EVENTS_QUEUE', 34 | N'DBMIRROR_WORKER_QUEUE', N'DBMIRRORING_CMD', 35 | N'DIRTY_PAGE_POLL', N'DISPATCHER_QUEUE_SEMAPHORE', 36 | N'EXECSYNC', N'FSAGENT', 37 | N'FT_IFTS_SCHEDULER_IDLE_WAIT', N'FT_IFTSHC_MUTEX', 38 | N'HADR_CLUSAPI_CALL', N'HADR_FILESTREAM_IOMGR_IOCOMPLETION', 39 | N'HADR_LOGCAPTURE_WAIT', N'HADR_NOTIFICATION_DEQUEUE', 40 | N'HADR_TIMER_TASK', N'HADR_WORK_QUEUE', 41 | N'KSOURCE_WAKEUP', N'LAZYWRITER_SLEEP', 42 | N'LOGMGR_QUEUE', N'ONDEMAND_TASK_QUEUE', 43 | N'PWAIT_ALL_COMPONENTS_INITIALIZED', 44 | N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', 45 | N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP', 46 | N'REQUEST_FOR_DEADLOCK_SEARCH', N'RESOURCE_QUEUE', 47 | N'SERVER_IDLE_CHECK', N'SLEEP_BPOOL_FLUSH', 48 | N'SLEEP_DBSTARTUP', N'SLEEP_DCOMSTARTUP', 49 | N'SLEEP_MASTERDBREADY', N'SLEEP_MASTERMDREADY', 50 | N'SLEEP_MASTERUPGRADED', N'SLEEP_MSDBSTARTUP', 51 | N'SLEEP_SYSTEMTASK', N'SLEEP_TASK', 52 | N'SLEEP_TEMPDBSTARTUP', N'SNI_HTTP_ACCEPT', 53 | N'SP_SERVER_DIAGNOSTICS_SLEEP', N'SQLTRACE_BUFFER_FLUSH', 54 | N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', 55 | N'SQLTRACE_WAIT_ENTRIES', N'WAIT_FOR_RESULTS', 56 | N'WAITFOR', N'WAITFOR_TASKSHUTDOWN', 57 | N'WAIT_XTP_HOST_WAIT', N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', 58 | N'WAIT_XTP_CKPT_CLOSE', N'XE_DISPATCHER_JOIN', 59 | N'XE_DISPATCHER_WAIT', N'XE_TIMER_EVENT') 60 | AND [waiting_tasks_count] > 0 61 | GROUP BY wait_type 62 | 63 | WAITFOR DELAY @delayInterval; 64 | 65 | INSERT @w2 (WaitType, WaitTimeInMs, WaitTaskCount, CollectionDate) 66 | SELECT 67 | WaitType = wait_type 68 | , WaitTimeInMs = SUM(wait_time_ms) 69 | , WaitTaskCount = SUM(waiting_tasks_count) 70 | , CollectionDate = GETDATE() 71 | FROM sys.dm_os_wait_stats 72 | WHERE [wait_type] NOT IN ( 73 | N'BROKER_EVENTHANDLER', N'BROKER_RECEIVE_WAITFOR', 74 | N'BROKER_TASK_STOP', N'BROKER_TO_FLUSH', 75 | N'BROKER_TRANSMITTER', N'CHECKPOINT_QUEUE', 76 | N'CHKPT', N'CLR_AUTO_EVENT', 77 | N'CLR_MANUAL_EVENT', N'CLR_SEMAPHORE', 78 | N'DBMIRROR_DBM_EVENT', N'DBMIRROR_EVENTS_QUEUE', 79 | N'DBMIRROR_WORKER_QUEUE', N'DBMIRRORING_CMD', 80 | N'DIRTY_PAGE_POLL', N'DISPATCHER_QUEUE_SEMAPHORE', 81 | N'EXECSYNC', N'FSAGENT', 82 | N'FT_IFTS_SCHEDULER_IDLE_WAIT', N'FT_IFTSHC_MUTEX', 83 | N'HADR_CLUSAPI_CALL', N'HADR_FILESTREAM_IOMGR_IOCOMPLETION', 84 | N'HADR_LOGCAPTURE_WAIT', N'HADR_NOTIFICATION_DEQUEUE', 85 | N'HADR_TIMER_TASK', N'HADR_WORK_QUEUE', 86 | N'KSOURCE_WAKEUP', N'LAZYWRITER_SLEEP', 87 | N'LOGMGR_QUEUE', N'ONDEMAND_TASK_QUEUE', 88 | N'PWAIT_ALL_COMPONENTS_INITIALIZED', 89 | N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', 90 | N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP', 91 | N'REQUEST_FOR_DEADLOCK_SEARCH', N'RESOURCE_QUEUE', 92 | N'SERVER_IDLE_CHECK', N'SLEEP_BPOOL_FLUSH', 93 | N'SLEEP_DBSTARTUP', N'SLEEP_DCOMSTARTUP', 94 | N'SLEEP_MASTERDBREADY', N'SLEEP_MASTERMDREADY', 95 | N'SLEEP_MASTERUPGRADED', N'SLEEP_MSDBSTARTUP', 96 | N'SLEEP_SYSTEMTASK', N'SLEEP_TASK', 97 | N'SLEEP_TEMPDBSTARTUP', N'SNI_HTTP_ACCEPT', 98 | N'SP_SERVER_DIAGNOSTICS_SLEEP', N'SQLTRACE_BUFFER_FLUSH', 99 | N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', 100 | N'SQLTRACE_WAIT_ENTRIES', N'WAIT_FOR_RESULTS', 101 | N'WAITFOR', N'WAITFOR_TASKSHUTDOWN', 102 | N'WAIT_XTP_HOST_WAIT', N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', 103 | N'WAIT_XTP_CKPT_CLOSE', N'XE_DISPATCHER_JOIN', 104 | N'XE_DISPATCHER_WAIT', N'XE_TIMER_EVENT') 105 | AND [waiting_tasks_count] > 0 106 | GROUP BY wait_type 107 | 108 | SELECT 109 | -- measurement 110 | T1.WaitType 111 | -- tags 112 | + ',servername=' + REPLACE(@@SERVERNAME, '\', ':') + '' 113 | + ',type=WaitStats' 114 | -- value 115 | + ' waittimeinms=' + CAST(T2.WaitTimeInMs - T1.WaitTimeInMs as varchar(16)) 116 | + ',waittaskcount=' + CAST(T2.WaitTaskCount - T1.WaitTaskCount as varchar(16)) 117 | + ',waittimeinmspersec=' + CAST((T2.WaitTimeInMs - T1.WaitTimeInMs) / CAST(DATEDIFF(SECOND, T1.CollectionDate, T2.CollectionDate) as float) as varchar(16)) 118 | FROM @w1 T1 119 | INNER JOIN @w2 T2 ON T2.WaitType = T1.WaitType 120 | WHERE T2.WaitTaskCount - T1.WaitTaskCount > 0; 121 | --------------------------------------------------------------------------------