diff --git a/Dockerfile b/Dockerfile index 9da26799..865ddf7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ FROM alpine:latest RUN apk --update upgrade && \ apk add curl ca-certificates && \ + apk add tzdata && \ update-ca-certificates && \ rm -rf /var/cache/apk/* diff --git a/go.mod b/go.mod index aaa1aa68..78316abf 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/justwatchcom/sql_exporter go 1.17 require ( - github.com/ClickHouse/clickhouse-go v1.5.2 + github.com/ClickHouse/clickhouse-go/v2 v2.0.14 github.com/cenkalti/backoff v2.2.1+incompatible github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73 github.com/go-kit/log v0.2.0 @@ -37,10 +37,8 @@ require ( github.com/aws/smithy-go v1.9.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect github.com/gabriel-vasile/mimetype v1.4.0 // indirect - github.com/go-kit/kit v0.12.0 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect github.com/golang/protobuf v1.5.2 // indirect @@ -50,15 +48,19 @@ require ( github.com/klauspost/compress v1.13.6 // indirect github.com/mattn/go-ieproxy v0.0.1 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/pierrec/lz4/v4 v4.1.11 // indirect + github.com/paulmach/orb v0.7.1 // indirect + github.com/pierrec/lz4/v4 v4.1.14 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/satori/go.uuid v1.2.0 // indirect + github.com/shopspring/decimal v1.3.1 // indirect github.com/sirupsen/logrus v1.8.1 // indirect + go.opentelemetry.io/otel v1.7.0 // indirect + go.opentelemetry.io/otel/trace v1.7.0 // indirect golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 // indirect - golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect + golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/protobuf v1.27.1 // indirect diff --git a/go.sum b/go.sum index f0471ae8..7c75c97c 100644 --- a/go.sum +++ b/go.sum @@ -49,8 +49,11 @@ github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUM github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ClickHouse/clickhouse-go v1.5.2 h1:yXgaOZ8WEHrd+okvZXjzulSt1zS33nM4ujfx9lVncl8= -github.com/ClickHouse/clickhouse-go v1.5.2/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= +github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0= +github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= +github.com/ClickHouse/clickhouse-go/v2 v2.0.14 h1:7HW+MXPaQfVyCzPGEn/LciMc8K6cG58FZMUc7DXQmro= +github.com/ClickHouse/clickhouse-go/v2 v2.0.14/go.mod h1:iq2DUGgpA4BBki2CVwrF8x43zqBjdgHtbexkFkh5a6M= +github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -98,7 +101,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bkaradzic/go-lz4 v1.0.0 h1:RXc4wYsyz985CkXXeX04y4VnZFGG8Rd43pRaHsOXAKk= github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= @@ -111,7 +113,6 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 h1:F1EaeKL/ta07PY/k9Os/UFtwERei2/XzGemhpGnBKNg= github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -145,8 +146,6 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= -github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.0 h1:7i2K3eKTos3Vc0enKCfnVcgHh2olr/MyfboYq7cAcFw= github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= @@ -156,11 +155,16 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= @@ -206,8 +210,9 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -225,6 +230,8 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -247,6 +254,7 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.13.1/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= @@ -271,6 +279,7 @@ github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRU github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mkevac/debugcharts v0.0.0-20191222103121-ae1c48aa8615/go.mod h1:Ad7oeElCZqA1Ufj0U9/liOF4BtVepxRcTvr2ey7zTvM= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -278,13 +287,18 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/paulmach/orb v0.5.0/go.mod h1:FWRlTgl88VI1RBx/MkrwWDRhQ96ctqMCh8boXhmqB/A= +github.com/paulmach/orb v0.7.1 h1:Zha++Z5OX/l168sqHK3k4z18LDvr+YAO/VjK0ReQ9rU= +github.com/paulmach/orb v0.7.1/go.mod h1:FWRlTgl88VI1RBx/MkrwWDRhQ96ctqMCh8boXhmqB/A= +github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4/v4 v4.1.8/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pierrec/lz4/v4 v4.1.11 h1:LVs17FAZJFOjgmJXl9Tf13WfLUvZq7/RjfEJrnwZ9OE= github.com/pierrec/lz4/v4 v4.1.11/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pierrec/lz4/v4 v4.1.14 h1:+fL8AQEZtz/ijeNnpduH0bROTu0O3NZAlPjQxGn8LwE= +github.com/pierrec/lz4/v4 v4.1.14/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -324,6 +338,11 @@ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/segmentio/go-athena v0.0.0-20181208004937-dfa5f1818930 h1:Tn2Ryh7e9oN9TK19Y0vP/1Rfr1/DqBxXC8qrWKS4ez8= github.com/segmentio/go-athena v0.0.0-20181208004937-dfa5f1818930/go.mod h1:umGD11uSGUY8Vd0lbo1jJUEAk4FxVV3YE5wRSXx1Lbk= +github.com/shirou/gopsutil v2.19.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= +github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= +github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= @@ -335,19 +354,369 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= +github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/vertica/vertica-sql-go v1.2.1 h1:VL8K3RJ021bCjLF45koxwQV66WUkuumRl7omewpvdUk= github.com/vertica/vertica-sql-go v1.2.1/go.mod h1:fGr44VWdEvL+f+Qt5LkKLOT7GoxaWdoUCnPBU9h6t04= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM= +go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= +go.opentelemetry.io/otel/trace v1.7.0 h1:O37Iogk1lEkMRXewVtZ1BBTVn5JEp8GrJvP92bJqC6o= +go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 h1:/pEO3GD/ABYAjuakUS6xSEmmlyVS4kxBNkeA9tLJiTI= golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 h1:QE6XYQK6naiK1EPAe1g/ILLxN5RBoH5xkJk3CqlMI/Y= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20210216034530-4410531fe030/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 h1:DZshvxDdVoeKIbudAdFEKi+f70l51luSy/7b76ibTY0= golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191220220014-0732a990476f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200828194041-157a740278f4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 h1:Js08h5hqB5xyWR789+QqueR6sDE8mk+YvpETZ+F6X9Y= +golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= +gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= +gonum.org/v1/gonum v0.9.3 h1:DnoIG+QAMaF5NvxnGe/oKsgKcAc6PcUyl8q0VetfQ8s= +gonum.org/v1/gonum v0.9.3/go.mod h1:TZumC3NeyVQskjXqmyWt4S3bINhy7B4eYwW69EbyX+0= +gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= +gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= +gonum.org/v1/plot v0.9.0/go.mod h1:3Pcqqmp6RHvJI72kgb8fThyUnav364FOsdDo2aGW5lY= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210630183607-d20f26d13c79/go.mod h1:yiaVoXHpRzHGyxV3o4DktVWY4mSUErTKaeEOq6C3t3U= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/job.go b/job.go index accb8bb5..4abe43cc 100644 --- a/job.go +++ b/job.go @@ -8,7 +8,7 @@ import ( "strings" "time" - _ "github.com/ClickHouse/clickhouse-go" // register the ClickHouse driver + _ "github.com/ClickHouse/clickhouse-go/v2" // register the ClickHouse driver "github.com/cenkalti/backoff" _ "github.com/denisenkom/go-mssqldb" // register the MS-SQL driver "github.com/go-kit/log" diff --git a/vendor/github.com/ClickHouse/clickhouse-go/.travis.yml b/vendor/github.com/ClickHouse/clickhouse-go/.travis.yml deleted file mode 100644 index 52b61d7c..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -sudo: required -language: go -go: - - 1.15.x - - 1.16.x -go_import_path: github.com/ClickHouse/clickhouse-go -services: - - docker -install: - - export GO111MODULE="on" - - go mod vendor - -before_install: - - docker --version - - docker-compose --version - - docker-compose up -d -script: - - ./go.test.sh -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/LICENSE b/vendor/github.com/ClickHouse/clickhouse-go/LICENSE deleted file mode 100644 index a860ed20..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017-2020 Kirill Shvakov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/ClickHouse/clickhouse-go/Makefile b/vendor/github.com/ClickHouse/clickhouse-go/Makefile deleted file mode 100644 index 813b3196..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -test: - go install -race -v - go test -i -v - go test -race -timeout 30s -v . - -coverage: - go test -coverprofile=coverage.out -v . - go tool cover -html=coverage.out diff --git a/vendor/github.com/ClickHouse/clickhouse-go/README.md b/vendor/github.com/ClickHouse/clickhouse-go/README.md deleted file mode 100644 index c4380130..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/README.md +++ /dev/null @@ -1,307 +0,0 @@ -# ClickHouse [![Build Status](https://travis-ci.org/ClickHouse/clickhouse-go.svg?branch=master)](https://travis-ci.org/ClickHouse/clickhouse-go) [![Go Report Card](https://goreportcard.com/badge/github.com/ClickHouse/clickhouse-go)](https://goreportcard.com/report/github.com/ClickHouse/clickhouse-go) [![codecov](https://codecov.io/gh/ClickHouse/clickhouse-go/branch/master/graph/badge.svg)](https://codecov.io/gh/ClickHouse/clickhouse-go) - -Golang SQL database driver for [Yandex ClickHouse](https://clickhouse.yandex/) - -## Key features - -* Uses native ClickHouse TCP client-server protocol -* Compatibility with `database/sql` -* Round Robin load-balancing -* Bulk write support : `begin->prepare->(in loop exec)->commit` -* LZ4 compression support (default is pure go lz4 or switch to use cgo lz4 by turning clz4 build tags on) -* External Tables support - -## DSN - -* username/password - auth credentials -* database - select the current default database -* read_timeout/write_timeout - timeout in second -* no_delay - disable/enable the Nagle Algorithm for tcp socket (default is 'true' - disable) -* alt_hosts - comma-separated list of single address hosts for load-balancing -* connection_open_strategy - random/in_order (default random). - * random - choose a random server from the set - * in_order - first live server is chosen in specified order - * time_random - choose random (based on the current time) server from the set. This option differs from `random` because randomness is based on the current time rather than on the number of previous connections. -* block_size - maximum rows in block (default is 1000000). If the rows are larger, the data will be split into several blocks to send to the server. If one block was sent to the server, the data would be persisted on the server disk, and we can't roll back the transaction. So always keep in mind that the batch size is no larger than the block_size if you want an atomic batch insert. -* pool_size - the maximum amount of preallocated byte chunks used in queries (default is 100). Decrease this if you experience memory problems at the expense of more GC pressure and vice versa. -* debug - enable debug output (boolean value) -* compress - enable lz4 compression (integer value, default is '0') -* check_connection_liveness - on supported platforms non-secure connections retrieved from the connection pool are checked in beginTx() for liveness before using them. If the check fails, the respective connection is marked as bad and the query retried with another connection. (boolean value, default is 'true') - -SSL/TLS parameters: - -* secure - establish secure connection (default is false) -* skip_verify - skip certificate verification (default is false) -* tls_config - name of a TLS config with client certificates, registered using `clickhouse.RegisterTLSConfig()`; implies secure to be true, unless explicitly specified - -Example: - -```sh -tcp://host1:9000?username=user&password=qwerty&database=clicks&read_timeout=10&write_timeout=20&alt_hosts=host2:9000,host3:9000 -``` - -## Supported data types - -* UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64 -* Float32, Float64 -* String -* FixedString(N) -* Date -* DateTime -* IPv4 -* IPv6 -* Enum -* UUID -* Nullable(T) -* [Array(T)](https://clickhouse.yandex/reference_en.html#Array(T)) [godoc](https://godoc.org/github.com/ClickHouse/clickhouse-go#Array) -* Array(Nullable(T)) -* Tuple(...T) - -## TODO - -* Support other compression methods(zstd ...) - -## Install - -```sh -go get -u github.com/ClickHouse/clickhouse-go -``` - -## Examples - -```go -package main - -import ( - "database/sql" - "fmt" - "log" - "time" - - "github.com/ClickHouse/clickhouse-go" -) - -func main() { - connect, err := sql.Open("clickhouse", "tcp://127.0.0.1:9000?debug=true") - if err != nil { - log.Fatal(err) - } - if err := connect.Ping(); err != nil { - if exception, ok := err.(*clickhouse.Exception); ok { - fmt.Printf("[%d] %s \n%s\n", exception.Code, exception.Message, exception.StackTrace) - } else { - fmt.Println(err) - } - return - } - - _, err = connect.Exec(` - CREATE TABLE IF NOT EXISTS example ( - country_code FixedString(2), - os_id UInt8, - browser_id UInt8, - categories Array(Int16), - action_day Date, - action_time DateTime - ) engine=Memory - `) - - if err != nil { - log.Fatal(err) - } - var ( - tx, _ = connect.Begin() - stmt, _ = tx.Prepare("INSERT INTO example (country_code, os_id, browser_id, categories, action_day, action_time) VALUES (?, ?, ?, ?, ?, ?)") - ) - defer stmt.Close() - - for i := 0; i < 100; i++ { - if _, err := stmt.Exec( - "RU", - 10+i, - 100+i, - clickhouse.Array([]int16{1, 2, 3}), - time.Now(), - time.Now(), - ); err != nil { - log.Fatal(err) - } - } - - if err := tx.Commit(); err != nil { - log.Fatal(err) - } - - rows, err := connect.Query("SELECT country_code, os_id, browser_id, categories, action_day, action_time FROM example") - if err != nil { - log.Fatal(err) - } - defer rows.Close() - - for rows.Next() { - var ( - country string - os, browser uint8 - categories []int16 - actionDay, actionTime time.Time - ) - if err := rows.Scan(&country, &os, &browser, &categories, &actionDay, &actionTime); err != nil { - log.Fatal(err) - } - log.Printf("country: %s, os: %d, browser: %d, categories: %v, action_day: %s, action_time: %s", country, os, browser, categories, actionDay, actionTime) - } - - if err := rows.Err(); err != nil { - log.Fatal(err) - } - - if _, err := connect.Exec("DROP TABLE example"); err != nil { - log.Fatal(err) - } -} -``` - -### Use [sqlx](https://github.com/jmoiron/sqlx) - -```go -package main - -import ( - "log" - "time" - - "github.com/jmoiron/sqlx" - _ "github.com/ClickHouse/clickhouse-go" -) - -func main() { - connect, err := sqlx.Open("clickhouse", "tcp://127.0.0.1:9000?debug=true") - if err != nil { - log.Fatal(err) - } - var items []struct { - CountryCode string `db:"country_code"` - OsID uint8 `db:"os_id"` - BrowserID uint8 `db:"browser_id"` - Categories []int16 `db:"categories"` - ActionTime time.Time `db:"action_time"` - } - - if err := connect.Select(&items, "SELECT country_code, os_id, browser_id, categories, action_time FROM example"); err != nil { - log.Fatal(err) - } - - for _, item := range items { - log.Printf("country: %s, os: %d, browser: %d, categories: %v, action_time: %s", item.CountryCode, item.OsID, item.BrowserID, item.Categories, item.ActionTime) - } -} -``` - -### External tables support - -```go -package main - -import ( - "database/sql" - "database/sql/driver" - "fmt" - "github.com/ClickHouse/clickhouse-go/lib/column" - "log" - "time" - - "github.com/ClickHouse/clickhouse-go" -) - -func main() { - connect, err := sql.Open("clickhouse", "tcp://127.0.0.1:9000?debug=true") - if err != nil { - log.Fatal(err) - } - if err := connect.Ping(); err != nil { - if exception, ok := err.(*clickhouse.Exception); ok { - fmt.Printf("[%d] %s \n%s\n", exception.Code, exception.Message, exception.StackTrace) - } else { - fmt.Println(err) - } - return - } - - _, err = connect.Exec(` - CREATE TABLE IF NOT EXISTS example ( - country_code FixedString(2), - os_id UInt8, - browser_id UInt8, - categories Array(Int16), - action_day Date, - action_time DateTime - ) engine=Memory - `) - - if err != nil { - log.Fatal(err) - } - var ( - tx, _ = connect.Begin() - stmt, _ = tx.Prepare("INSERT INTO example (country_code, os_id, browser_id, categories, action_day, action_time) VALUES (?, ?, ?, ?, ?, ?)") - ) - defer stmt.Close() - - for i := 0; i < 100; i++ { - if _, err := stmt.Exec( - "RU", - 10+i, - 100+i, - clickhouse.Array([]int16{1, 2, 3}), - time.Now(), - time.Now(), - ); err != nil { - log.Fatal(err) - } - } - - if err := tx.Commit(); err != nil { - log.Fatal(err) - } - - col, err := column.Factory("country_code", "String", nil) - if err != nil { - log.Fatal(err) - } - countriesExternalTable := clickhouse.ExternalTable{ - Name: "countries", - Values: [][]driver.Value{ - {"RU"}, - }, - Columns: []column.Column{col}, - } - - rows, err := connect.Query("SELECT country_code, os_id, browser_id, categories, action_day, action_time "+ - "FROM example WHERE country_code IN ?", countriesExternalTable) - if err != nil { - log.Fatal(err) - } - defer rows.Close() - - for rows.Next() { - var ( - country string - os, browser uint8 - categories []int16 - actionDay, actionTime time.Time - ) - if err := rows.Scan(&country, &os, &browser, &categories, &actionDay, &actionTime); err != nil { - log.Fatal(err) - } - log.Printf("country: %s, os: %d, browser: %d, categories: %v, action_day: %s, action_time: %s", country, os, browser, categories, actionDay, actionTime) - } - - if err := rows.Err(); err != nil { - log.Fatal(err) - } - - if _, err := connect.Exec("DROP TABLE example"); err != nil { - log.Fatal(err) - } -} -``` diff --git a/vendor/github.com/ClickHouse/clickhouse-go/array.go b/vendor/github.com/ClickHouse/clickhouse-go/array.go deleted file mode 100644 index 997b8ab6..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/array.go +++ /dev/null @@ -1,21 +0,0 @@ -package clickhouse - -import ( - "time" -) - -func Array(v interface{}) interface{} { - return v -} - -func ArrayFixedString(len int, v interface{}) interface{} { - return v -} - -func ArrayDate(v []time.Time) interface{} { - return v -} - -func ArrayDateTime(v []time.Time) interface{} { - return v -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/bootstrap.go b/vendor/github.com/ClickHouse/clickhouse-go/bootstrap.go deleted file mode 100644 index 3e11e66e..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/bootstrap.go +++ /dev/null @@ -1,255 +0,0 @@ -package clickhouse - -import ( - "bufio" - "database/sql" - "database/sql/driver" - "fmt" - "io" - "log" - "net/url" - "os" - "strconv" - "strings" - "sync" - "sync/atomic" - "time" - - "github.com/ClickHouse/clickhouse-go/lib/binary" - "github.com/ClickHouse/clickhouse-go/lib/data" - "github.com/ClickHouse/clickhouse-go/lib/protocol" -) - -const ( - // DefaultDatabase when connecting to ClickHouse - DefaultDatabase = "default" - // DefaultUsername when connecting to ClickHouse - DefaultUsername = "default" - // DefaultConnTimeout when connecting to ClickHouse - DefaultConnTimeout = 5 * time.Second - // DefaultReadTimeout when reading query results - DefaultReadTimeout = time.Minute - // DefaultWriteTimeout when sending queries - DefaultWriteTimeout = time.Minute -) - -var ( - unixtime int64 - logOutput io.Writer = os.Stdout - hostname, _ = os.Hostname() - poolInit sync.Once -) - -func init() { - sql.Register("clickhouse", &bootstrap{}) - go func() { - for tick := time.Tick(time.Second); ; { - select { - case <-tick: - atomic.AddInt64(&unixtime, int64(time.Second)) - } - } - }() -} - -func now() time.Time { - return time.Unix(0, atomic.LoadInt64(&unixtime)) -} - -type bootstrap struct{} - -func (d *bootstrap) Open(dsn string) (driver.Conn, error) { - return Open(dsn) -} - -// SetLogOutput allows to change output of the default logger -func SetLogOutput(output io.Writer) { - logOutput = output -} - -// Open the connection -func Open(dsn string) (driver.Conn, error) { - clickhouse, err := open(dsn) - if err != nil { - return nil, err - } - - return clickhouse, err -} - -func open(dsn string) (*clickhouse, error) { - url, err := url.Parse(dsn) - if err != nil { - return nil, err - } - var ( - hosts = []string{url.Host} - query = url.Query() - secure = false - skipVerify = false - tlsConfigName = query.Get("tls_config") - noDelay = true - compress = false - database = query.Get("database") - username = query.Get("username") - password = query.Get("password") - blockSize = 1000000 - connTimeout = DefaultConnTimeout - readTimeout = DefaultReadTimeout - writeTimeout = DefaultWriteTimeout - connOpenStrategy = connOpenRandom - checkConnLiveness = true - ) - if len(database) == 0 { - database = DefaultDatabase - } - if len(username) == 0 { - username = DefaultUsername - } - if v, err := strconv.ParseBool(query.Get("no_delay")); err == nil { - noDelay = v - } - tlsConfig := getTLSConfigClone(tlsConfigName) - if tlsConfigName != "" && tlsConfig == nil { - return nil, fmt.Errorf("invalid tls_config - no config registered under name %s", tlsConfigName) - } - secure = tlsConfig != nil - if v, err := strconv.ParseBool(query.Get("secure")); err == nil { - secure = v - } - if v, err := strconv.ParseBool(query.Get("skip_verify")); err == nil { - skipVerify = v - } - if duration, err := strconv.ParseFloat(query.Get("timeout"), 64); err == nil { - connTimeout = time.Duration(duration * float64(time.Second)) - } - if duration, err := strconv.ParseFloat(query.Get("read_timeout"), 64); err == nil { - readTimeout = time.Duration(duration * float64(time.Second)) - } - if duration, err := strconv.ParseFloat(query.Get("write_timeout"), 64); err == nil { - writeTimeout = time.Duration(duration * float64(time.Second)) - } - if size, err := strconv.ParseInt(query.Get("block_size"), 10, 64); err == nil { - blockSize = int(size) - } - if altHosts := strings.Split(query.Get("alt_hosts"), ","); len(altHosts) != 0 { - for _, host := range altHosts { - if len(host) != 0 { - hosts = append(hosts, host) - } - } - } - switch query.Get("connection_open_strategy") { - case "random": - connOpenStrategy = connOpenRandom - case "in_order": - connOpenStrategy = connOpenInOrder - case "time_random": - connOpenStrategy = connOpenTimeRandom - } - - settings, err := makeQuerySettings(query) - if err != nil { - return nil, err - } - - if v, err := strconv.ParseBool(query.Get("compress")); err == nil { - compress = v - } - - if v, err := strconv.ParseBool(query.Get("check_connection_liveness")); err == nil { - checkConnLiveness = v - } - if secure { - // There is no way to check the liveness of a secure connection, as long as there is no access to raw TCP net.Conn - checkConnLiveness = false - } - - var ( - ch = clickhouse{ - logf: func(string, ...interface{}) {}, - settings: settings, - compress: compress, - blockSize: blockSize, - checkConnLiveness: checkConnLiveness, - ServerInfo: data.ServerInfo{ - Timezone: time.Local, - }, - } - logger = log.New(logOutput, "[clickhouse]", 0) - ) - if debug, err := strconv.ParseBool(url.Query().Get("debug")); err == nil && debug { - ch.logf = logger.Printf - } - ch.logf("host(s)=%s, database=%s, username=%s", - strings.Join(hosts, ", "), - database, - username, - ) - options := connOptions{ - secure: secure, - tlsConfig: tlsConfig, - skipVerify: skipVerify, - hosts: hosts, - connTimeout: connTimeout, - readTimeout: readTimeout, - writeTimeout: writeTimeout, - noDelay: noDelay, - openStrategy: connOpenStrategy, - logf: ch.logf, - } - if ch.conn, err = dial(options); err != nil { - return nil, err - } - logger.SetPrefix(fmt.Sprintf("[clickhouse][connect=%d]", ch.conn.ident)) - ch.buffer = bufio.NewWriter(ch.conn) - - ch.decoder = binary.NewDecoderWithCompress(ch.conn) - ch.encoder = binary.NewEncoderWithCompress(ch.buffer) - - if err := ch.hello(database, username, password); err != nil { - ch.conn.Close() - return nil, err - } - return &ch, nil -} - -func (ch *clickhouse) hello(database, username, password string) error { - ch.logf("[hello] -> %s", ch.ClientInfo) - { - ch.encoder.Uvarint(protocol.ClientHello) - if err := ch.ClientInfo.Write(ch.encoder); err != nil { - return err - } - { - ch.encoder.String(database) - ch.encoder.String(username) - ch.encoder.String(password) - } - if err := ch.encoder.Flush(); err != nil { - return err - } - - } - { - packet, err := ch.decoder.Uvarint() - if err != nil { - return err - } - switch packet { - case protocol.ServerException: - return ch.exception() - case protocol.ServerHello: - if err := ch.ServerInfo.Read(ch.decoder); err != nil { - return err - } - case protocol.ServerEndOfStream: - ch.logf("[bootstrap] <- end of stream") - return nil - default: - return fmt.Errorf("[hello] unexpected packet [%d] from server", packet) - } - } - ch.logf("[hello] <- %s", ch.ServerInfo) - return nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse.go b/vendor/github.com/ClickHouse/clickhouse-go/clickhouse.go deleted file mode 100644 index babc8935..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse.go +++ /dev/null @@ -1,354 +0,0 @@ -package clickhouse - -import ( - "bufio" - "context" - "database/sql" - "database/sql/driver" - "errors" - "fmt" - "net" - "reflect" - "regexp" - "sync" - "time" - - "github.com/ClickHouse/clickhouse-go/lib/binary" - "github.com/ClickHouse/clickhouse-go/lib/column" - "github.com/ClickHouse/clickhouse-go/lib/data" - "github.com/ClickHouse/clickhouse-go/lib/protocol" - "github.com/ClickHouse/clickhouse-go/lib/types" -) - -type ( - Date = types.Date - DateTime = types.DateTime - UUID = types.UUID -) - -type ExternalTable struct { - Name string - Values [][]driver.Value - Columns []column.Column -} - -var ( - ErrInsertInNotBatchMode = errors.New("insert statement supported only in the batch mode (use begin/commit)") - ErrLimitDataRequestInTx = errors.New("data request has already been prepared in transaction") -) - -var ( - splitInsertRe = regexp.MustCompile(`(?i)\sVALUES\s*\(`) -) - -type logger func(format string, v ...interface{}) - -type clickhouse struct { - sync.Mutex - data.ServerInfo - data.ClientInfo - logf logger - conn *connect - block *data.Block - buffer *bufio.Writer - decoder *binary.Decoder - encoder *binary.Encoder - settings *querySettings - compress bool - blockSize int - inTransaction bool - checkConnLiveness bool -} - -func (ch *clickhouse) Prepare(query string) (driver.Stmt, error) { - return ch.prepareContext(context.Background(), query) -} - -func (ch *clickhouse) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) { - return ch.prepareContext(ctx, query) -} - -func (ch *clickhouse) prepareContext(ctx context.Context, query string) (driver.Stmt, error) { - ch.logf("[prepare] %s", query) - switch { - case ch.conn.closed: - return nil, driver.ErrBadConn - case ch.block != nil: - return nil, ErrLimitDataRequestInTx - case isInsert(query): - if !ch.inTransaction { - return nil, ErrInsertInNotBatchMode - } - return ch.insert(ctx, query) - } - return &stmt{ - ch: ch, - query: query, - numInput: numInput(query), - }, nil -} - -func (ch *clickhouse) insert(ctx context.Context, query string) (_ driver.Stmt, err error) { - if err := ch.sendQuery(ctx, splitInsertRe.Split(query, -1)[0]+" VALUES ", nil); err != nil { - return nil, err - } - if ch.block, err = ch.readMeta(); err != nil { - return nil, err - } - return &stmt{ - ch: ch, - isInsert: true, - }, nil -} - -func (ch *clickhouse) Begin() (driver.Tx, error) { - return ch.beginTx(context.Background(), txOptions{}) -} - -func (ch *clickhouse) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) { - return ch.beginTx(ctx, txOptions{ - Isolation: int(opts.Isolation), - ReadOnly: opts.ReadOnly, - }) -} - -type txOptions struct { - Isolation int - ReadOnly bool -} - -func (ch *clickhouse) beginTx(ctx context.Context, opts txOptions) (*clickhouse, error) { - ch.logf("[begin] tx=%t, data=%t", ch.inTransaction, ch.block != nil) - switch { - case ch.inTransaction: - return nil, sql.ErrTxDone - case ch.conn.closed: - return nil, driver.ErrBadConn - } - - // Perform a stale connection check. We only perform this check in beginTx, - // because database/sql retries driver.ErrBadConn only for first request, - // but beginTx doesn't perform any other network interaction. - if ch.checkConnLiveness { - if err := ch.conn.connCheck(); err != nil { - ch.logf("[begin] closing bad idle connection: %w", err) - ch.Close() - return ch, driver.ErrBadConn - } - } - - if finish := ch.watchCancel(ctx); finish != nil { - defer finish() - } - ch.block = nil - ch.inTransaction = true - return ch, nil -} - -func (ch *clickhouse) Commit() error { - ch.logf("[commit] tx=%t, data=%t", ch.inTransaction, ch.block != nil) - defer func() { - if ch.block != nil { - ch.block.Reset() - ch.block = nil - } - ch.inTransaction = false - }() - switch { - case !ch.inTransaction: - return sql.ErrTxDone - case ch.conn.closed: - return driver.ErrBadConn - } - if ch.block != nil { - if err := ch.writeBlock(ch.block, ""); err != nil { - return err - } - // Send empty block as marker of end of data. - if err := ch.writeBlock(&data.Block{}, ""); err != nil { - return err - } - if err := ch.encoder.Flush(); err != nil { - return err - } - return ch.process() - } - return nil -} - -func (ch *clickhouse) Rollback() error { - ch.logf("[rollback] tx=%t, data=%t", ch.inTransaction, ch.block != nil) - if !ch.inTransaction { - return sql.ErrTxDone - } - if ch.block != nil { - ch.block.Reset() - } - ch.block = nil - ch.buffer = nil - ch.inTransaction = false - return ch.conn.Close() -} - -func (ch *clickhouse) CheckNamedValue(nv *driver.NamedValue) error { - switch nv.Value.(type) { - case ExternalTable, column.IP, column.UUID: - return nil - case nil, []byte, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64, string, time.Time: - return nil - } - switch v := nv.Value.(type) { - case - []int, []int8, []int16, []int32, []int64, - []uint, []uint8, []uint16, []uint32, []uint64, - []float32, []float64, - []string: - return nil - case net.IP, *net.IP: - return nil - case driver.Valuer: - value, err := v.Value() - if err != nil { - return err - } - nv.Value = value - default: - switch value := reflect.ValueOf(nv.Value); value.Kind() { - case reflect.Slice: - return nil - case reflect.Bool: - nv.Value = uint8(0) - if value.Bool() { - nv.Value = uint8(1) - } - case reflect.Int8: - nv.Value = int8(value.Int()) - case reflect.Int16: - nv.Value = int16(value.Int()) - case reflect.Int32: - nv.Value = int32(value.Int()) - case reflect.Int64: - nv.Value = value.Int() - case reflect.Uint8: - nv.Value = uint8(value.Uint()) - case reflect.Uint16: - nv.Value = uint16(value.Uint()) - case reflect.Uint32: - nv.Value = uint32(value.Uint()) - case reflect.Uint64: - nv.Value = uint64(value.Uint()) - case reflect.Float32: - nv.Value = float32(value.Float()) - case reflect.Float64: - nv.Value = float64(value.Float()) - case reflect.String: - nv.Value = value.String() - } - } - return nil -} - -func (ch *clickhouse) Close() error { - ch.block = nil - return ch.conn.Close() -} - -func (ch *clickhouse) process() error { - packet, err := ch.decoder.Uvarint() - if err != nil { - return err - } - for { - switch packet { - case protocol.ServerPong: - ch.logf("[process] <- pong") - return nil - case protocol.ServerException: - ch.logf("[process] <- exception") - return ch.exception() - case protocol.ServerProgress: - progress, err := ch.progress() - if err != nil { - return err - } - ch.logf("[process] <- progress: rows=%d, bytes=%d, total rows=%d", - progress.rows, - progress.bytes, - progress.totalRows, - ) - case protocol.ServerProfileInfo: - profileInfo, err := ch.profileInfo() - if err != nil { - return err - } - ch.logf("[process] <- profiling: rows=%d, bytes=%d, blocks=%d", profileInfo.rows, profileInfo.bytes, profileInfo.blocks) - case protocol.ServerData: - block, err := ch.readBlock() - if err != nil { - return err - } - ch.logf("[process] <- data: packet=%d, columns=%d, rows=%d", packet, block.NumColumns, block.NumRows) - case protocol.ServerEndOfStream: - ch.logf("[process] <- end of stream") - return nil - default: - ch.conn.Close() - return fmt.Errorf("[process] unexpected packet [%d] from server", packet) - } - if packet, err = ch.decoder.Uvarint(); err != nil { - return err - } - } -} - -func (ch *clickhouse) cancel() error { - ch.logf("[cancel request]") - // even if we fail to write the cancel, we still need to close - err := ch.encoder.Uvarint(protocol.ClientCancel) - if err == nil { - err = ch.encoder.Flush() - } - // return the close error if there was one, otherwise return the write error - if cerr := ch.conn.Close(); cerr != nil { - return cerr - } - return err -} - -func (ch *clickhouse) watchCancel(ctx context.Context) func() { - if done := ctx.Done(); done != nil { - finished := make(chan struct{}) - go func() { - select { - case <-done: - ch.cancel() - finished <- struct{}{} - ch.logf("[cancel] <- done") - case <-finished: - ch.logf("[cancel] <- finished") - } - }() - return func() { - select { - case <-finished: - case finished <- struct{}{}: - } - } - } - return func() {} -} - -func (ch *clickhouse) ExecContext(ctx context.Context, query string, - args []driver.NamedValue) (driver.Result, error) { - finish := ch.watchCancel(ctx) - defer finish() - stmt, err := ch.PrepareContext(ctx, query) - if err != nil { - return nil, err - } - dargs := make([]driver.Value, len(args)) - for i, nv := range args { - dargs[i] = nv.Value - } - return stmt.Exec(dargs) -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_exception.go b/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_exception.go deleted file mode 100644 index 2317d943..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_exception.go +++ /dev/null @@ -1,46 +0,0 @@ -package clickhouse - -import ( - "fmt" - "strings" -) - -type Exception struct { - Code int32 - Name string - Message string - StackTrace string - nested error -} - -func (e *Exception) Error() string { - return fmt.Sprintf("code: %d, message: %s", e.Code, e.Message) -} - -func (ch *clickhouse) exception() error { - var ( - e Exception - err error - hasNested bool - ) - if e.Code, err = ch.decoder.Int32(); err != nil { - return err - } - if e.Name, err = ch.decoder.String(); err != nil { - return err - } - if e.Message, err = ch.decoder.String(); err != nil { - return err - } - e.Message = strings.TrimSpace(strings.TrimPrefix(e.Message, e.Name+":")) - if e.StackTrace, err = ch.decoder.String(); err != nil { - return err - } - if hasNested, err = ch.decoder.Bool(); err != nil { - return err - } - if hasNested { - e.nested = ch.exception() - } - return &e -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_ping.go b/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_ping.go deleted file mode 100644 index 9c6b50a2..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_ping.go +++ /dev/null @@ -1,28 +0,0 @@ -package clickhouse - -import ( - "context" - "database/sql/driver" - - "github.com/ClickHouse/clickhouse-go/lib/protocol" -) - -func (ch *clickhouse) Ping(ctx context.Context) error { - return ch.ping(ctx) -} - -func (ch *clickhouse) ping(ctx context.Context) error { - if ch.conn.closed { - return driver.ErrBadConn - } - ch.logf("-> ping") - finish := ch.watchCancel(ctx) - defer finish() - if err := ch.encoder.Uvarint(protocol.ClientPing); err != nil { - return err - } - if err := ch.encoder.Flush(); err != nil { - return err - } - return ch.process() -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_profile_info.go b/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_profile_info.go deleted file mode 100644 index 97bc9c79..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_profile_info.go +++ /dev/null @@ -1,37 +0,0 @@ -package clickhouse - -type profileInfo struct { - rows uint64 - bytes uint64 - blocks uint64 - appliedLimit bool - rowsBeforeLimit uint64 - calculatedRowsBeforeLimit bool -} - -func (ch *clickhouse) profileInfo() (*profileInfo, error) { - var ( - p profileInfo - err error - ) - if p.rows, err = ch.decoder.Uvarint(); err != nil { - return nil, err - } - if p.blocks, err = ch.decoder.Uvarint(); err != nil { - return nil, err - } - if p.bytes, err = ch.decoder.Uvarint(); err != nil { - return nil, err - } - - if p.appliedLimit, err = ch.decoder.Bool(); err != nil { - return nil, err - } - if p.rowsBeforeLimit, err = ch.decoder.Uvarint(); err != nil { - return nil, err - } - if p.calculatedRowsBeforeLimit, err = ch.decoder.Bool(); err != nil { - return nil, err - } - return &p, nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_progress.go b/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_progress.go deleted file mode 100644 index 2ccc5fd9..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_progress.go +++ /dev/null @@ -1,26 +0,0 @@ -package clickhouse - -type progress struct { - rows uint64 - bytes uint64 - totalRows uint64 -} - -func (ch *clickhouse) progress() (*progress, error) { - var ( - p progress - err error - ) - if p.rows, err = ch.decoder.Uvarint(); err != nil { - return nil, err - } - if p.bytes, err = ch.decoder.Uvarint(); err != nil { - return nil, err - } - - if p.totalRows, err = ch.decoder.Uvarint(); err != nil { - return nil, err - } - - return &p, nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_read_block.go b/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_read_block.go deleted file mode 100644 index e9a3384d..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_read_block.go +++ /dev/null @@ -1,19 +0,0 @@ -package clickhouse - -import ( - "github.com/ClickHouse/clickhouse-go/lib/data" -) - -func (ch *clickhouse) readBlock() (*data.Block, error) { - if _, err := ch.decoder.String(); err != nil { // temporary table - return nil, err - } - - ch.decoder.SelectCompress(ch.compress) - var block data.Block - if err := block.Read(&ch.ServerInfo, ch.decoder); err != nil { - return nil, err - } - ch.decoder.SelectCompress(false) - return &block, nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_read_meta.go b/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_read_meta.go deleted file mode 100644 index 83e18dc1..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_read_meta.go +++ /dev/null @@ -1,53 +0,0 @@ -package clickhouse - -import ( - "fmt" - - "github.com/ClickHouse/clickhouse-go/lib/data" - "github.com/ClickHouse/clickhouse-go/lib/protocol" -) - -func (ch *clickhouse) readMeta() (*data.Block, error) { - for { - packet, err := ch.decoder.Uvarint() - if err != nil { - return nil, err - } - - switch packet { - case protocol.ServerException: - ch.logf("[read meta] <- exception") - return nil, ch.exception() - case protocol.ServerProgress: - progress, err := ch.progress() - if err != nil { - return nil, err - } - ch.logf("[read meta] <- progress: rows=%d, bytes=%d, total rows=%d", - progress.rows, - progress.bytes, - progress.totalRows, - ) - case protocol.ServerProfileInfo: - profileInfo, err := ch.profileInfo() - if err != nil { - return nil, err - } - ch.logf("[read meta] <- profiling: rows=%d, bytes=%d, blocks=%d", profileInfo.rows, profileInfo.bytes, profileInfo.blocks) - case protocol.ServerData: - block, err := ch.readBlock() - if err != nil { - return nil, err - } - ch.logf("[read meta] <- data: packet=%d, columns=%d, rows=%d", packet, block.NumColumns, block.NumRows) - return block, nil - case protocol.ServerEndOfStream: - _, err := ch.readBlock() - ch.logf("[process] <- end of stream") - return nil, err - default: - ch.conn.Close() - return nil, fmt.Errorf("[read meta] unexpected packet [%d] from server", packet) - } - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_send_external_data.go b/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_send_external_data.go deleted file mode 100644 index 706a6c58..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_send_external_data.go +++ /dev/null @@ -1,35 +0,0 @@ -package clickhouse - -import "github.com/ClickHouse/clickhouse-go/lib/data" - -func (ch *clickhouse) sendExternalTables(externalTables []ExternalTable) error { - ch.logf("[send external tables] count %d", len(externalTables)) - if externalTables == nil || len(externalTables) == 0 { - return nil - } - block := &data.Block{} - sentTables := make(map[string]bool, 0) - for _, externalTable := range externalTables { - if _, ok := sentTables[externalTable.Name]; ok { - continue - } - ch.logf("[send external table] name %s", externalTable.Name) - sentTables[externalTable.Name] = true - block.Columns = externalTable.Columns - block.NumColumns = uint64(len(externalTable.Columns)) - for _, row := range externalTable.Values { - err := block.AppendRow(row) - if err != nil { - return err - } - } - if err := ch.writeBlock(block, externalTable.Name); err != nil { - return err - } - if err := ch.encoder.Flush(); err != nil { - return err - } - block.Reset() - } - return nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_send_query.go b/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_send_query.go deleted file mode 100644 index 0717ed77..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_send_query.go +++ /dev/null @@ -1,71 +0,0 @@ -package clickhouse - -import ( - "context" - "github.com/ClickHouse/clickhouse-go/lib/data" - "github.com/ClickHouse/clickhouse-go/lib/protocol" -) - -func (ch *clickhouse) sendQuery(ctx context.Context, query string, externalTables []ExternalTable) error { - ch.logf("[send query] %s", query) - if err := ch.encoder.Uvarint(protocol.ClientQuery); err != nil { - return err - } - var queryID string - queryIDValue := ctx.Value(queryIDKey) - if queryIDValue != nil { - if queryIdStr, ok := queryIDValue.(string); ok { - queryID = queryIdStr - } - } - if err := ch.encoder.String(queryID); err != nil { - return err - } - { // client info - ch.encoder.Uvarint(1) - ch.encoder.String("") - ch.encoder.String("") - ch.encoder.String("[::ffff:127.0.0.1]:0") - ch.encoder.Uvarint(1) // iface type TCP - ch.encoder.String(hostname) - ch.encoder.String(hostname) - } - if err := ch.ClientInfo.Write(ch.encoder); err != nil { - return err - } - if ch.ServerInfo.Revision >= protocol.DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO { - ch.encoder.String("") - } - - // the settings are written as list of contiguous name-value pairs, finished with empty name - if !ch.settings.IsEmpty() { - ch.logf("[query settings] %s", ch.settings.settingsStr) - if err := ch.settings.Serialize(ch.encoder); err != nil { - return err - } - } - // empty string is a marker of the end of the settings - if err := ch.encoder.String(""); err != nil { - return err - } - if err := ch.encoder.Uvarint(protocol.StateComplete); err != nil { - return err - } - compress := protocol.CompressDisable - if ch.compress { - compress = protocol.CompressEnable - } - if err := ch.encoder.Uvarint(compress); err != nil { - return err - } - if err := ch.encoder.String(query); err != nil { - return err - } - if err := ch.sendExternalTables(externalTables); err != nil { - return err - } - if err := ch.writeBlock(&data.Block{}, ""); err != nil { - return err - } - return ch.encoder.Flush() -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_write_block.go b/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_write_block.go deleted file mode 100644 index 5a76f497..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/clickhouse_write_block.go +++ /dev/null @@ -1,40 +0,0 @@ -package clickhouse - -import ( - "github.com/ClickHouse/clickhouse-go/lib/data" - "github.com/ClickHouse/clickhouse-go/lib/protocol" -) - -func (ch *clickhouse) writeBlock(block *data.Block, tableName string) error { - ch.Lock() - defer ch.Unlock() - if err := ch.encoder.Uvarint(protocol.ClientData); err != nil { - return err - } - - if err := ch.encoder.String(tableName); err != nil { // temporary table - return err - } - - // implement CityHash v 1.0.2 and add LZ4 compression - /* - From Alexey Milovidov - Насколько я помню, сжимаются блоки с данными Native формата, а всё остальное (всякие номера пакетов и т. п.) передаётся без сжатия. - - Сжатые данные устроены так. Они представляют собой набор сжатых фреймов. - Каждый фрейм имеет следующий вид: - чексумма (16 байт), - идентификатор алгоритма сжатия (1 байт), - размер сжатых данных (4 байта, little endian, размер не включает в себя чексумму, но включает в себя остальные 9 байт заголовка), - размер несжатых данных (4 байта, little endian), затем сжатые данные. - Идентификатор алгоритма: 0x82 - lz4, 0x90 - zstd. - Чексумма - CityHash128 из CityHash версии 1.0.2, вычисленный от сжатых данных с учётом 9 байт заголовка. - - См. CompressedReadBufferBase, CompressedWriteBuffer, - utils/compressor, TCPHandler. - */ - ch.encoder.SelectCompress(ch.compress) - err := block.Write(&ch.ServerInfo, ch.encoder) - ch.encoder.SelectCompress(false) - return err -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/connect.go b/vendor/github.com/ClickHouse/clickhouse-go/connect.go deleted file mode 100644 index 2fc68128..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/connect.go +++ /dev/null @@ -1,191 +0,0 @@ -package clickhouse - -import ( - "bufio" - "crypto/tls" - "database/sql/driver" - "net" - "sync/atomic" - "time" -) - -var tick int32 - -type openStrategy int8 - -func (s openStrategy) String() string { - switch s { - case connOpenInOrder: - return "in_order" - case connOpenTimeRandom: - return "time_random" - } - return "random" -} - -const ( - connOpenRandom openStrategy = iota + 1 - connOpenInOrder - connOpenTimeRandom -) - -type connOptions struct { - secure, skipVerify bool - tlsConfig *tls.Config - hosts []string - connTimeout, readTimeout, writeTimeout time.Duration - noDelay bool - openStrategy openStrategy - logf func(string, ...interface{}) -} - -func dial(options connOptions) (*connect, error) { - var ( - err error - abs = func(v int) int { - if v < 0 { - return -1 * v - } - return v - } - conn net.Conn - ident = abs(int(atomic.AddInt32(&tick, 1))) - ) - tlsConfig := options.tlsConfig - if options.secure { - if tlsConfig == nil { - tlsConfig = &tls.Config{} - } - tlsConfig.InsecureSkipVerify = options.skipVerify - } - checkedHosts := make(map[int]struct{}, len(options.hosts)) - for i := range options.hosts { - var num int - switch options.openStrategy { - case connOpenInOrder: - num = i - case connOpenRandom: - num = (ident + i) % len(options.hosts) - case connOpenTimeRandom: - // select host based on milliseconds - num = int((time.Now().UnixNano()/1000)%1000) % len(options.hosts) - for _, ok := checkedHosts[num]; ok; _, ok = checkedHosts[num] { - num = int(time.Now().UnixNano()) % len(options.hosts) - } - checkedHosts[num] = struct{}{} - } - switch { - case options.secure: - conn, err = tls.DialWithDialer( - &net.Dialer{ - Timeout: options.connTimeout, - }, - "tcp", - options.hosts[num], - tlsConfig, - ) - default: - conn, err = net.DialTimeout("tcp", options.hosts[num], options.connTimeout) - } - if err == nil { - options.logf( - "[dial] secure=%t, skip_verify=%t, strategy=%s, ident=%d, server=%d -> %s", - options.secure, - options.skipVerify, - options.openStrategy, - ident, - num, - conn.RemoteAddr(), - ) - if tcp, ok := conn.(*net.TCPConn); ok { - err = tcp.SetNoDelay(options.noDelay) // Disable or enable the Nagle Algorithm for this tcp socket - if err != nil { - return nil, err - } - } - return &connect{ - Conn: conn, - logf: options.logf, - ident: ident, - buffer: bufio.NewReader(conn), - readTimeout: options.readTimeout, - writeTimeout: options.writeTimeout, - }, nil - } else { - options.logf( - "[dial err] secure=%t, skip_verify=%t, strategy=%s, ident=%d, addr=%s\n%#v", - options.secure, - options.skipVerify, - options.openStrategy, - ident, - options.hosts[num], - err, - ) - } - } - return nil, err -} - -type connect struct { - net.Conn - logf func(string, ...interface{}) - ident int - buffer *bufio.Reader - closed bool - readTimeout time.Duration - writeTimeout time.Duration - lastReadDeadlineTime time.Time - lastWriteDeadlineTime time.Time -} - -func (conn *connect) Read(b []byte) (int, error) { - var ( - n int - err error - total int - dstLen = len(b) - ) - if currentTime := now(); conn.readTimeout != 0 && currentTime.Sub(conn.lastReadDeadlineTime) > (conn.readTimeout>>2) { - conn.SetReadDeadline(time.Now().Add(conn.readTimeout)) - conn.lastReadDeadlineTime = currentTime - } - for total < dstLen { - if n, err = conn.buffer.Read(b[total:]); err != nil { - conn.logf("[connect] read error: %v", err) - conn.Close() - return n, driver.ErrBadConn - } - total += n - } - return total, nil -} - -func (conn *connect) Write(b []byte) (int, error) { - var ( - n int - err error - total int - srcLen = len(b) - ) - if currentTime := now(); conn.writeTimeout != 0 && currentTime.Sub(conn.lastWriteDeadlineTime) > (conn.writeTimeout>>2) { - conn.SetWriteDeadline(time.Now().Add(conn.writeTimeout)) - conn.lastWriteDeadlineTime = currentTime - } - for total < srcLen { - if n, err = conn.Conn.Write(b[total:]); err != nil { - conn.logf("[connect] write error: %v", err) - conn.Close() - return n, driver.ErrBadConn - } - total += n - } - return n, nil -} - -func (conn *connect) Close() error { - if !conn.closed { - conn.closed = true - return conn.Conn.Close() - } - return nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/connect_check.go b/vendor/github.com/ClickHouse/clickhouse-go/connect_check.go deleted file mode 100644 index 4b01a13e..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/connect_check.go +++ /dev/null @@ -1,57 +0,0 @@ -// +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos - -package clickhouse - -import ( - "errors" - "fmt" - "io" - "syscall" - "time" -) - -var errUnexpectedRead = errors.New("unexpected read from socket") - -func (conn *connect) connCheck() error { - var sysErr error - - sysConn, ok := conn.Conn.(syscall.Conn) - if !ok { - return nil - } - rawConn, err := sysConn.SyscallConn() - if err != nil { - return err - } - // If this connection has a ReadTimeout which we've been setting on - // reads, reset it to zero value before we attempt a non-blocking - // read, otherwise we may get os.ErrDeadlineExceeded for the cached - // connection from the pool with an expired timeout. - if conn.readTimeout != 0 { - err = conn.SetReadDeadline(time.Time{}) - if err != nil { - return fmt.Errorf("set read deadline: %w", err) - } - conn.lastReadDeadlineTime = time.Time{} - } - err = rawConn.Read(func(fd uintptr) bool { - var buf [1]byte - n, err := syscall.Read(int(fd), buf[:]) - switch { - case n == 0 && err == nil: - sysErr = io.EOF - case n > 0: - sysErr = errUnexpectedRead - case err == syscall.EAGAIN || err == syscall.EWOULDBLOCK: - sysErr = nil - default: - sysErr = err - } - return true - }) - if err != nil { - return err - } - - return sysErr -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/connect_check_dummy.go b/vendor/github.com/ClickHouse/clickhouse-go/connect_check_dummy.go deleted file mode 100644 index c8cc74e4..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/connect_check_dummy.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build !linux,!darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!illumos - -package clickhouse - -func (conn *connect) connCheck() error { - return nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/docker-compose.yml b/vendor/github.com/ClickHouse/clickhouse-go/docker-compose.yml deleted file mode 100644 index 2d03214b..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/docker-compose.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -version: '3' -services: - clickhouse: - image: yandex/clickhouse-server - ports: - - 127.0.0.1:8123:8123 - - 127.0.0.1:9000:9000 - - 127.0.0.1:9009:9009 diff --git a/vendor/github.com/ClickHouse/clickhouse-go/helpers.go b/vendor/github.com/ClickHouse/clickhouse-go/helpers.go deleted file mode 100644 index 7e10d062..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/helpers.go +++ /dev/null @@ -1,144 +0,0 @@ -package clickhouse - -import ( - "bytes" - "database/sql/driver" - "fmt" - "reflect" - "regexp" - "strings" - "time" -) - -func numInput(query string) int { - - var ( - count int - args = make(map[string]struct{}) - reader = bytes.NewReader([]byte(query)) - quote, gravis bool - escape bool - keyword bool - inBetween bool - like = newMatcher("like") - limit = newMatcher("limit") - offset = newMatcher("offset") - between = newMatcher("between") - in = newMatcher("in") - and = newMatcher("and") - from = newMatcher("from") - join = newMatcher("join") - subSelect = newMatcher("select") - ) - for { - if char, _, err := reader.ReadRune(); err == nil { - if escape { - escape = false - continue - } - switch char { - case '\\': - if gravis || quote { - escape = true - } - case '\'': - if !gravis { - quote = !quote - } - case '`': - if !quote { - gravis = !gravis - } - } - if quote || gravis { - continue - } - switch { - case char == '?' && keyword: - count++ - case char == '@': - if param := paramParser(reader); len(param) != 0 { - if _, found := args[param]; !found { - args[param] = struct{}{} - count++ - } - } - case - char == '=', - char == '<', - char == '>', - char == '(', - char == ',', - char == '[', - char == '%': - keyword = true - default: - if limit.matchRune(char) || offset.matchRune(char) || like.matchRune(char) || - in.matchRune(char) || from.matchRune(char) || join.matchRune(char) || subSelect.matchRune(char) { - keyword = true - } else if between.matchRune(char) { - keyword = true - inBetween = true - } else if inBetween && and.matchRune(char) { - keyword = true - inBetween = false - } else { - keyword = keyword && (char == ' ' || char == '\t' || char == '\n') - } - } - } else { - break - } - } - return count -} - -func paramParser(reader *bytes.Reader) string { - var name bytes.Buffer - for { - if char, _, err := reader.ReadRune(); err == nil { - if char == '_' || char >= '0' && char <= '9' || 'a' <= char && char <= 'z' || 'A' <= char && char <= 'Z' { - name.WriteRune(char) - } else { - reader.UnreadRune() - break - } - } else { - break - } - } - return name.String() -} - -var selectRe = regexp.MustCompile(`\s+SELECT\s+`) - -func isInsert(query string) bool { - if f := strings.Fields(query); len(f) > 2 { - return strings.EqualFold("INSERT", f[0]) && strings.EqualFold("INTO", f[1]) && !selectRe.MatchString(strings.ToUpper(query)) - } - return false -} - -func quote(v driver.Value) string { - switch v := reflect.ValueOf(v); v.Kind() { - case reflect.Slice: - values := make([]string, 0, v.Len()) - for i := 0; i < v.Len(); i++ { - values = append(values, quote(v.Index(i).Interface())) - } - return strings.Join(values, ", ") - } - switch v := v.(type) { - case string: - return "'" + strings.NewReplacer(`\`, `\\`, `'`, `\'`).Replace(v) + "'" - case time.Time: - return formatTime(v) - case nil: - return "null" - } - return fmt.Sprint(v) -} - -func formatTime(v time.Time) string { - return v.Format("toDateTime('2006-01-02 15:04:05', '" + v.Location().String() + "')") -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_reader.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_reader.go deleted file mode 100644 index be428b36..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_reader.go +++ /dev/null @@ -1,107 +0,0 @@ -// +build !clz4 - -package binary - -import ( - "encoding/binary" - "fmt" - "io" - - "github.com/ClickHouse/clickhouse-go/lib/lz4" -) - -type compressReader struct { - reader io.Reader - // data uncompressed - data []byte - // data position - pos int - // data compressed - zdata []byte - // lz4 headers - header []byte -} - -// NewCompressReader wrap the io.Reader -func NewCompressReader(r io.Reader) *compressReader { - p := &compressReader{ - reader: r, - header: make([]byte, HeaderSize), - } - p.data = make([]byte, BlockMaxSize, BlockMaxSize) - - zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize - p.zdata = make([]byte, zlen, zlen) - - p.pos = len(p.data) - return p -} - -func (cr *compressReader) Read(buf []byte) (n int, err error) { - var bytesRead = 0 - n = len(buf) - - if cr.pos < len(cr.data) { - copyedSize := copy(buf, cr.data[cr.pos:]) - - bytesRead += copyedSize - cr.pos += copyedSize - } - - for bytesRead < n { - if err = cr.readCompressedData(); err != nil { - return bytesRead, err - } - copyedSize := copy(buf[bytesRead:], cr.data) - - bytesRead += copyedSize - cr.pos = copyedSize - } - return n, nil -} - -func (cr *compressReader) readCompressedData() (err error) { - cr.pos = 0 - var n int - n, err = cr.reader.Read(cr.header) - if err != nil { - return - } - if n != len(cr.header) { - return fmt.Errorf("Lz4 decompression header EOF") - } - - compressedSize := int(binary.LittleEndian.Uint32(cr.header[17:])) - 9 - decompressedSize := int(binary.LittleEndian.Uint32(cr.header[21:])) - - if compressedSize > cap(cr.zdata) { - cr.zdata = make([]byte, compressedSize) - } - if decompressedSize > cap(cr.data) { - cr.data = make([]byte, decompressedSize) - } - - cr.zdata = cr.zdata[:compressedSize] - cr.data = cr.data[:decompressedSize] - - // @TODO checksum - if cr.header[16] == LZ4 { - n, err = cr.reader.Read(cr.zdata) - if err != nil { - return - } - - if n != len(cr.zdata) { - return fmt.Errorf("Decompress read size not match") - } - - _, err = lz4.Decode(cr.data, cr.zdata) - if err != nil { - return - } - } else { - return fmt.Errorf("Unknown compression method: 0x%02x ", cr.header[16]) - } - - return nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_reader_clz4.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_reader_clz4.go deleted file mode 100644 index 2845b3b8..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_reader_clz4.go +++ /dev/null @@ -1,107 +0,0 @@ -// +build clz4 - -package binary - -import ( - "encoding/binary" - "fmt" - "io" - - lz4 "github.com/cloudflare/golz4" -) - -type compressReader struct { - reader io.Reader - // data uncompressed - data []byte - // data position - pos int - // data compressed - zdata []byte - // lz4 headers - header []byte -} - -// NewCompressReader wrap the io.Reader -func NewCompressReader(r io.Reader) *compressReader { - p := &compressReader{ - reader: r, - header: make([]byte, HeaderSize), - } - p.data = make([]byte, BlockMaxSize, BlockMaxSize) - - zlen := lz4.CompressBound(p.data) + HeaderSize - p.zdata = make([]byte, zlen, zlen) - - p.pos = len(p.data) - return p -} - -func (cr *compressReader) Read(buf []byte) (n int, err error) { - var bytesRead = 0 - n = len(buf) - - if cr.pos < len(cr.data) { - copyedSize := copy(buf, cr.data[cr.pos:]) - - bytesRead += copyedSize - cr.pos += copyedSize - } - - for bytesRead < n { - if err = cr.readCompressedData(); err != nil { - return bytesRead, err - } - copyedSize := copy(buf[bytesRead:], cr.data) - - bytesRead += copyedSize - cr.pos = copyedSize - } - return n, nil -} - -func (cr *compressReader) readCompressedData() (err error) { - cr.pos = 0 - var n int - n, err = cr.reader.Read(cr.header) - if err != nil { - return - } - if n != len(cr.header) { - return fmt.Errorf("Lz4 decompression header EOF") - } - - compressedSize := int(binary.LittleEndian.Uint32(cr.header[17:])) - 9 - decompressedSize := int(binary.LittleEndian.Uint32(cr.header[21:])) - - if compressedSize > cap(cr.zdata) { - cr.zdata = make([]byte, compressedSize) - } - if decompressedSize > cap(cr.data) { - cr.data = make([]byte, decompressedSize) - } - - cr.zdata = cr.zdata[:compressedSize] - cr.data = cr.data[:decompressedSize] - - // @TODO checksum - if cr.header[16] == LZ4 { - n, err = cr.reader.Read(cr.zdata) - if err != nil { - return - } - - if n != len(cr.zdata) { - return fmt.Errorf("Decompress read size not match") - } - - err = lz4.Uncompress(cr.zdata, cr.data) - if err != nil { - return - } - } else { - return fmt.Errorf("Unknown compression method: 0x%02x ", cr.header[16]) - } - - return nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_settings.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_settings.go deleted file mode 100644 index ca455997..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_settings.go +++ /dev/null @@ -1,21 +0,0 @@ -package binary - -type CompressionMethodByte byte - -const ( - NONE CompressionMethodByte = 0x02 - LZ4 = 0x82 - ZSTD = 0x90 -) - -const ( - // ChecksumSize is 128bits for cityhash102 checksum - ChecksumSize = 16 - // CompressHeader magic + compressed_size + uncompressed_size - CompressHeaderSize = 1 + 4 + 4 - - // HeaderSize - HeaderSize = ChecksumSize + CompressHeaderSize - // BlockMaxSize 1MB - BlockMaxSize = 1 << 20 -) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_writer.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_writer.go deleted file mode 100644 index e4a73cf0..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_writer.go +++ /dev/null @@ -1,79 +0,0 @@ -// +build !clz4 - -package binary - -import ( - "encoding/binary" - "io" - - "github.com/ClickHouse/clickhouse-go/lib/cityhash102" - "github.com/ClickHouse/clickhouse-go/lib/lz4" -) - -type compressWriter struct { - writer io.Writer - // data uncompressed - data []byte - // data position - pos int - // data compressed - zdata []byte -} - -// NewCompressWriter wrap the io.Writer -func NewCompressWriter(w io.Writer) *compressWriter { - p := &compressWriter{writer: w} - p.data = make([]byte, BlockMaxSize, BlockMaxSize) - - zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize - p.zdata = make([]byte, zlen, zlen) - return p -} - -func (cw *compressWriter) Write(buf []byte) (int, error) { - var n int - for len(buf) > 0 { - // Accumulate the data to be compressed. - m := copy(cw.data[cw.pos:], buf) - cw.pos += m - buf = buf[m:] - - if cw.pos == len(cw.data) { - err := cw.Flush() - if err != nil { - return n, err - } - } - n += m - } - return n, nil -} - -func (cw *compressWriter) Flush() (err error) { - if cw.pos == 0 { - return - } - - // write the headers - compressedSize, err := lz4.Encode(cw.zdata[HeaderSize:], cw.data[:cw.pos]) - if err != nil { - return err - } - compressedSize += CompressHeaderSize - // fill the header, compressed_size_32 + uncompressed_size_32 - cw.zdata[16] = LZ4 - binary.LittleEndian.PutUint32(cw.zdata[17:], uint32(compressedSize)) - binary.LittleEndian.PutUint32(cw.zdata[21:], uint32(cw.pos)) - - // fill the checksum - checkSum := cityhash102.CityHash128(cw.zdata[16:], uint32(compressedSize)) - binary.LittleEndian.PutUint64(cw.zdata[0:], checkSum.Lower64()) - binary.LittleEndian.PutUint64(cw.zdata[8:], checkSum.Higher64()) - - cw.writer.Write(cw.zdata[:compressedSize+ChecksumSize]) - if w, ok := cw.writer.(WriteFlusher); ok { - err = w.Flush() - } - cw.pos = 0 - return -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_writer_clz4.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_writer_clz4.go deleted file mode 100644 index 1302e161..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_writer_clz4.go +++ /dev/null @@ -1,78 +0,0 @@ -// +build clz4 - -package binary - -import ( - "encoding/binary" - "io" - - lz4 "github.com/cloudflare/golz4" - "github.com/ClickHouse/clickhouse-go/lib/cityhash102" -) - -type compressWriter struct { - writer io.Writer - // data uncompressed - data []byte - // data position - pos int - // data compressed - zdata []byte -} - -// NewCompressWriter wrap the io.Writer -func NewCompressWriter(w io.Writer) *compressWriter { - p := &compressWriter{writer: w} - p.data = make([]byte, BlockMaxSize, BlockMaxSize) - - zlen := lz4.CompressBound(p.data) + HeaderSize - p.zdata = make([]byte, zlen, zlen) - return p -} - -func (cw *compressWriter) Write(buf []byte) (int, error) { - var n int - for len(buf) > 0 { - // Accumulate the data to be compressed. - m := copy(cw.data[cw.pos:], buf) - cw.pos += m - buf = buf[m:] - - if cw.pos == len(cw.data) { - err := cw.Flush() - if err != nil { - return n, err - } - } - n += m - } - return n, nil -} - -func (cw *compressWriter) Flush() (err error) { - if cw.pos == 0 { - return - } - // write the headers - compressedSize, err := lz4.Compress(cw.data[:cw.pos], cw.zdata[HeaderSize:]) - if err != nil { - return err - } - compressedSize += CompressHeaderSize - // fill the header, compressed_size_32 + uncompressed_size_32 - cw.zdata[16] = LZ4 - binary.LittleEndian.PutUint32(cw.zdata[17:], uint32(compressedSize)) - binary.LittleEndian.PutUint32(cw.zdata[21:], uint32(cw.pos)) - - // fill the checksum - checkSum := cityhash102.CityHash128(cw.zdata[16:], uint32(compressedSize)) - binary.LittleEndian.PutUint64(cw.zdata[0:], checkSum.Lower64()) - binary.LittleEndian.PutUint64(cw.zdata[8:], checkSum.Higher64()) - - cw.writer.Write(cw.zdata[:compressedSize+ChecksumSize]) - if w, ok := cw.writer.(WriteFlusher); ok { - err = w.Flush() - } - cw.pos = 0 - return -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/encoder.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/encoder.go deleted file mode 100644 index b4571b7e..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/encoder.go +++ /dev/null @@ -1,199 +0,0 @@ -package binary - -import ( - "encoding/binary" - "io" - "math" - "reflect" - "unsafe" -) - -func NewEncoder(w io.Writer) *Encoder { - return &Encoder{ - output: w, - } -} - -func NewEncoderWithCompress(w io.Writer) *Encoder { - return &Encoder{ - output: w, - compressOutput: NewCompressWriter(w), - } -} - -type Encoder struct { - compress bool - output io.Writer - compressOutput io.Writer - scratch [binary.MaxVarintLen64]byte -} - -func (enc *Encoder) SelectCompress(compress bool) { - if enc.compressOutput == nil { - return - } - if enc.compress && !compress { - enc.Flush() - } - enc.compress = compress -} - -func (enc *Encoder) Get() io.Writer { - if enc.compress && enc.compressOutput != nil { - return enc.compressOutput - } - return enc.output -} - -func (enc *Encoder) Uvarint(v uint64) error { - ln := binary.PutUvarint(enc.scratch[:binary.MaxVarintLen64], v) - if _, err := enc.Get().Write(enc.scratch[0:ln]); err != nil { - return err - } - return nil -} - -func (enc *Encoder) Bool(v bool) error { - if v { - return enc.UInt8(1) - } - return enc.UInt8(0) -} - -func (enc *Encoder) Int8(v int8) error { - return enc.UInt8(uint8(v)) -} - -func (enc *Encoder) Int16(v int16) error { - return enc.UInt16(uint16(v)) -} - -func (enc *Encoder) Int32(v int32) error { - return enc.UInt32(uint32(v)) -} - -func (enc *Encoder) Int64(v int64) error { - return enc.UInt64(uint64(v)) -} - -func (enc *Encoder) UInt8(v uint8) error { - enc.scratch[0] = v - if _, err := enc.Get().Write(enc.scratch[:1]); err != nil { - return err - } - return nil -} - -func (enc *Encoder) UInt16(v uint16) error { - enc.scratch[0] = byte(v) - enc.scratch[1] = byte(v >> 8) - if _, err := enc.Get().Write(enc.scratch[:2]); err != nil { - return err - } - return nil -} - -func (enc *Encoder) UInt32(v uint32) error { - enc.scratch[0] = byte(v) - enc.scratch[1] = byte(v >> 8) - enc.scratch[2] = byte(v >> 16) - enc.scratch[3] = byte(v >> 24) - if _, err := enc.Get().Write(enc.scratch[:4]); err != nil { - return err - } - return nil -} - -func (enc *Encoder) UInt64(v uint64) error { - enc.scratch[0] = byte(v) - enc.scratch[1] = byte(v >> 8) - enc.scratch[2] = byte(v >> 16) - enc.scratch[3] = byte(v >> 24) - enc.scratch[4] = byte(v >> 32) - enc.scratch[5] = byte(v >> 40) - enc.scratch[6] = byte(v >> 48) - enc.scratch[7] = byte(v >> 56) - if _, err := enc.Get().Write(enc.scratch[:8]); err != nil { - return err - } - return nil -} - -func (enc *Encoder) Float32(v float32) error { - return enc.UInt32(math.Float32bits(v)) -} - -func (enc *Encoder) Float64(v float64) error { - return enc.UInt64(math.Float64bits(v)) -} - -func (enc *Encoder) String(v string) error { - str := Str2Bytes(v) - if err := enc.Uvarint(uint64(len(str))); err != nil { - return err - } - if _, err := enc.Get().Write(str); err != nil { - return err - } - return nil -} - -func (enc *Encoder) RawString(str []byte) error { - if err := enc.Uvarint(uint64(len(str))); err != nil { - return err - } - if _, err := enc.Get().Write(str); err != nil { - return err - } - return nil -} - -func (enc *Encoder) Decimal128(bytes []byte) error { - _, err := enc.Get().Write(bytes) - return err -} - -func (enc *Encoder) Write(b []byte) (int, error) { - return enc.Get().Write(b) -} - -func (enc *Encoder) Flush() error { - if w, ok := enc.Get().(WriteFlusher); ok { - return w.Flush() - } - return nil -} - -type WriteFlusher interface { - Flush() error -} - -func Str2Bytes(str string) []byte { - // Copied from https://github.com/m3db/m3/blob/master/src/x/unsafe/string.go#L62 - if len(str) == 0 { - return nil - } - - // We need to declare a real byte slice so internally the compiler - // knows to use an unsafe.Pointer to keep track of the underlying memory so that - // once the slice's array pointer is updated with the pointer to the string's - // underlying bytes, the compiler won't prematurely GC the memory when the string - // goes out of scope. - var b []byte - byteHeader := (*reflect.SliceHeader)(unsafe.Pointer(&b)) - - // This makes sure that even if GC relocates the string's underlying - // memory after this assignment, the corresponding unsafe.Pointer in the internal - // slice struct will be updated accordingly to reflect the memory relocation. - byteHeader.Data = (*reflect.StringHeader)(unsafe.Pointer(&str)).Data - - // It is important that we access str after we assign the Data - // pointer of the string header to the Data pointer of the slice header to - // make sure the string (and the underlying bytes backing the string) don't get - // GC'ed before the assignment happens. - l := len(str) - byteHeader.Len = l - byteHeader.Cap = l - - return b -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/cityhash102/city64.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/cityhash102/city64.go deleted file mode 100644 index c410c44d..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/cityhash102/city64.go +++ /dev/null @@ -1,45 +0,0 @@ -package cityhash102 - -import ( - "encoding/binary" - "hash" -) - -type City64 struct { - s []byte -} - -var _ hash.Hash64 = (*City64)(nil) -var _ hash.Hash = (*City64)(nil) - -func New64() hash.Hash64 { - return &City64{} -} - -func (this *City64) Sum(b []byte) []byte { - b2 := make([]byte, 8) - binary.BigEndian.PutUint64(b2, this.Sum64()) - b = append(b, b2...) - return b -} - -func (this *City64) Sum64() uint64 { - return CityHash64(this.s, uint32(len(this.s))) -} - -func (this *City64) Reset() { - this.s = this.s[0:0] -} - -func (this *City64) BlockSize() int { - return 1 -} - -func (this *City64) Write(s []byte) (n int, err error) { - this.s = append(this.s, s...) - return len(s), nil -} - -func (this *City64) Size() int { - return 8 -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/cityhash102/doc.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/cityhash102/doc.go deleted file mode 100644 index 01ee5f85..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/cityhash102/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -/** COPY from https://github.com/zentures/cityhash/ - -NOTE: The code is modified to be compatible with CityHash128 used in ClickHouse -*/ -package cityhash102 diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/array.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/array.go deleted file mode 100644 index a9e052a2..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/array.go +++ /dev/null @@ -1,270 +0,0 @@ -package column - -import ( - "errors" - "fmt" - "net" - "reflect" - "strings" - "time" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type columnDecoder func() (interface{}, error) - -var unsupportedArrayTypeErrTemp = "unsupported Array type '%s'" - -// If you add Nullable type, that can be used in Array(Nullable(T)) add this type to ../codegen/nullable_appender/main.go in structure values.Types. -// Run code generation. -//go:generate go run ../codegen/nullable_appender -package $GOPACKAGE -file nullable_appender.go -type Array struct { - base - depth int - column Column - nullable bool -} - -func (array *Array) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - return nil, fmt.Errorf("do not use Read method for Array(T) column") -} - -func (array *Array) WriteNull(nulls, encoder *binary.Encoder, v interface{}) error { - if array.nullable { - column, ok := array.column.(*Nullable) - if !ok { - return fmt.Errorf("cannot convert to nullable type") - } - return column.WriteNull(nulls, encoder, v) - } - return fmt.Errorf("write null to not nullable array") -} - -func (array *Array) Write(encoder *binary.Encoder, v interface{}) error { - return array.column.Write(encoder, v) -} - -func (array *Array) ReadArray(decoder *binary.Decoder, rows int) (_ []interface{}, err error) { - var ( - offsets = make([][]uint64, array.depth) - values = make([]interface{}, rows) - ) - - // Read offsets - lastOffset := uint64(rows) - for i := 0; i < array.depth; i++ { - offset := make([]uint64, lastOffset) - for j := uint64(0); j < lastOffset; j++ { - if offset[j], err = decoder.UInt64(); err != nil { - return nil, err - } - } - offsets[i] = offset - lastOffset = 0 - if len(offset) > 0 { - lastOffset = offset[len(offset)-1] - } - } - - var cd columnDecoder - - switch column := array.column.(type) { - case *Nullable: - nullRows, err := column.ReadNull(decoder, int(lastOffset)) - if err != nil { - return nil, err - } - cd = func(rows []interface{}) columnDecoder { - i := 0 - return func() (interface{}, error) { - if i > len(rows) { - return nil, errors.New("not enough rows to return while parsing Null column") - } - ret := rows[i] - i++ - return ret, nil - } - }(nullRows) - case *Tuple: - tupleRows, err := column.ReadTuple(decoder, int(lastOffset)) - if err != nil { - return nil, err - } - // closure to return fully assembled tuple values as if they - // were decoded one at a time - cd = func(rows []interface{}) columnDecoder { - i := 0 - return func() (interface{}, error) { - if i > len(rows) { - return nil, errors.New("not enough rows to return while parsing Tuple column") - } - ret := rows[i] - i++ - return ret, nil - } - }(tupleRows) - default: - cd = func(decoder *binary.Decoder) columnDecoder { - return func() (interface{}, error) { return array.column.Read(decoder, array.nullable) } - }(decoder) - } - - // Read values - for i := 0; i < rows; i++ { - if values[i], err = array.read(cd, offsets, uint64(i), 0); err != nil { - return nil, err - } - } - return values, nil -} - -func (array *Array) read(readColumn columnDecoder, offsets [][]uint64, index uint64, level int) (interface{}, error) { - end := offsets[level][index] - start := uint64(0) - if index > 0 { - start = offsets[level][index-1] - } - - scanT := array.column.ScanType() - slice := reflect.MakeSlice(array.arrayType(level), 0, int(end-start)) - for i := start; i < end; i++ { - var ( - value interface{} - err error - ) - if level == array.depth-1 { - value, err = readColumn() - } else { - value, err = array.read(readColumn, offsets, i, level+1) - } - if err != nil { - return nil, err - } - if array.nullable && level == array.depth-1 { - f, ok := nullableAppender[scanT.String()] - if !ok { - return nil, fmt.Errorf(unsupportedArrayTypeErrTemp, scanT.String()) - } - - cSlice, err := f(value, slice) - if err != nil { - return nil, err - } - - slice = cSlice - } else { - slice = reflect.Append(slice, reflect.ValueOf(value)) - } - - } - return slice.Interface(), nil -} - -func (array *Array) arrayType(level int) reflect.Type { - t := array.column.ScanType() - for i := 0; i < array.depth-level; i++ { - t = reflect.SliceOf(t) - } - return t -} - -func (array *Array) Depth() int { - return array.depth -} - -func parseArray(name, chType string, timezone *time.Location) (*Array, error) { - if len(chType) < 11 { - return nil, fmt.Errorf("invalid Array column type: %s", chType) - } - var ( - depth int - columnType = chType - ) - -loop: - for _, str := range strings.Split(chType, "Array(") { - switch { - case len(str) == 0: - depth++ - default: - chType = str[:len(str)-depth] - break loop - } - } - column, err := Factory(name, chType, timezone) - if err != nil { - return nil, fmt.Errorf("Array(T): %v", err) - } - - var scanType interface{} - switch t := column.ScanType(); t { - case arrayBaseTypes[int8(0)]: - scanType = []int8{} - case arrayBaseTypes[int16(0)]: - scanType = []int16{} - case arrayBaseTypes[int32(0)]: - scanType = []int32{} - case arrayBaseTypes[int64(0)]: - scanType = []int64{} - case arrayBaseTypes[uint8(0)]: - scanType = []uint8{} - case arrayBaseTypes[uint16(0)]: - scanType = []uint16{} - case arrayBaseTypes[uint32(0)]: - scanType = []uint32{} - case arrayBaseTypes[uint64(0)]: - scanType = []uint64{} - case arrayBaseTypes[float32(0)]: - scanType = []float32{} - case arrayBaseTypes[float64(0)]: - scanType = []float64{} - case arrayBaseTypes[string("")]: - scanType = []string{} - case arrayBaseTypes[time.Time{}]: - scanType = []time.Time{} - case arrayBaseTypes[IPv4{}], arrayBaseTypes[IPv6{}]: - scanType = []net.IP{} - case reflect.ValueOf([]interface{}{}).Type(): - scanType = [][]interface{}{} - - //nullable - case arrayBaseTypes[ptrInt8T]: - scanType = []*int8{} - case arrayBaseTypes[ptrInt16T]: - scanType = []*int16{} - case arrayBaseTypes[ptrInt32T]: - scanType = []*int32{} - case arrayBaseTypes[ptrInt64T]: - scanType = []*int64{} - case arrayBaseTypes[ptrUInt8T]: - scanType = []*uint8{} - case arrayBaseTypes[ptrUInt16T]: - scanType = []*uint16{} - case arrayBaseTypes[ptrUInt32T]: - scanType = []*uint32{} - case arrayBaseTypes[ptrUInt64T]: - scanType = []*uint64{} - case arrayBaseTypes[ptrFloat32]: - scanType = []*float32{} - case arrayBaseTypes[ptrFloat64]: - scanType = []*float64{} - case arrayBaseTypes[ptrString]: - scanType = []*string{} - case arrayBaseTypes[ptrTime]: - scanType = []*time.Time{} - case arrayBaseTypes[ptrIPv4], arrayBaseTypes[ptrIPv6]: - scanType = []*net.IP{} - default: - return nil, fmt.Errorf(unsupportedArrayTypeErrTemp, column.ScanType().Name()) - } - return &Array{ - base: base{ - name: name, - chType: columnType, - valueOf: reflect.ValueOf(scanType), - }, - depth: depth, - column: column, - nullable: strings.HasPrefix(column.CHType(), "Nullable"), - }, nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/column.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/column.go deleted file mode 100644 index 60b1f969..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/column.go +++ /dev/null @@ -1,205 +0,0 @@ -package column - -import ( - "fmt" - "reflect" - "strings" - "time" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type Column interface { - Name() string - CHType() string - ScanType() reflect.Type - Read(*binary.Decoder, bool) (interface{}, error) - Write(*binary.Encoder, interface{}) error - defaultValue() interface{} - Depth() int -} - -func Factory(name, chType string, timezone *time.Location) (Column, error) { - switch chType { - case "Int8": - return &Int8{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[int8(0)], - }, - }, nil - case "Int16": - return &Int16{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[int16(0)], - }, - }, nil - case "Int32": - return &Int32{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[int32(0)], - }, - }, nil - case "Int64": - return &Int64{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[int64(0)], - }, - }, nil - case "UInt8": - return &UInt8{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[uint8(0)], - }, - }, nil - case "UInt16": - return &UInt16{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[uint16(0)], - }, - }, nil - case "UInt32": - return &UInt32{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[uint32(0)], - }, - }, nil - case "UInt64": - return &UInt64{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[uint64(0)], - }, - }, nil - case "Float32": - return &Float32{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[float32(0)], - }, - }, nil - case "Float64": - return &Float64{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[float64(0)], - }, - }, nil - case "String": - return &String{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[string("")], - }, - }, nil - case "UUID": - return &UUID{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[string("")], - }, - }, nil - case "Date": - _, offset := time.Unix(0, 0).In(timezone).Zone() - return &Date{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[time.Time{}], - }, - Timezone: timezone, - offset: int64(offset), - }, nil - case "IPv4": - return &IPv4{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[IPv4{}], - }, - }, nil - case "IPv6": - return &IPv6{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[IPv6{}], - }, - }, nil - } - switch { - case strings.HasPrefix(chType, "DateTime") && !strings.HasPrefix(chType, "DateTime64"): - return &DateTime{ - base: base{ - name: name, - chType: "DateTime", - valueOf: columnBaseTypes[time.Time{}], - }, - Timezone: timezone, - }, nil - case strings.HasPrefix(chType, "DateTime64"): - return &DateTime64{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[time.Time{}], - }, - Timezone: timezone, - }, nil - case strings.HasPrefix(chType, "Array"): - return parseArray(name, chType, timezone) - case strings.HasPrefix(chType, "Nullable"): - return parseNullable(name, chType, timezone) - case strings.HasPrefix(chType, "FixedString"): - return parseFixedString(name, chType) - case strings.HasPrefix(chType, "Enum8"), strings.HasPrefix(chType, "Enum16"): - return parseEnum(name, chType) - case strings.HasPrefix(chType, "Decimal"): - return parseDecimal(name, chType) - case strings.HasPrefix(chType, "SimpleAggregateFunction"): - if nestedType, err := getNestedType(chType, "SimpleAggregateFunction"); err != nil { - return nil, err - } else { - return Factory(name, nestedType, timezone) - } - case strings.HasPrefix(chType, "Tuple"): - return parseTuple(name, chType, timezone) - } - return nil, fmt.Errorf("column: unhandled type %v", chType) -} - -func getNestedType(chType string, wrapType string) (string, error) { - prefixLen := len(wrapType) + 1 - suffixLen := 1 - - if len(chType) > prefixLen+suffixLen { - nested := strings.Split(chType[prefixLen:len(chType)-suffixLen], ",") - if len(nested) == 2 { - return strings.TrimSpace(nested[1]), nil - } - - if len(nested) == 3 { - return strings.TrimSpace(strings.Join(nested[1:], ",")), nil - } - } - - return "", fmt.Errorf("column: invalid %s type (%s)", wrapType, chType) -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/common.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/common.go deleted file mode 100644 index 0583eeea..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/common.go +++ /dev/null @@ -1,115 +0,0 @@ -package column - -import ( - "fmt" - "net" - "reflect" - "time" -) - -type ErrUnexpectedType struct { - Column Column - T interface{} -} - -func (err *ErrUnexpectedType) Error() string { - return fmt.Sprintf("%s: unexpected type %T", err.Column, err.T) -} - -var columnBaseTypes = map[interface{}]reflect.Value{ - int8(0): reflect.ValueOf(int8(0)), - int16(0): reflect.ValueOf(int16(0)), - int32(0): reflect.ValueOf(int32(0)), - int64(0): reflect.ValueOf(int64(0)), - uint8(0): reflect.ValueOf(uint8(0)), - uint16(0): reflect.ValueOf(uint16(0)), - uint32(0): reflect.ValueOf(uint32(0)), - uint64(0): reflect.ValueOf(uint64(0)), - float32(0): reflect.ValueOf(float32(0)), - float64(0): reflect.ValueOf(float64(0)), - string(""): reflect.ValueOf(string("")), - time.Time{}: reflect.ValueOf(time.Time{}), - IPv4{}: reflect.ValueOf(net.IPv4zero), - IPv6{}: reflect.ValueOf(net.IPv6unspecified), -} - -type ptrTo uint8 - -const ( - ptrInt8T ptrTo = iota - ptrInt16T - ptrInt32T - ptrInt64T - ptrUInt8T - ptrUInt16T - ptrUInt32T - ptrUInt64T - ptrFloat32 - ptrFloat64 - ptrString - ptrTime - ptrIPv4 - ptrIPv6 -) - -var arrayBaseTypes = map[interface{}]reflect.Type{ - int8(0): reflect.ValueOf(int8(0)).Type(), - int16(0): reflect.ValueOf(int16(0)).Type(), - int32(0): reflect.ValueOf(int32(0)).Type(), - int64(0): reflect.ValueOf(int64(0)).Type(), - uint8(0): reflect.ValueOf(uint8(0)).Type(), - uint16(0): reflect.ValueOf(uint16(0)).Type(), - uint32(0): reflect.ValueOf(uint32(0)).Type(), - uint64(0): reflect.ValueOf(uint64(0)).Type(), - float32(0): reflect.ValueOf(float32(0)).Type(), - float64(0): reflect.ValueOf(float64(0)).Type(), - string(""): reflect.ValueOf(string("")).Type(), - time.Time{}: reflect.ValueOf(time.Time{}).Type(), - IPv4{}: reflect.ValueOf(net.IPv4zero).Type(), - IPv6{}: reflect.ValueOf(net.IPv6unspecified).Type(), - - // nullable - ptrInt8T: reflect.PtrTo(reflect.ValueOf(int8(0)).Type()), - ptrInt16T: reflect.PtrTo(reflect.ValueOf(int16(0)).Type()), - ptrInt32T: reflect.PtrTo(reflect.ValueOf(int32(0)).Type()), - ptrInt64T: reflect.PtrTo(reflect.ValueOf(int64(0)).Type()), - ptrUInt8T: reflect.PtrTo(reflect.ValueOf(uint8(0)).Type()), - ptrUInt16T: reflect.PtrTo(reflect.ValueOf(uint16(0)).Type()), - ptrUInt32T: reflect.PtrTo(reflect.ValueOf(uint32(0)).Type()), - ptrUInt64T: reflect.PtrTo(reflect.ValueOf(uint64(0)).Type()), - ptrFloat32: reflect.PtrTo(reflect.ValueOf(float32(0)).Type()), - ptrFloat64: reflect.PtrTo(reflect.ValueOf(float64(0)).Type()), - ptrString: reflect.PtrTo(reflect.ValueOf(string("")).Type()), - ptrTime: reflect.PtrTo(reflect.ValueOf(time.Time{}).Type()), - ptrIPv4: reflect.PtrTo(reflect.ValueOf(net.IPv4zero).Type()), - ptrIPv6: reflect.PtrTo(reflect.ValueOf(net.IPv6unspecified).Type()), -} - -type base struct { - name, chType string - valueOf reflect.Value -} - -func (base *base) Name() string { - return base.name -} - -func (base *base) CHType() string { - return base.chType -} - -func (base *base) ScanType() reflect.Type { - return base.valueOf.Type() -} - -func (base *base) defaultValue() interface{} { - return base.valueOf.Interface() -} - -func (base *base) String() string { - return fmt.Sprintf("%s (%s)", base.name, base.chType) -} - -func (base *base) Depth() int { - return 0 -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/date.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/date.go deleted file mode 100644 index 6dacb45c..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/date.go +++ /dev/null @@ -1,84 +0,0 @@ -package column - -import ( - "time" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type Date struct { - base - Timezone *time.Location - offset int64 -} - -func (dt *Date) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - sec, err := decoder.Int16() - if err != nil { - return nil, err - } - return time.Unix(int64(sec)*24*3600-dt.offset, 0).In(dt.Timezone), nil -} - -func (dt *Date) Write(encoder *binary.Encoder, v interface{}) error { - var timestamp int64 - switch value := v.(type) { - case time.Time: - _, offset := value.Zone() - timestamp = value.Unix() + int64(offset) - case int16: - return encoder.Int16(value) - case int32: - timestamp = int64(value) + dt.offset - case uint32: - timestamp = int64(value) + dt.offset - case uint64: - timestamp = int64(value) + dt.offset - case int64: - timestamp = value + dt.offset - case string: - var err error - timestamp, err = dt.parse(value) - if err != nil { - return err - } - - // this relies on Nullable never sending nil values through - case *time.Time: - _, offset := value.Zone() - timestamp = (*value).Unix() + int64(offset) - case *int16: - return encoder.Int16(*value) - case *int32: - timestamp = int64(*value) + dt.offset - case *int64: - timestamp = *value + dt.offset - case *string: - var err error - timestamp, err = dt.parse(*value) - if err != nil { - return err - } - - default: - return &ErrUnexpectedType{ - T: v, - Column: dt, - } - } - - return encoder.Int16(int16(timestamp / 24 / 3600)) -} - -func (dt *Date) parse(value string) (int64, error) { - tv, err := time.Parse("2006-01-02", value) - if err != nil { - return 0, err - } - return time.Date( - time.Time(tv).Year(), - time.Time(tv).Month(), - time.Time(tv).Day(), - 0, 0, 0, 0, time.UTC, - ).Unix(), nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/datetime.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/datetime.go deleted file mode 100644 index 3252c835..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/datetime.go +++ /dev/null @@ -1,87 +0,0 @@ -package column - -import ( - "time" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type DateTime struct { - base - Timezone *time.Location -} - -func (dt *DateTime) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - sec, err := decoder.Int32() - if err != nil { - return nil, err - } - return time.Unix(int64(sec), 0).In(dt.Timezone), nil -} - -func (dt *DateTime) Write(encoder *binary.Encoder, v interface{}) error { - var timestamp int64 - switch value := v.(type) { - case time.Time: - if !value.IsZero() { - timestamp = value.Unix() - } - case int16: - timestamp = int64(value) - case int32: - timestamp = int64(value) - case uint32: - timestamp = int64(value) - case uint64: - timestamp = int64(value) - case int64: - timestamp = value - case string: - var err error - timestamp, err = dt.parse(value) - if err != nil { - return err - } - - case *time.Time: - if value != nil && !(*value).IsZero() { - timestamp = (*value).Unix() - } - case *int16: - timestamp = int64(*value) - case *int32: - timestamp = int64(*value) - case *int64: - timestamp = *value - case *string: - var err error - timestamp, err = dt.parse(*value) - if err != nil { - return err - } - - default: - return &ErrUnexpectedType{ - T: v, - Column: dt, - } - } - - return encoder.Int32(int32(timestamp)) -} - -func (dt *DateTime) parse(value string) (int64, error) { - tv, err := time.Parse("2006-01-02 15:04:05", value) - if err != nil { - return 0, err - } - return time.Date( - time.Time(tv).Year(), - time.Time(tv).Month(), - time.Time(tv).Day(), - time.Time(tv).Hour(), - time.Time(tv).Minute(), - time.Time(tv).Second(), - 0, time.Local, //use local timzone when insert into clickhouse - ).Unix(), nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/datetime64.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/datetime64.go deleted file mode 100644 index 20657f97..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/datetime64.go +++ /dev/null @@ -1,100 +0,0 @@ -package column - -import ( - "math" - "strconv" - "strings" - "time" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type DateTime64 struct { - base - Timezone *time.Location -} - -func (dt *DateTime64) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - value, err := decoder.Int64() - if err != nil { - return nil, err - } - - precision, err := dt.getPrecision() - if err != nil { - return nil, err - } - - var nano int64 - if precision < 19 { - nano = value * int64(math.Pow10(9-precision)) - } - - sec := nano / int64(10e8) - nsec := nano - sec*10e8 - - return time.Unix(sec, nsec).In(dt.Timezone), nil -} - -func (dt *DateTime64) Write(encoder *binary.Encoder, v interface{}) error { - var timestamp int64 - switch value := v.(type) { - case time.Time: - if !value.IsZero() { - timestamp = value.UnixNano() - } - case uint64: - timestamp = int64(value) - case int64: - timestamp = value - case string: - var err error - timestamp, err = dt.parse(value) - if err != nil { - return err - } - case *time.Time: - if value != nil && !(*value).IsZero() { - timestamp = (*value).UnixNano() - } - case *int64: - timestamp = *value - case *string: - var err error - timestamp, err = dt.parse(*value) - if err != nil { - return err - } - default: - return &ErrUnexpectedType{ - T: v, - Column: dt, - } - } - - precision, err := dt.getPrecision() - if err != nil { - return err - } - - timestamp = timestamp / int64(math.Pow10(9-precision)) - - return encoder.Int64(timestamp) -} - -func (dt *DateTime64) parse(value string) (int64, error) { - tv, err := time.Parse("2006-01-02 15:04:05.999", value) - if err != nil { - return 0, err - } - return tv.UnixNano(), nil -} - -func (dt *DateTime64) getPrecision() (int, error) { - dtParams := dt.base.chType[11 : len(dt.base.chType)-1] - precision, err := strconv.Atoi(strings.Split(dtParams, ",")[0]) - if err != nil { - return 0, err - } - return precision, nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/decimal.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/decimal.go deleted file mode 100644 index 464208ee..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/decimal.go +++ /dev/null @@ -1,377 +0,0 @@ -package column - -import ( - b "encoding/binary" - "errors" - "fmt" - "math" - "reflect" - "strconv" - "strings" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -// Table of powers of 10 for fast casting from floating types to decimal type -// representations. -var factors10 = []float64{ - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, - 1e14, 1e15, 1e16, 1e17, 1e18, -} - -// Decimal represents Decimal(P, S) ClickHouse. Decimal is represented as -// integral. Also floating-point types are supported for query parameters. -// -// Since there is no support for int128 in Golang, decimals with precision 19 -// through 38 are represented as 16 little-endian bytes. -type Decimal struct { - base - nobits int // its domain is {32, 64} - precision int - scale int -} - -func (d *Decimal) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - switch d.nobits { - case 32: - return decoder.Int32() - case 64: - return decoder.Int64() - case 128: - return decoder.Decimal128() - default: - return nil, errors.New("unachievable execution path") - } -} - -func (d *Decimal) Write(encoder *binary.Encoder, v interface{}) error { - switch d.nobits { - case 32: - return d.write32(encoder, v) - case 64: - return d.write64(encoder, v) - case 128: - return d.write128(encoder, v) - default: - return errors.New("unachievable execution path") - } -} - -func (d *Decimal) float2int32(floating float64) int32 { - fixed := int32(floating * factors10[d.scale]) - return fixed -} - -func (d *Decimal) float2int64(floating float64) int64 { - fixed := int64(floating * factors10[d.scale]) - return fixed -} - -func (d *Decimal) write32(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case int8: - return encoder.Int32(int32(v)) - case int16: - return encoder.Int32(int32(v)) - case int32: - return encoder.Int32(int32(v)) - case int64: - if v > math.MaxInt32 || v < math.MinInt32 { - return errors.New("overflow when narrowing type conversion from int64 to int32") - } - return encoder.Int32(int32(v)) - - case uint8: - return encoder.Int32(int32(v)) - case uint16: - return encoder.Int32(int32(v)) - case uint32: - if v > math.MaxInt32 { - return errors.New("overflow when narrowing type conversion from uint32 to int32") - } - return encoder.Int32(int32(v)) - case uint64: - if v > math.MaxInt32 { - return errors.New("overflow when narrowing type conversion from uint64 to int32") - } - return encoder.Int32(int32(v)) - - case float32: - fixed := d.float2int32(float64(v)) - return encoder.Int32(fixed) - case float64: - fixed := d.float2int32(float64(v)) - return encoder.Int32(fixed) - - // this relies on Nullable never sending nil values through - case *int8: - return encoder.Int32(int32(*v)) - case *int16: - return encoder.Int32(int32(*v)) - case *int32: - return encoder.Int32(int32(*v)) - case *int64: - if *v > math.MaxInt32 || *v < math.MinInt32 { - return errors.New("overflow when narrowing type conversion from int64 to int32") - } - return encoder.Int32(int32(*v)) - - case *uint8: - return encoder.Int32(int32(*v)) - case *uint16: - return encoder.Int32(int32(*v)) - case *uint32: - if *v > math.MaxInt32 { - return errors.New("overflow when narrowing type conversion from uint34 to int32") - } - return encoder.Int32(int32(*v)) - case *uint64: - if *v > math.MaxInt32 { - return errors.New("overflow when narrowing type conversion from uint64 to int32") - } - return encoder.Int32(int32(*v)) - - case *float32: - fixed := d.float2int32(float64(*v)) - return encoder.Int32(fixed) - case *float64: - fixed := d.float2int32(float64(*v)) - return encoder.Int32(fixed) - } - - return &ErrUnexpectedType{ - T: v, - Column: d, - } -} - -func (d *Decimal) write64(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case int: - return encoder.Int64(int64(v)) - case int8: - return encoder.Int64(int64(v)) - case int16: - return encoder.Int64(int64(v)) - case int32: - return encoder.Int64(int64(v)) - case int64: - return encoder.Int64(int64(v)) - - case uint8: - return encoder.Int64(int64(v)) - case uint16: - return encoder.Int64(int64(v)) - case uint32: - return encoder.Int64(int64(v)) - case uint64: - if v > math.MaxInt64 { - return errors.New("overflow when narrowing type conversion from uint64 to int64") - } - return encoder.Int64(int64(v)) - - case float32: - fixed := d.float2int64(float64(v)) - return encoder.Int64(fixed) - case float64: - fixed := d.float2int64(float64(v)) - return encoder.Int64(fixed) - - // this relies on Nullable never sending nil values through - case *int: - return encoder.Int64(int64(*v)) - case *int8: - return encoder.Int64(int64(*v)) - case *int16: - return encoder.Int64(int64(*v)) - case *int32: - return encoder.Int64(int64(*v)) - case *int64: - return encoder.Int64(int64(*v)) - - case *uint8: - return encoder.Int64(int64(*v)) - case *uint16: - return encoder.Int64(int64(*v)) - case *uint32: - return encoder.Int64(int64(*v)) - case *uint64: - if *v > math.MaxInt64 { - return errors.New("overflow when narrowing type conversion from uint64 to int64") - } - return encoder.Int64(int64(*v)) - - case *float32: - fixed := d.float2int64(float64(*v)) - return encoder.Int64(fixed) - case *float64: - fixed := d.float2int64(float64(*v)) - return encoder.Int64(fixed) - } - - return &ErrUnexpectedType{ - T: v, - Column: d, - } -} - -// Turns an int64 into 16 little-endian bytes. -func int64ToDecimal128(v int64) []byte { - bytes := make([]byte, 16) - b.LittleEndian.PutUint64(bytes[:8], uint64(v)) - sign := 0 - if v < 0 { - sign = -1 - } - b.LittleEndian.PutUint64(bytes[8:], uint64(sign)) - return bytes -} - -// Turns a uint64 into 16 little-endian bytes. -func uint64ToDecimal128(v uint64) []byte { - bytes := make([]byte, 16) - b.LittleEndian.PutUint64(bytes[:8], uint64(v)) - return bytes -} - -func (d *Decimal) write128(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case int: - return encoder.Decimal128(int64ToDecimal128(int64(v))) - case int8: - return encoder.Decimal128(int64ToDecimal128(int64(v))) - case int16: - return encoder.Decimal128(int64ToDecimal128(int64(v))) - case int32: - return encoder.Decimal128(int64ToDecimal128(int64(v))) - case int64: - return encoder.Decimal128(int64ToDecimal128(v)) - - case uint8: - return encoder.Decimal128(uint64ToDecimal128(uint64(v))) - case uint16: - return encoder.Decimal128(uint64ToDecimal128(uint64(v))) - case uint32: - return encoder.Decimal128(uint64ToDecimal128(uint64(v))) - case uint64: - return encoder.Decimal128(uint64ToDecimal128(v)) - - case float32: - fixed := d.float2int64(float64(v)) - return encoder.Decimal128(int64ToDecimal128(fixed)) - case float64: - fixed := d.float2int64(float64(v)) - return encoder.Decimal128(int64ToDecimal128(fixed)) - - case []byte: - if len(v) != 16 { - return errors.New("expected 16 bytes") - } - return encoder.Decimal128(v) - - // this relies on Nullable never sending nil values through - case *int: - return encoder.Decimal128(int64ToDecimal128(int64(*v))) - case *int8: - return encoder.Decimal128(int64ToDecimal128(int64(*v))) - case *int16: - return encoder.Decimal128(int64ToDecimal128(int64(*v))) - case *int32: - return encoder.Decimal128(int64ToDecimal128(int64(*v))) - case *int64: - return encoder.Decimal128(int64ToDecimal128(*v)) - - case *uint8: - return encoder.Decimal128(uint64ToDecimal128(uint64(*v))) - case *uint16: - return encoder.Decimal128(uint64ToDecimal128(uint64(*v))) - case *uint32: - return encoder.Decimal128(uint64ToDecimal128(uint64(*v))) - case *uint64: - return encoder.Decimal128(uint64ToDecimal128(*v)) - - case *float32: - fixed := d.float2int64(float64(*v)) - return encoder.Decimal128(int64ToDecimal128(fixed)) - case *float64: - fixed := d.float2int64(float64(*v)) - return encoder.Decimal128(int64ToDecimal128(fixed)) - - case *[]byte: - if len(*v) != 16 { - return errors.New("expected 16 bytes") - } - return encoder.Decimal128(*v) - } - - return &ErrUnexpectedType{ - T: v, - Column: d, - } -} - -func parseDecimal(name, chType string) (Column, error) { - switch { - case len(chType) < 12: - fallthrough - case !strings.HasPrefix(chType, "Decimal"): - fallthrough - case chType[7] != '(': - fallthrough - case chType[len(chType)-1] != ')': - return nil, fmt.Errorf("invalid Decimal format: '%s'", chType) - } - - var params = strings.Split(chType[8:len(chType)-1], ",") - - if len(params) != 2 { - return nil, fmt.Errorf("invalid Decimal format: '%s'", chType) - } - - params[0] = strings.TrimSpace(params[0]) - params[1] = strings.TrimSpace(params[1]) - - var err error - var decimal = &Decimal{ - base: base{ - name: name, - chType: chType, - }, - } - - if decimal.precision, err = strconv.Atoi(params[0]); err != nil { - return nil, fmt.Errorf("'%s' is not Decimal type: %s", chType, err) - } else if decimal.precision < 1 { - return nil, errors.New("wrong precision of Decimal type") - } - - if decimal.scale, err = strconv.Atoi(params[1]); err != nil { - return nil, fmt.Errorf("'%s' is not Decimal type: %s", chType, err) - } else if decimal.scale < 0 || decimal.scale > decimal.precision { - return nil, errors.New("wrong scale of Decimal type") - } - - switch { - case decimal.precision <= 9: - decimal.nobits = 32 - decimal.valueOf = columnBaseTypes[int32(0)] - case decimal.precision <= 18: - decimal.nobits = 64 - decimal.valueOf = columnBaseTypes[int64(0)] - case decimal.precision <= 38: - decimal.nobits = 128 - decimal.valueOf = reflect.ValueOf([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}) - default: - return nil, errors.New("precision of Decimal exceeds max bound") - } - - return decimal, nil -} - -func (d *Decimal) GetPrecision() int { - return d.precision -} - -func (d *Decimal) GetScale() int { - return d.scale -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/enum.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/enum.go deleted file mode 100644 index 59a8d707..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/enum.go +++ /dev/null @@ -1,175 +0,0 @@ -package column - -import ( - "fmt" - "strconv" - "strings" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type Enum struct { - iv map[string]interface{} - vi map[interface{}]string - base - baseType interface{} -} - -func (enum *Enum) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - var ( - err error - ident interface{} - ) - switch enum.baseType.(type) { - case int16: - if ident, err = decoder.Int16(); err != nil { - return nil, err - } - default: - if ident, err = decoder.Int8(); err != nil { - return nil, err - } - } - if ident, found := enum.vi[ident]; found || isNull { - return ident, nil - } - return nil, fmt.Errorf("invalid Enum value: %v", ident) -} - -func (enum *Enum) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case string: - return enum.encodeFromString(v, encoder) - case uint8: - if _, ok := enum.baseType.(int8); ok { - return encoder.Int8(int8(v)) - } - case int8: - if _, ok := enum.baseType.(int8); ok { - return encoder.Int8(v) - } - case uint16: - if _, ok := enum.baseType.(int16); ok { - return encoder.Int16(int16(v)) - } - case int16: - if _, ok := enum.baseType.(int16); ok { - return encoder.Int16(v) - } - case int64: - switch enum.baseType.(type) { - case int8: - return encoder.Int8(int8(v)) - case int16: - return encoder.Int16(int16(v)) - } - // nullable enums - case *string: - return enum.encodeFromString(*v, encoder) - case *uint8: - if _, ok := enum.baseType.(int8); ok { - return encoder.Int8(int8(*v)) - } - case *int8: - if _, ok := enum.baseType.(int8); ok { - return encoder.Int8(*v) - } - case *uint16: - if _, ok := enum.baseType.(int16); ok { - return encoder.Int16(int16(*v)) - } - case *int16: - if _, ok := enum.baseType.(int16); ok { - return encoder.Int16(*v) - } - case *int64: - switch enum.baseType.(type) { - case int8: - return encoder.Int8(int8(*v)) - case int16: - return encoder.Int16(int16(*v)) - } - } - return &ErrUnexpectedType{ - T: v, - Column: enum, - } -} - -func (enum *Enum) encodeFromString(v string, encoder *binary.Encoder) error { - ident, found := enum.iv[v] - if !found { - return fmt.Errorf("invalid Enum ident: %s", v) - } - switch ident := ident.(type) { - case int8: - return encoder.Int8(ident) - case int16: - return encoder.Int16(ident) - default: - return &ErrUnexpectedType{ - T: ident, - Column: enum, - } - } -} - -func (enum *Enum) defaultValue() interface{} { - return enum.baseType -} - -func parseEnum(name, chType string) (*Enum, error) { - var ( - data string - isEnum16 bool - ) - if len(chType) < 8 { - return nil, fmt.Errorf("invalid Enum format: %s", chType) - } - switch { - case strings.HasPrefix(chType, "Enum8"): - data = chType[6:] - case strings.HasPrefix(chType, "Enum16"): - data = chType[7:] - isEnum16 = true - default: - return nil, fmt.Errorf("'%s' is not Enum type", chType) - } - enum := Enum{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[string("")], - }, - iv: make(map[string]interface{}), - vi: make(map[interface{}]string), - } - for _, block := range strings.Split(data[:len(data)-1], ",") { - parts := strings.Split(block, "=") - if len(parts) != 2 { - return nil, fmt.Errorf("invalid Enum format: %s", chType) - } - var ( - ident = strings.TrimSpace(parts[0]) - value, err = strconv.ParseInt(strings.TrimSpace(parts[1]), 10, 16) - ) - if err != nil { - return nil, fmt.Errorf("invalid Enum value: %v", chType) - } - { - var ( - ident = ident[1 : len(ident)-1] - value interface{} = int16(value) - ) - if !isEnum16 { - value = int8(value.(int16)) - } - if enum.baseType == nil { - enum.baseType = value - } - enum.iv[ident] = value - enum.vi[value] = ident - } - } - return &enum, nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/fixed_string.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/fixed_string.go deleted file mode 100644 index 75135f7b..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/fixed_string.go +++ /dev/null @@ -1,71 +0,0 @@ -package column - -import ( - "encoding" - "fmt" - "reflect" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type FixedString struct { - base - len int - scanType reflect.Type -} - -func (str *FixedString) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.Fixed(str.len) - if err != nil { - return "", err - } - return string(v), nil -} - -func (str *FixedString) Write(encoder *binary.Encoder, v interface{}) error { - var fixedString []byte - switch v := v.(type) { - case string: - fixedString = binary.Str2Bytes(v) - case []byte: - fixedString = v - case encoding.BinaryMarshaler: - bytes, err := v.MarshalBinary() - if err != nil { - return err - } - fixedString = bytes - default: - return &ErrUnexpectedType{ - T: v, - Column: str, - } - } - switch { - case len(fixedString) > str.len: - return fmt.Errorf("too large value '%s' (expected %d, got %d)", fixedString, str.len, len(fixedString)) - case len(fixedString) < str.len: - tmp := make([]byte, str.len) - copy(tmp, fixedString) - fixedString = tmp - } - if _, err := encoder.Write(fixedString); err != nil { - return err - } - return nil -} - -func parseFixedString(name, chType string) (*FixedString, error) { - var strLen int - if _, err := fmt.Sscanf(chType, "FixedString(%d)", &strLen); err != nil { - return nil, err - } - return &FixedString{ - base: base{ - name: name, - chType: chType, - valueOf: columnBaseTypes[string("")], - }, - len: strLen, - }, nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/float32.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/float32.go deleted file mode 100644 index 477a6a1a..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/float32.go +++ /dev/null @@ -1,35 +0,0 @@ -package column - -import ( - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type Float32 struct{ base } - -func (Float32) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.Float32() - if err != nil { - return float32(0), err - } - return v, nil -} - -func (float *Float32) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case float32: - return encoder.Float32(v) - case float64: - return encoder.Float32(float32(v)) - - // this relies on Nullable never sending nil values through - case *float32: - return encoder.Float32(*v) - case *float64: - return encoder.Float32(float32(*v)) - } - - return &ErrUnexpectedType{ - T: v, - Column: float, - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/float64.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/float64.go deleted file mode 100644 index 2f845400..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/float64.go +++ /dev/null @@ -1,35 +0,0 @@ -package column - -import ( - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type Float64 struct{ base } - -func (Float64) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.Float64() - if err != nil { - return float64(0), err - } - return v, nil -} - -func (float *Float64) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case float32: - return encoder.Float64(float64(v)) - case float64: - return encoder.Float64(v) - - // this relies on Nullable never sending nil values through - case *float32: - return encoder.Float64(float64(*v)) - case *float64: - return encoder.Float64(*v) - } - - return &ErrUnexpectedType{ - T: v, - Column: float, - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int16.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int16.go deleted file mode 100644 index 0b2d167d..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int16.go +++ /dev/null @@ -1,39 +0,0 @@ -package column - -import ( - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type Int16 struct{ base } - -func (Int16) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.Int16() - if err != nil { - return int16(0), err - } - return v, nil -} - -func (i *Int16) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case int16: - return encoder.Int16(v) - case int64: - return encoder.Int16(int16(v)) - case int: - return encoder.Int16(int16(v)) - - // this relies on Nullable never sending nil values through - case *int16: - return encoder.Int16(*v) - case *int64: - return encoder.Int16(int16(*v)) - case *int: - return encoder.Int16(int16(*v)) - } - - return &ErrUnexpectedType{ - T: v, - Column: i, - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int32.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int32.go deleted file mode 100644 index 34328e30..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int32.go +++ /dev/null @@ -1,39 +0,0 @@ -package column - -import ( - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type Int32 struct{ base } - -func (Int32) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.Int32() - if err != nil { - return int32(0), err - } - return v, nil -} - -func (i *Int32) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case int32: - return encoder.Int32(v) - case int64: - return encoder.Int32(int32(v)) - case int: - return encoder.Int32(int32(v)) - - // this relies on Nullable never sending nil values through - case *int32: - return encoder.Int32(*v) - case *int64: - return encoder.Int32(int32(*v)) - case *int: - return encoder.Int32(int32(*v)) - } - - return &ErrUnexpectedType{ - T: v, - Column: i, - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int64.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int64.go deleted file mode 100644 index fa627f0c..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int64.go +++ /dev/null @@ -1,40 +0,0 @@ -package column - -import ( - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type Int64 struct{ base } - -func (Int64) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.Int64() - if err != nil { - return int64(0), err - } - return v, nil -} - -func (i *Int64) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case int: - return encoder.Int64(int64(v)) - case int64: - return encoder.Int64(v) - case []byte: - if _, err := encoder.Write(v); err != nil { - return err - } - return nil - - // this relies on Nullable never sending nil values through - case *int: - return encoder.Int64(int64(*v)) - case *int64: - return encoder.Int64(*v) - } - - return &ErrUnexpectedType{ - T: v, - Column: i, - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int8.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int8.go deleted file mode 100644 index aa36bee2..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/int8.go +++ /dev/null @@ -1,49 +0,0 @@ -package column - -import ( - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type Int8 struct{ base } - -func (Int8) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.Int8() - if err != nil { - return int8(0), err - } - return v, nil -} - -func (i *Int8) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case int8: - return encoder.Int8(v) - case int64: - return encoder.Int8(int8(v)) - case int: - return encoder.Int8(int8(v)) - case bool: - if v { - return encoder.Int8(int8(1)) - } - return encoder.Int8(int8(0)) - - // this relies on Nullable never sending nil values through - case *int8: - return encoder.Int8(*v) - case *int64: - return encoder.Int8(int8(*v)) - case *int: - return encoder.Int8(int8(*v)) - case *bool: - if *v { - return encoder.Int8(int8(1)) - } - return encoder.Int8(int8(0)) - } - - return &ErrUnexpectedType{ - T: v, - Column: i, - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/ip.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/ip.go deleted file mode 100644 index 03056d7c..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/ip.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -IP type supporting for clickhouse as FixedString(16) -*/ - -package column - -import ( - "database/sql/driver" - "errors" - "net" - "strings" -) - -var ( - errInvalidScanType = errors.New("Invalid scan types") - errInvalidScanValue = errors.New("Invalid scan value") -) - -// IP column type -type IP net.IP - -// Value implements the driver.Valuer interface, json field interface -// Alignment on the right side -func (ip IP) Value() (driver.Value, error) { - return ip.MarshalBinary() -} - -func (ip IP) MarshalBinary() ([]byte, error) { - if len(ip) < 16 { - var ( - buff = make([]byte, 16) - j = 0 - ) - for i := 16 - len(ip); i < 16; i++ { - buff[i] = ip[j] - j++ - } - for i := 0; i < 16-len(ip); i++ { - buff[i] = '\x00' - } - if len(ip) == 4 { - buff[11] = '\xff' - buff[10] = '\xff' - } - return buff, nil - } - return []byte(ip), nil -} - -// Scan implements the driver.Valuer interface, json field interface -func (ip *IP) Scan(value interface{}) (err error) { - switch v := value.(type) { - case []byte: - if len(v) == 4 || len(v) == 16 { - *ip = IP(v) - } else { - err = errInvalidScanValue - } - case string: - if v == "" { - err = errInvalidScanValue - return - } - if (len(v) == 4 || len(v) == 16) && !strings.Contains(v, ".") && !strings.Contains(v, ":"){ - *ip = IP([]byte(v)) - return - } - if strings.Contains(v, ":") { - *ip = IP(net.ParseIP(v)) - return - } - *ip = IP(net.ParseIP(v).To4()) - case net.IP: - *ip = IP(v) - default: - err = errInvalidScanType - } - return -} - -// String implements the fmt.Stringer interface -func (ip IP) String() string { - return net.IP(ip).String() -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/ipv4.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/ipv4.go deleted file mode 100644 index eaac52c6..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/ipv4.go +++ /dev/null @@ -1,54 +0,0 @@ -package column - -import ( - "net" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type IPv4 struct { - base -} - -func (*IPv4) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.Fixed(4) - if err != nil { - return nil, err - } - return net.IPv4(v[3], v[2], v[1], v[0]), nil -} - -func (ip *IPv4) Write(encoder *binary.Encoder, v interface{}) error { - var netIP net.IP - switch v.(type) { - case string: - netIP = net.ParseIP(v.(string)) - case net.IP: - netIP = v.(net.IP) - case *net.IP: - netIP = *(v.(*net.IP)) - default: - return &ErrUnexpectedType{ - T: v, - Column: ip, - } - } - - if netIP == nil { - return &ErrUnexpectedType{ - T: v, - Column: ip, - } - } - ip4 := netIP.To4() - if ip4 == nil { - return &ErrUnexpectedType{ - T: v, - Column: ip, - } - } - if _, err := encoder.Write([]byte{ip4[3], ip4[2], ip4[1], ip4[0]}); err != nil { - return err - } - return nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/ipv6.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/ipv6.go deleted file mode 100644 index 0fa9f8a9..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/ipv6.go +++ /dev/null @@ -1,47 +0,0 @@ -package column - -import ( - "net" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type IPv6 struct { - base -} - -func (*IPv6) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.Fixed(16) - if err != nil { - return nil, err - } - return net.IP(v), nil -} - -func (ip *IPv6) Write(encoder *binary.Encoder, v interface{}) error { - var netIP net.IP - switch v.(type) { - case string: - netIP = net.ParseIP(v.(string)) - case net.IP: - netIP = v.(net.IP) - case *net.IP: - netIP = *(v.(*net.IP)) - default: - return &ErrUnexpectedType{ - T: v, - Column: ip, - } - } - - if netIP == nil { - return &ErrUnexpectedType{ - T: v, - Column: ip, - } - } - if _, err := encoder.Write([]byte(netIP.To16())); err != nil { - return err - } - return nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/nullable.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/nullable.go deleted file mode 100644 index 9dd88b54..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/nullable.go +++ /dev/null @@ -1,96 +0,0 @@ -package column - -import ( - "fmt" - "reflect" - "time" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type Nullable struct { - base - column Column -} - -func (null *Nullable) ScanType() reflect.Type { - return reflect.PtrTo(null.column.ScanType()) -} - -func (null *Nullable) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - return null.column.Read(decoder, isNull) -} - -func (null *Nullable) Write(encoder *binary.Encoder, v interface{}) error { - return nil -} - -func (null *Nullable) ReadNull(decoder *binary.Decoder, rows int) (_ []interface{}, err error) { - var ( - isNull byte - value interface{} - nulls = make([]byte, rows) - values = make([]interface{}, rows) - ) - for i := 0; i < rows; i++ { - if isNull, err = decoder.ReadByte(); err != nil { - return nil, err - } - nulls[i] = isNull - } - for i, isNull := range nulls { - switch value, err = null.column.Read(decoder, isNull != 0); true { - case err != nil: - return nil, err - case isNull == 0: - values[i] = value - default: - values[i] = nil - } - } - return values, nil -} -func (null *Nullable) WriteNull(nulls, encoder *binary.Encoder, v interface{}) error { - if isNil(v) { - if _, err := nulls.Write([]byte{1}); err != nil { - return err - } - return null.column.Write(encoder, null.column.defaultValue()) - } - if _, err := nulls.Write([]byte{0}); err != nil { - return err - } - return null.column.Write(encoder, v) -} - -func parseNullable(name, chType string, timezone *time.Location) (*Nullable, error) { - if len(chType) < 14 { - return nil, fmt.Errorf("invalid Nullable column type: %s", chType) - } - column, err := Factory(name, chType[9:][:len(chType)-10], timezone) - if err != nil { - return nil, fmt.Errorf("Nullable(T): %v", err) - } - return &Nullable{ - base: base{ - name: name, - chType: chType, - }, - column: column, - }, nil -} - -func (null *Nullable) GetColumn() Column { - return null.column -} - -func isNil(v interface{}) bool { - if v == nil { - return true - } - switch val := reflect.ValueOf(v); val.Type().Kind() { - case reflect.Array, reflect.Chan, reflect.Map, reflect.Ptr, reflect.Slice: - return val.IsNil() - } - return false -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/nullable_appender.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/nullable_appender.go deleted file mode 100644 index a7680262..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/nullable_appender.go +++ /dev/null @@ -1,173 +0,0 @@ - -// DANGER! This code was autogenerated from template by clickhouse-go/lib/codegen/nullable_appender. -// You shouldn't change it manually. -// For more info check clickhouse-go/lib/codegen/nullable_appender/main.go - -package column - -import ( - "fmt" - "net" - "reflect" - "time" -) - -var nullableAppender = map[string]func(v interface{}, slice reflect.Value) (reflect.Value, error){ - - "*int8": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(int8) - if !ok { - return slice, fmt.Errorf("cannot assert to type int8") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *int8 - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*int16": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(int16) - if !ok { - return slice, fmt.Errorf("cannot assert to type int16") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *int16 - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*int32": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(int32) - if !ok { - return slice, fmt.Errorf("cannot assert to type int32") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *int32 - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*int64": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(int64) - if !ok { - return slice, fmt.Errorf("cannot assert to type int64") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *int64 - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*uint8": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(uint8) - if !ok { - return slice, fmt.Errorf("cannot assert to type uint8") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *uint8 - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*uint16": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(uint16) - if !ok { - return slice, fmt.Errorf("cannot assert to type uint16") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *uint16 - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*uint32": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(uint32) - if !ok { - return slice, fmt.Errorf("cannot assert to type uint32") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *uint32 - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*uint64": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(uint64) - if !ok { - return slice, fmt.Errorf("cannot assert to type uint64") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *uint64 - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*float32": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(float32) - if !ok { - return slice, fmt.Errorf("cannot assert to type float32") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *float32 - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*float64": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(float64) - if !ok { - return slice, fmt.Errorf("cannot assert to type float64") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *float64 - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*string": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(string) - if !ok { - return slice, fmt.Errorf("cannot assert to type string") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *string - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*time.Time": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(time.Time) - if !ok { - return slice, fmt.Errorf("cannot assert to type time.Time") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *time.Time - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - - "*net.IP": func(v interface{}, slice reflect.Value) (reflect.Value, error) { - if v != nil { - v, ok := v.(net.IP) - if !ok { - return slice, fmt.Errorf("cannot assert to type net.IP") - } - return reflect.Append(slice, reflect.ValueOf(&v)), nil - } - var vNil *net.IP - return reflect.Append(slice, reflect.ValueOf(vNil)), nil - }, - -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/string.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/string.go deleted file mode 100644 index a190660f..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/string.go +++ /dev/null @@ -1,35 +0,0 @@ -package column - -import ( - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type String struct{ base } - -func (String) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.String() - if err != nil { - return "", err - } - return v, nil -} - -func (str *String) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case string: - return encoder.String(v) - case []byte: - return encoder.RawString(v) - - // this relies on Nullable never sending nil values through - case *string: - return encoder.String(*v) - case *[]byte: - return encoder.RawString(*v) - } - - return &ErrUnexpectedType{ - T: v, - Column: str, - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/tuple.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/tuple.go deleted file mode 100644 index 00578a6e..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/tuple.go +++ /dev/null @@ -1,110 +0,0 @@ -package column - -import ( - "fmt" - "github.com/ClickHouse/clickhouse-go/lib/binary" - "reflect" - "strconv" - "time" -) - -type Tuple struct { - base - columns []Column -} - -func (tuple *Tuple) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - return nil, fmt.Errorf("do not use Read method for Tuple(T) column") -} - -func (tuple *Tuple) ReadTuple(decoder *binary.Decoder, rows int) ([]interface{}, error) { - var values = make([][]interface{}, rows) - - for _, c := range tuple.columns { - - switch column := c.(type) { - case *Array: - cols, err := column.ReadArray(decoder, rows) - if err != nil { - return nil, err - } - for i := 0; i < rows; i++ { - values[i] = append(values[i], cols[i]) - } - - case *Nullable: - cols, err := column.ReadNull(decoder, rows) - if err != nil { - return nil, err - } - for i := 0; i < rows; i++ { - values[i] = append(values[i], cols[i]) - } - - case *Tuple: - cols, err := column.ReadTuple(decoder, rows) - if err != nil { - return nil, err - } - for i := 0; i < rows; i++ { - values[i] = append(values[i], cols[i]) - } - - default: - for i := 0; i < rows; i++ { - value, err := c.Read(decoder, false) - if err != nil { - return nil, err - } - values[i] = append(values[i], value) - } - } - } - - var ret = make([]interface{}, rows) - for i := range values { - ret[i] = values[i] - } - - return ret, nil -} - -func (tuple *Tuple) Write(encoder *binary.Encoder, v interface{}) (err error) { - return fmt.Errorf("unsupported Tuple(T) type [%T]", v) -} - -func parseTuple(name, chType string, timezone *time.Location) (Column, error) { - var columnType = chType - - chType = chType[6 : len(chType)-1] - var types []string - var last, diff int - for i, b := range chType + "," { - if b == '(' { - diff++ - } else if b == ')' { - diff-- - } else if b == ',' && diff == 0 { - types = append(types, chType[last:i]) - last = i + 2 - } - } - - var columns = make([]Column, 0, len(types)) - for i, chType := range types { - column, err := Factory(name+"."+strconv.Itoa(i+1), chType, timezone) - if err != nil { - return nil, fmt.Errorf("%s: %v", chType, err) - } - columns = append(columns, column) - } - - return &Tuple{ - base: base{ - name: name, - chType: columnType, - valueOf: reflect.ValueOf([]interface{}{}), - }, - columns: columns, - }, nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint16.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint16.go deleted file mode 100644 index cf761efb..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint16.go +++ /dev/null @@ -1,43 +0,0 @@ -package column - -import ( - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type UInt16 struct{ base } - -func (UInt16) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.UInt16() - if err != nil { - return uint16(0), err - } - return v, nil -} - -func (u *UInt16) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case uint16: - return encoder.UInt16(v) - case int64: - return encoder.UInt16(uint16(v)) - case uint64: - return encoder.UInt16(uint16(v)) - case int: - return encoder.UInt16(uint16(v)) - - // this relies on Nullable never sending nil values through - case *uint16: - return encoder.UInt16(*v) - case *int64: - return encoder.UInt16(uint16(*v)) - case *uint64: - return encoder.UInt16(uint16(*v)) - case *int: - return encoder.UInt16(uint16(*v)) - } - - return &ErrUnexpectedType{ - T: v, - Column: u, - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint32.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint32.go deleted file mode 100644 index f5f72f5f..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint32.go +++ /dev/null @@ -1,43 +0,0 @@ -package column - -import ( - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type UInt32 struct{ base } - -func (UInt32) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.UInt32() - if err != nil { - return uint32(0), err - } - return v, nil -} - -func (u *UInt32) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case uint32: - return encoder.UInt32(v) - case uint64: - return encoder.UInt32(uint32(v)) - case int64: - return encoder.UInt32(uint32(v)) - case int: - return encoder.UInt32(uint32(v)) - - // this relies on Nullable never sending nil values through - case *uint64: - return encoder.UInt32(uint32(*v)) - case *uint32: - return encoder.UInt32(*v) - case *int64: - return encoder.UInt32(uint32(*v)) - case *int: - return encoder.UInt32(uint32(*v)) - } - - return &ErrUnexpectedType{ - T: v, - Column: u, - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint64.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint64.go deleted file mode 100644 index 09261e01..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint64.go +++ /dev/null @@ -1,44 +0,0 @@ -package column - -import ( - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type UInt64 struct{ base } - -func (UInt64) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.UInt64() - if err != nil { - return uint64(0), err - } - return v, nil -} - -func (u *UInt64) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case []byte: - if _, err := encoder.Write(v); err != nil { - return err - } - return nil - case uint64: - return encoder.UInt64(v) - case int64: - return encoder.UInt64(uint64(v)) - case int: - return encoder.UInt64(uint64(v)) - - // this relies on Nullable never sending nil values through - case *uint64: - return encoder.UInt64(*v) - case *int64: - return encoder.UInt64(uint64(*v)) - case *int: - return encoder.UInt64(uint64(*v)) - } - - return &ErrUnexpectedType{ - T: v, - Column: u, - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint8.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint8.go deleted file mode 100644 index 8af493e7..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint8.go +++ /dev/null @@ -1,47 +0,0 @@ -package column - -import ( - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type UInt8 struct{ base } - -func (UInt8) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - v, err := decoder.UInt8() - if err != nil { - return uint8(0), err - } - return v, nil -} - -func (u *UInt8) Write(encoder *binary.Encoder, v interface{}) error { - switch v := v.(type) { - case bool: - return encoder.Bool(v) - case uint8: - return encoder.UInt8(v) - case int64: - return encoder.UInt8(uint8(v)) - case uint64: - return encoder.UInt8(uint8(v)) - case int: - return encoder.UInt8(uint8(v)) - - // this relies on Nullable never sending nil values through - case *bool: - return encoder.Bool(*v) - case *uint8: - return encoder.UInt8(*v) - case *int64: - return encoder.UInt8(uint8(*v)) - case *uint64: - return encoder.UInt8(uint8(*v)) - case *int: - return encoder.UInt8(uint8(*v)) - } - - return &ErrUnexpectedType{ - T: v, - Column: u, - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uuid.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uuid.go deleted file mode 100644 index f778acc9..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/column/uuid.go +++ /dev/null @@ -1,139 +0,0 @@ -package column - -import ( - "encoding/hex" - "errors" - "fmt" - "reflect" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -const ( - UUIDLen = 16 - NullUUID = "00000000-0000-0000-0000-000000000000" -) - -var ErrInvalidUUIDFormat = errors.New("invalid UUID format") - -type UUID struct { - base - scanType reflect.Type -} - -func (*UUID) Read(decoder *binary.Decoder, isNull bool) (interface{}, error) { - src, err := decoder.Fixed(UUIDLen) - if err != nil { - return "", err - } - - src = swap(src) - - var uuid [36]byte - { - hex.Encode(uuid[:], src[:4]) - uuid[8] = '-' - hex.Encode(uuid[9:13], src[4:6]) - uuid[13] = '-' - hex.Encode(uuid[14:18], src[6:8]) - uuid[18] = '-' - hex.Encode(uuid[19:23], src[8:10]) - uuid[23] = '-' - hex.Encode(uuid[24:], src[10:]) - } - return string(uuid[:]), nil -} - -func (u *UUID) Write(encoder *binary.Encoder, v interface{}) (err error) { - var uuid []byte - switch v := v.(type) { - case string: - if uuid, err = uuid2bytes(v); err != nil { - return err - } - case []byte: - if len(v) != UUIDLen { - return fmt.Errorf("invalid raw UUID len '%s' (expected %d, got %d)", uuid, UUIDLen, len(uuid)) - } - uuid = make([]byte, 16) - copy(uuid, v) - default: - return &ErrUnexpectedType{ - T: v, - Column: u, - } - } - - uuid = swap(uuid) - - if _, err := encoder.Write(uuid); err != nil { - return err - } - return nil -} - -func swap(src []byte) []byte { - _ = src[15] - src[0], src[7] = src[7], src[0] - src[1], src[6] = src[6], src[1] - src[2], src[5] = src[5], src[2] - src[3], src[4] = src[4], src[3] - src[8], src[15] = src[15], src[8] - src[9], src[14] = src[14], src[9] - src[10], src[13] = src[13], src[10] - src[11], src[12] = src[12], src[11] - return src -} - -func uuid2bytes(str string) ([]byte, error) { - var uuid [16]byte - strLength := len(str) - if strLength == 0 { - str = NullUUID - } else if strLength != 36 { - return nil, ErrInvalidUUIDFormat - } - if str[8] != '-' || str[13] != '-' || str[18] != '-' || str[23] != '-' { - return nil, ErrInvalidUUIDFormat - } - for i, x := range [16]int{ - 0, 2, 4, 6, - 9, 11, 14, 16, - 19, 21, 24, 26, - 28, 30, 32, 34, - } { - if v, ok := xtob(str[x], str[x+1]); !ok { - return nil, ErrInvalidUUIDFormat - } else { - uuid[i] = v - } - } - return uuid[:], nil -} - -// xvalues returns the value of a byte as a hexadecimal digit or 255. -var xvalues = [256]byte{ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, - 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -} - -// xtob converts hex characters x1 and x2 into a byte. -func xtob(x1, x2 byte) (byte, bool) { - b1 := xvalues[x1] - b2 := xvalues[x2] - return (b1 << 4) | b2, b1 != 255 && b2 != 255 -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/data/block.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/data/block.go deleted file mode 100644 index a3417821..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/data/block.go +++ /dev/null @@ -1,323 +0,0 @@ -package data - -import ( - "bytes" - "database/sql/driver" - "fmt" - "io" - "reflect" - "strings" - - "github.com/ClickHouse/clickhouse-go/lib/binary" - "github.com/ClickHouse/clickhouse-go/lib/column" -) - -type offset [][]int - -type Block struct { - Values [][]interface{} - Columns []column.Column - NumRows uint64 - NumColumns uint64 - offsets []offset - buffers []*buffer - info blockInfo -} - -func (block *Block) Copy() *Block { - return &Block{ - Columns: block.Columns, - NumColumns: block.NumColumns, - info: block.info, - } -} - -func (block *Block) ColumnNames() []string { - names := make([]string, 0, len(block.Columns)) - for _, column := range block.Columns { - names = append(names, column.Name()) - } - return names -} - -func (block *Block) Read(serverInfo *ServerInfo, decoder *binary.Decoder) (err error) { - if serverInfo.Revision > 0 { - if err = block.info.read(decoder); err != nil { - return err - } - } - - if block.NumColumns, err = decoder.Uvarint(); err != nil { - return err - } - if block.NumRows, err = decoder.Uvarint(); err != nil { - return err - } - block.Values = make([][]interface{}, block.NumColumns) - if block.NumRows > 10 { - for i := 0; i < int(block.NumColumns); i++ { - block.Values[i] = make([]interface{}, 0, block.NumRows) - } - } - for i := 0; i < int(block.NumColumns); i++ { - var ( - value interface{} - columnName string - columnType string - ) - if columnName, err = decoder.String(); err != nil { - return err - } - if columnType, err = decoder.String(); err != nil { - return err - } - c, err := column.Factory(columnName, columnType, serverInfo.Timezone) - if err != nil { - return err - } - block.Columns = append(block.Columns, c) - switch column := c.(type) { - case *column.Array: - if block.Values[i], err = column.ReadArray(decoder, int(block.NumRows)); err != nil { - return err - } - case *column.Nullable: - if block.Values[i], err = column.ReadNull(decoder, int(block.NumRows)); err != nil { - return err - } - case *column.Tuple: - if block.Values[i], err = column.ReadTuple(decoder, int(block.NumRows)); err != nil { - return err - } - default: - for row := 0; row < int(block.NumRows); row++ { - if value, err = column.Read(decoder, false); err != nil { - return err - } - block.Values[i] = append(block.Values[i], value) - } - } - } - return nil -} - -func (block *Block) writeArray(col column.Column, value Value, num, level int) error { - if level > col.Depth() { - arrColumn, ok := col.(*column.Array) - if ok && strings.Contains(col.CHType(), "Nullable") { - return arrColumn.WriteNull(block.buffers[num].Offset, block.buffers[num].Column, value.Interface()) - } - return col.Write(block.buffers[num].Column, value.Interface()) - } - - switch { - case value.Kind() == reflect.Slice: - if len(block.offsets[num]) < level { - block.offsets[num] = append(block.offsets[num], []int{value.Len()}) - } else { - block.offsets[num][level-1] = append( - block.offsets[num][level-1], - block.offsets[num][level-1][len(block.offsets[num][level-1])-1]+value.Len(), - ) - } - for i := 0; i < value.Len(); i++ { - if err := block.writeArray(col, value.Index(i), num, level+1); err != nil { - return err - } - } - default: - if err := col.Write(block.buffers[num].Column, value.Interface()); err != nil { - return err - } - } - return nil -} - -func (block *Block) AppendRow(args []driver.Value) error { - if len(block.Columns) != len(args) { - return fmt.Errorf("block: expected %d arguments (columns: %s), got %d", len(block.Columns), strings.Join(block.ColumnNames(), ", "), len(args)) - } - block.Reserve() - { - block.NumRows++ - } - for num, c := range block.Columns { - switch column := c.(type) { - case *column.Array: - value := reflect.ValueOf(args[num]) - if value.Kind() != reflect.Slice { - return fmt.Errorf("unsupported Array(T) type [%T]", value.Interface()) - } - if err := block.writeArray(c, newValue(value), num, 1); err != nil { - return err - } - case *column.Nullable: - if err := column.WriteNull(block.buffers[num].Offset, block.buffers[num].Column, args[num]); err != nil { - return err - } - default: - if err := column.Write(block.buffers[num].Column, args[num]); err != nil { - return err - } - } - } - return nil -} - -func (block *Block) Reserve() { - if len(block.buffers) == 0 { - block.buffers = make([]*buffer, len(block.Columns)) - block.offsets = make([]offset, len(block.Columns)) - for i := 0; i < len(block.Columns); i++ { - var ( - offsetBuffer = new(bytes.Buffer) - columnBuffer = new(bytes.Buffer) - ) - block.buffers[i] = &buffer{ - Offset: binary.NewEncoder(offsetBuffer), - Column: binary.NewEncoder(columnBuffer), - offsetBuffer: offsetBuffer, - columnBuffer: columnBuffer, - } - } - } -} - -func (block *Block) Reset() { - block.NumRows = 0 - block.NumColumns = 0 - block.Values = block.Values[:0] - block.Columns = block.Columns[:0] - block.info.reset() - for _, buffer := range block.buffers { - buffer.reset() - } - { - block.offsets = nil - block.buffers = nil - } -} - -func (block *Block) Write(serverInfo *ServerInfo, encoder *binary.Encoder) error { - if serverInfo.Revision > 0 { - if err := block.info.write(encoder); err != nil { - return err - } - } - if err := encoder.Uvarint(block.NumColumns); err != nil { - return err - } - encoder.Uvarint(block.NumRows) - defer func() { - block.NumRows = 0 - for i := range block.offsets { - block.offsets[i] = offset{} - } - }() - for i, column := range block.Columns { - encoder.String(column.Name()) - encoder.String(column.CHType()) - if len(block.buffers) == len(block.Columns) { - for _, offsets := range block.offsets[i] { - for _, offset := range offsets { - if err := encoder.UInt64(uint64(offset)); err != nil { - return err - } - } - } - if _, err := block.buffers[i].WriteTo(encoder); err != nil { - return err - } - } - } - return nil -} - -type blockInfo struct { - num1 uint64 - isOverflows bool - num2 uint64 - bucketNum int32 - num3 uint64 -} - -func (info *blockInfo) reset() { - info.num1 = 0 - info.isOverflows = false - info.num2 = 0 - info.bucketNum = 0 - info.num3 = 0 -} - -func (info *blockInfo) read(decoder *binary.Decoder) error { - var err error - if info.num1, err = decoder.Uvarint(); err != nil { - return err - } - if info.isOverflows, err = decoder.Bool(); err != nil { - return err - } - if info.num2, err = decoder.Uvarint(); err != nil { - return err - } - if info.bucketNum, err = decoder.Int32(); err != nil { - return err - } - if info.num3, err = decoder.Uvarint(); err != nil { - return err - } - return nil -} - -func (info *blockInfo) write(encoder *binary.Encoder) error { - if err := encoder.Uvarint(1); err != nil { - return err - } - if err := encoder.Bool(info.isOverflows); err != nil { - return err - } - if err := encoder.Uvarint(2); err != nil { - return err - } - if info.bucketNum == 0 { - info.bucketNum = -1 - } - if err := encoder.Int32(info.bucketNum); err != nil { - return err - } - if err := encoder.Uvarint(0); err != nil { - return err - } - return nil -} - -type buffer struct { - Offset *binary.Encoder - Column *binary.Encoder - offsetBuffer *bytes.Buffer - columnBuffer *bytes.Buffer -} - -func (buf *buffer) WriteTo(w io.Writer) (int64, error) { - var size int64 - { - ln, err := buf.offsetBuffer.WriteTo(w) - if err != nil { - return size, err - } - size += ln - } - { - ln, err := buf.columnBuffer.WriteTo(w) - if err != nil { - return size, err - } - size += ln - } - return size, nil -} - -func (buf *buffer) reset() { - buf.offsetBuffer.Reset() - buf.columnBuffer.Reset() -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/data/block_write_column.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/data/block_write_column.go deleted file mode 100644 index b23ec6fd..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/data/block_write_column.go +++ /dev/null @@ -1,277 +0,0 @@ -package data - -import ( - "fmt" - "github.com/ClickHouse/clickhouse-go/lib/column" - "net" - "reflect" - "time" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -func (block *Block) WriteDate(c int, v time.Time) error { - _, offset := v.Zone() - nday := (v.Unix() + int64(offset)) / 24 / 3600 - return block.buffers[c].Column.UInt16(uint16(nday)) -} - -func (block *Block) WriteDateNullable(c int, v *time.Time) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.UInt16(0) - } - return block.WriteDate(c, *v) -} - -func (block *Block) WriteDateTime(c int, v time.Time) error { - return block.buffers[c].Column.UInt32(uint32(v.Unix())) -} - -func (block *Block) WriteDateTimeNullable(c int, v *time.Time) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.UInt32(0) - } - return block.buffers[c].Column.UInt32(uint32(v.Unix())) -} - -func (block *Block) WriteBool(c int, v bool) error { - if v { - return block.buffers[c].Column.UInt8(1) - } - return block.buffers[c].Column.UInt8(0) -} - -func (block *Block) WriteBoolNullable(c int, v *bool) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil || !(*v) { - return block.buffers[c].Column.UInt8(0) - } - return block.buffers[c].Column.UInt8(1) -} - -func (block *Block) WriteInt8(c int, v int8) error { - return block.buffers[c].Column.Int8(v) -} - -func (block *Block) WriteInt8Nullable(c int, v *int8) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.Int8(0) - } - return block.buffers[c].Column.Int8(*v) -} - -func (block *Block) WriteInt16(c int, v int16) error { - return block.buffers[c].Column.Int16(v) -} - -func (block *Block) WriteInt16Nullable(c int, v *int16) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.Int16(0) - } - return block.buffers[c].Column.Int16(*v) -} - -func (block *Block) WriteInt32(c int, v int32) error { - return block.buffers[c].Column.Int32(v) -} - -func (block *Block) WriteInt32Nullable(c int, v *int32) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.Int32(0) - } - return block.buffers[c].Column.Int32(*v) -} - -func (block *Block) WriteInt64(c int, v int64) error { - return block.buffers[c].Column.Int64(v) -} - -func (block *Block) WriteInt64Nullable(c int, v *int64) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.Int64(0) - } - return block.buffers[c].Column.Int64(*v) -} - -func (block *Block) WriteUInt8(c int, v uint8) error { - return block.buffers[c].Column.UInt8(v) -} - -func (block *Block) WriteUInt8Nullable(c int, v *uint8) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.UInt8(0) - } - return block.buffers[c].Column.UInt8(*v) -} - -func (block *Block) WriteUInt16(c int, v uint16) error { - return block.buffers[c].Column.UInt16(v) -} - -func (block *Block) WriteUInt16Nullable(c int, v *uint16) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.UInt16(0) - } - return block.buffers[c].Column.UInt16(*v) -} - -func (block *Block) WriteUInt32(c int, v uint32) error { - return block.buffers[c].Column.UInt32(v) -} - -func (block *Block) WriteUInt32Nullable(c int, v *uint32) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.UInt32(0) - } - return block.buffers[c].Column.UInt32(*v) -} - -func (block *Block) WriteUInt64(c int, v uint64) error { - return block.buffers[c].Column.UInt64(v) -} - -func (block *Block) WriteUInt64Nullable(c int, v *uint64) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.UInt64(0) - } - return block.buffers[c].Column.UInt64(*v) -} - -func (block *Block) WriteFloat32(c int, v float32) error { - return block.buffers[c].Column.Float32(v) -} - -func (block *Block) WriteFloat32Nullable(c int, v *float32) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.Float32(0) - } - return block.buffers[c].Column.Float32(*v) -} - -func (block *Block) WriteFloat64(c int, v float64) error { - return block.buffers[c].Column.Float64(v) -} - -func (block *Block) WriteFloat64Nullable(c int, v *float64) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.buffers[c].Column.Float64(0) - } - return block.buffers[c].Column.Float64(*v) -} - -func (block *Block) WriteBytes(c int, v []byte) error { - if err := block.buffers[c].Column.Uvarint(uint64(len(v))); err != nil { - return err - } - if _, err := block.buffers[c].Column.Write(v); err != nil { - return err - } - return nil -} - -func (block *Block) WriteBytesNullable(c int, v *[]byte) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.WriteBytes(c, []byte{}) - } - return block.WriteBytes(c, *v) -} - -func (block *Block) WriteString(c int, v string) error { - if err := block.buffers[c].Column.Uvarint(uint64(len(v))); err != nil { - return err - } - if _, err := block.buffers[c].Column.Write(binary.Str2Bytes(v)); err != nil { - return err - } - return nil -} - -func (block *Block) WriteStringNullable(c int, v *string) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.WriteString(c, "") - } - return block.WriteString(c, *v) -} - -func (block *Block) WriteFixedString(c int, v []byte) error { - return block.Columns[c].Write(block.buffers[c].Column, v) -} - -func (block *Block) WriteFixedStringNullable(c int, v *[]byte) error { - writer := block.Columns[c].(*column.Nullable) - return writer.WriteNull(block.buffers[c].Offset, block.buffers[c].Column, v) -} - -func (block *Block) WriteIP(c int, v net.IP) error { - return block.Columns[c].Write(block.buffers[c].Column, v) -} - -func (block *Block) WriteIPNullable(c int, v net.IP) error { - writer := block.Columns[c].(*column.Nullable) - return writer.WriteNull(block.buffers[c].Offset, block.buffers[c].Column, v) -} - -func (block *Block) WriteArray(c int, v interface{}) error { - return block.WriteArrayWithValue(c, newValue(reflect.ValueOf(v))) -} - -func (block *Block) WriteArrayWithValue(c int, value Value) error { - if value.Kind() != reflect.Slice { - return fmt.Errorf("unsupported Array(T) type [%T]", value.Interface()) - } - return block.writeArray(block.Columns[c], value, c, 1) -} - -func (block *Block) WriteArrayNullable(c int, v *interface{}) error { - if err := block.buffers[c].Offset.Bool(v == nil); err != nil { - return err - } - if v == nil { - return block.Columns[c].Write(block.buffers[c].Column, []string{}) - } - return block.WriteArray(c, *v) -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/data/client_info.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/data/client_info.go deleted file mode 100644 index 0bff4198..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/data/client_info.go +++ /dev/null @@ -1,29 +0,0 @@ -package data - -import ( - "fmt" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -const ClientName = "Golang SQLDriver" - -const ( - ClickHouseRevision = 54213 - ClickHouseDBMSVersionMajor = 1 - ClickHouseDBMSVersionMinor = 1 -) - -type ClientInfo struct{} - -func (ClientInfo) Write(encoder *binary.Encoder) error { - encoder.String(ClientName) - encoder.Uvarint(ClickHouseDBMSVersionMajor) - encoder.Uvarint(ClickHouseDBMSVersionMinor) - encoder.Uvarint(ClickHouseRevision) - return nil -} - -func (ClientInfo) String() string { - return fmt.Sprintf("%s %d.%d.%d", ClientName, ClickHouseDBMSVersionMajor, ClickHouseDBMSVersionMinor, ClickHouseRevision) -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/data/server_info.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/data/server_info.go deleted file mode 100644 index a6c90bed..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/data/server_info.go +++ /dev/null @@ -1,47 +0,0 @@ -package data - -import ( - "fmt" - //"io" - "time" - - "github.com/ClickHouse/clickhouse-go/lib/binary" - "github.com/ClickHouse/clickhouse-go/lib/protocol" -) - -type ServerInfo struct { - Name string - Revision uint64 - MinorVersion uint64 - MajorVersion uint64 - Timezone *time.Location -} - -func (srv *ServerInfo) Read(decoder *binary.Decoder) (err error) { - if srv.Name, err = decoder.String(); err != nil { - return fmt.Errorf("could not read server name: %v", err) - } - if srv.MajorVersion, err = decoder.Uvarint(); err != nil { - return fmt.Errorf("could not read server major version: %v", err) - } - if srv.MinorVersion, err = decoder.Uvarint(); err != nil { - return fmt.Errorf("could not read server minor version: %v", err) - } - if srv.Revision, err = decoder.Uvarint(); err != nil { - return fmt.Errorf("could not read server revision: %v", err) - } - if srv.Revision >= protocol.DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE { - timezone, err := decoder.String() - if err != nil { - return fmt.Errorf("could not read server timezone: %v", err) - } - if srv.Timezone, err = time.LoadLocation(timezone); err != nil { - return fmt.Errorf("could not load time location: %v", err) - } - } - return nil -} - -func (srv ServerInfo) String() string { - return fmt.Sprintf("%s %d.%d.%d (%s)", srv.Name, srv.MajorVersion, srv.MinorVersion, srv.Revision, srv.Timezone) -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/data/value.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/data/value.go deleted file mode 100644 index 3c7e4ede..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/data/value.go +++ /dev/null @@ -1,33 +0,0 @@ -package data - -import "reflect" - -// Value is a writable value. -type Value interface { - // Kind returns value's Kind. - Kind() reflect.Kind - - // Len returns value's length. - // It panics if value's Kind is not Array, Chan, Map, Slice, or String. - Len() int - - // Index returns value's i'th element. - // It panics if value's Kind is not Array, Slice, or String or i is out of range. - Index(i int) Value - - // Interface returns value's current value as an interface{}. - Interface() interface{} -} - -// value is a wrapper that wraps reflect.Value to comply with Value interface. -type value struct { - reflect.Value -} - -func newValue(v reflect.Value) Value { - return value{Value: v} -} - -func (v value) Index(i int) Value { - return newValue(v.Value.Index(i)) -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/LICENSE b/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/LICENSE deleted file mode 100644 index 85cbc1df..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2011-2012 Branimir Karadzic. All rights reserved. -Copyright 2013 Damian Gryski. All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/doc.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/doc.go deleted file mode 100644 index 091981c8..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2011-2012 Branimir Karadzic. All rights reserved. -// Copyright 2013 Damian Gryski. All rights reserved. - -// @LINK: https://github.com/bkaradzic/go-lz4 -// @NOTE: The code is modified to be high performance and less memory usage - -package lz4 diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/fuzz.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/fuzz.go deleted file mode 100644 index e4989de9..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/fuzz.go +++ /dev/null @@ -1,23 +0,0 @@ -// +build gofuzz - -package lz4 - -import "encoding/binary" - -func Fuzz(data []byte) int { - - if len(data) < 4 { - return 0 - } - - ln := binary.LittleEndian.Uint32(data) - if ln > (1 << 21) { - return 0 - } - - if _, err := Decode(nil, data); err != nil { - return 0 - } - - return 1 -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/reader.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/reader.go deleted file mode 100644 index f8d38ea2..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/reader.go +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2011-2012 Branimir Karadzic. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -package lz4 - -import ( - "errors" - "io" -) - -var ( - // ErrCorrupt indicates the input was corrupt - ErrCorrupt = errors.New("corrupt input") -) - -const ( - mlBits = 4 - mlMask = (1 << mlBits) - 1 - runBits = 8 - mlBits - runMask = (1 << runBits) - 1 -) - -type decoder struct { - src []byte - dst []byte - spos uint32 - dpos uint32 - ref uint32 -} - -func (d *decoder) readByte() (uint8, error) { - if int(d.spos) == len(d.src) { - return 0, io.EOF - } - b := d.src[d.spos] - d.spos++ - return b, nil -} - -func (d *decoder) getLen() (uint32, error) { - - length := uint32(0) - ln, err := d.readByte() - if err != nil { - return 0, ErrCorrupt - } - for ln == 255 { - length += 255 - ln, err = d.readByte() - if err != nil { - return 0, ErrCorrupt - } - } - length += uint32(ln) - - return length, nil -} - -func (d *decoder) cp(length, decr uint32) { - - if int(d.ref+length) < int(d.dpos) { - copy(d.dst[d.dpos:], d.dst[d.ref:d.ref+length]) - } else { - for ii := uint32(0); ii < length; ii++ { - d.dst[d.dpos+ii] = d.dst[d.ref+ii] - } - } - d.dpos += length - d.ref += length - decr -} - -func (d *decoder) finish(err error) error { - if err == io.EOF { - return nil - } - - return err -} - -// Decode returns the decoded form of src. The returned slice may be a -// subslice of dst if it was large enough to hold the entire decoded block. -func Decode(dst, src []byte) (int, error) { - d := decoder{src: src, dst: dst, spos: 0} - - decr := []uint32{0, 3, 2, 3} - - for { - code, err := d.readByte() - if err != nil { - return len(d.dst), d.finish(err) - } - - length := uint32(code >> mlBits) - if length == runMask { - ln, err := d.getLen() - if err != nil { - return 0, ErrCorrupt - } - length += ln - } - - if int(d.spos+length) > len(d.src) || int(d.dpos+length) > len(d.dst) { - return 0, ErrCorrupt - } - - for ii := uint32(0); ii < length; ii++ { - d.dst[d.dpos+ii] = d.src[d.spos+ii] - } - - d.spos += length - d.dpos += length - - if int(d.spos) == len(d.src) { - return len(d.dst), nil - } - - if int(d.spos+2) >= len(d.src) { - return 0, ErrCorrupt - } - - back := uint32(d.src[d.spos]) | uint32(d.src[d.spos+1])<<8 - - if back > d.dpos { - return 0, ErrCorrupt - } - - d.spos += 2 - d.ref = d.dpos - back - - length = uint32(code & mlMask) - if length == mlMask { - ln, err := d.getLen() - if err != nil { - return 0, ErrCorrupt - } - length += ln - } - - literal := d.dpos - d.ref - - if literal < 4 { - if int(d.dpos+4) > len(d.dst) { - return 0, ErrCorrupt - } - - d.cp(4, decr[literal]) - } else { - length += 4 - } - - if int(d.dpos+length) > len(d.dst) { - return 0, ErrCorrupt - } - - d.cp(length, 0) - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/writer.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/writer.go deleted file mode 100644 index 969311be..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/writer.go +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2011-2012 Branimir Karadzic. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -package lz4 - -import ( - "errors" - "sync" -) - -const ( - minMatch = 4 - hashLog = 16 - hashTableSize = 1 << hashLog - hashShift = (minMatch * 8) - hashLog - incompressible uint32 = 128 - uninitHash = 0x88888888 - - mfLimit = 8 + minMatch // The last match cannot start within the last 12 bytes. - // MaxInputSize is the largest buffer than can be compressed in a single block - MaxInputSize = 0x7E000000 -) - -var ( - // ErrTooLarge indicates the input buffer was too large - ErrTooLarge = errors.New("input too large") - ErrEncodeTooSmall = errors.New("encode buffer too small") - - hashPool = sync.Pool{ - New: func() interface{} { - return make([]uint32, hashTableSize) - }, - } -) - -type encoder struct { - src []byte - dst []byte - hashTable []uint32 - pos uint32 - anchor uint32 - dpos uint32 -} - -// CompressBound returns the maximum length of a lz4 block -func CompressBound(isize int) int { - if isize > MaxInputSize { - return 0 - } - return isize + ((isize) / 255) + 16 -} - -func (e *encoder) writeLiterals(length, mlLen, pos uint32) { - - ln := length - - var code byte - if ln > runMask-1 { - code = runMask - } else { - code = byte(ln) - } - - if mlLen > mlMask-1 { - e.dst[e.dpos] = (code << mlBits) + byte(mlMask) - } else { - e.dst[e.dpos] = (code << mlBits) + byte(mlLen) - } - e.dpos++ - - if code == runMask { - ln -= runMask - for ; ln > 254; ln -= 255 { - e.dst[e.dpos] = 255 - e.dpos++ - } - - e.dst[e.dpos] = byte(ln) - e.dpos++ - } - - for ii := uint32(0); ii < length; ii++ { - e.dst[e.dpos+ii] = e.src[pos+ii] - } - - e.dpos += length -} - -// Encode returns the encoded form of src. The returned array may be a -// sub-slice of dst if it was large enough to hold the entire output. -func Encode(dst, src []byte) (compressedSize int, error error) { - if len(src) >= MaxInputSize { - return 0, ErrTooLarge - } - - if n := CompressBound(len(src)); len(dst) < n { - return 0, ErrEncodeTooSmall - } - - hashTable := hashPool.Get().([]uint32) - for i := range hashTable { - hashTable[i] = 0 - } - e := encoder{src: src, dst: dst, hashTable: hashTable} - defer func() { - hashPool.Put(hashTable) - }() - // binary.LittleEndian.PutUint32(dst, uint32(len(src))) - // e.dpos = 0 - - var ( - step uint32 = 1 - limit = incompressible - ) - - for { - if int(e.pos)+12 >= len(e.src) { - e.writeLiterals(uint32(len(e.src))-e.anchor, 0, e.anchor) - return int(e.dpos), nil - } - - sequence := uint32(e.src[e.pos+3])<<24 | uint32(e.src[e.pos+2])<<16 | uint32(e.src[e.pos+1])<<8 | uint32(e.src[e.pos+0]) - - hash := (sequence * 2654435761) >> hashShift - ref := e.hashTable[hash] + uninitHash - e.hashTable[hash] = e.pos - uninitHash - - if ((e.pos-ref)>>16) != 0 || uint32(e.src[ref+3])<<24|uint32(e.src[ref+2])<<16|uint32(e.src[ref+1])<<8|uint32(e.src[ref+0]) != sequence { - if e.pos-e.anchor > limit { - limit <<= 1 - step += 1 + (step >> 2) - } - e.pos += step - continue - } - - if step > 1 { - e.hashTable[hash] = ref - uninitHash - e.pos -= step - 1 - step = 1 - continue - } - limit = incompressible - - ln := e.pos - e.anchor - back := e.pos - ref - - anchor := e.anchor - - e.pos += minMatch - ref += minMatch - e.anchor = e.pos - - for int(e.pos) < len(e.src)-5 && e.src[e.pos] == e.src[ref] { - e.pos++ - ref++ - } - - mlLen := e.pos - e.anchor - - e.writeLiterals(ln, mlLen, anchor) - e.dst[e.dpos] = uint8(back) - e.dst[e.dpos+1] = uint8(back >> 8) - e.dpos += 2 - - if mlLen > mlMask-1 { - mlLen -= mlMask - for mlLen > 254 { - mlLen -= 255 - - e.dst[e.dpos] = 255 - e.dpos++ - } - - e.dst[e.dpos] = byte(mlLen) - e.dpos++ - } - - e.anchor = e.pos - } -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/protocol/README.md b/vendor/github.com/ClickHouse/clickhouse-go/lib/protocol/README.md deleted file mode 100644 index 84fdd48c..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/protocol/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# ClickHouse Native protocol - -# Handshake - diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/protocol/protocol.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/protocol/protocol.go deleted file mode 100644 index ba5fd7c7..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/protocol/protocol.go +++ /dev/null @@ -1,35 +0,0 @@ -package protocol - -const ( - DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE = 54058 - DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO = 54060 -) - -const ( - ClientHello = 0 - ClientQuery = 1 - ClientData = 2 - ClientCancel = 3 - ClientPing = 4 -) - -const ( - CompressEnable uint64 = 1 - CompressDisable uint64 = 0 -) - -const ( - StateComplete = 2 -) - -const ( - ServerHello = 0 - ServerData = 1 - ServerException = 2 - ServerProgress = 3 - ServerPong = 4 - ServerEndOfStream = 5 - ServerProfileInfo = 6 - ServerTotals = 7 - ServerExtremes = 8 -) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/types/date.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/types/date.go deleted file mode 100644 index a7d0143b..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/types/date.go +++ /dev/null @@ -1,48 +0,0 @@ -// Timezoneless date/datetime types - -package types - -import ( - "database/sql/driver" - "time" -) - -// Truncate timezone -// -// clickhouse.Date(time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local)) -> time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC) -type Date time.Time - -func (date Date) Value() (driver.Value, error) { - return date.convert(), nil -} - -func (date Date) convert() time.Time { - return time.Date(time.Time(date).Year(), time.Time(date).Month(), time.Time(date).Day(), 0, 0, 0, 0, time.UTC) -} - -// Truncate timezone -// -// clickhouse.DateTime(time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local)) -> time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC) -type DateTime time.Time - -func (datetime DateTime) Value() (driver.Value, error) { - return datetime.convert(), nil -} - -func (datetime DateTime) convert() time.Time { - return time.Date( - time.Time(datetime).Year(), - time.Time(datetime).Month(), - time.Time(datetime).Day(), - time.Time(datetime).Hour(), - time.Time(datetime).Minute(), - time.Time(datetime).Second(), - 1, - time.UTC, - ) -} - -var ( - _ driver.Valuer = Date{} - _ driver.Valuer = DateTime{} -) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/types/uuid.go b/vendor/github.com/ClickHouse/clickhouse-go/lib/types/uuid.go deleted file mode 100644 index dc270a85..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/types/uuid.go +++ /dev/null @@ -1,99 +0,0 @@ -package types - -import ( - "database/sql/driver" - "encoding/hex" - "errors" - "fmt" -) - -var InvalidUUIDFormatError = errors.New("invalid UUID format") - -// this type will be deprecated because the ClickHouse server (>=1.1.54276) has a built-in type UUID -type UUID string - -func (str UUID) Value() (driver.Value, error) { - return uuid2bytes(string(str)) -} - -func (str UUID) MarshalBinary() ([]byte, error) { - return uuid2bytes(string(str)) -} - -func (str *UUID) Scan(v interface{}) error { - var src []byte - switch v := v.(type) { - case string: - src = []byte(v) - case []byte: - src = v - } - - if len(src) != 16 { - return fmt.Errorf("invalid UUID length: %d", len(src)) - } - - var uuid [36]byte - { - hex.Encode(uuid[:], src[:4]) - uuid[8] = '-' - hex.Encode(uuid[9:13], src[4:6]) - uuid[13] = '-' - hex.Encode(uuid[14:18], src[6:8]) - uuid[18] = '-' - hex.Encode(uuid[19:23], src[8:10]) - uuid[23] = '-' - hex.Encode(uuid[24:], src[10:]) - } - *str = UUID(uuid[:]) - return nil -} - -func uuid2bytes(str string) ([]byte, error) { - var uuid [16]byte - if str[8] != '-' || str[13] != '-' || str[18] != '-' || str[23] != '-' { - return nil, InvalidUUIDFormatError - } - for i, x := range [16]int{ - 0, 2, 4, 6, - 9, 11, 14, 16, - 19, 21, 24, 26, - 28, 30, 32, 34, - } { - if v, ok := xtob(str[x], str[x+1]); !ok { - return nil, InvalidUUIDFormatError - } else { - uuid[i] = v - } - } - return uuid[:], nil -} - -// xvalues returns the value of a byte as a hexadecimal digit or 255. -var xvalues = [256]byte{ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, - 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -} - -// xtob converts hex characters x1 and x2 into a byte. -func xtob(x1, x2 byte) (byte, bool) { - b1 := xvalues[x1] - b2 := xvalues[x2] - return (b1 << 4) | b2, b1 != 255 && b2 != 255 -} - -var _ driver.Valuer = UUID("") diff --git a/vendor/github.com/ClickHouse/clickhouse-go/query_settings.go b/vendor/github.com/ClickHouse/clickhouse-go/query_settings.go deleted file mode 100644 index 506728cc..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/query_settings.go +++ /dev/null @@ -1,286 +0,0 @@ -package clickhouse - -import ( - "fmt" - "net/url" - "strconv" - - "github.com/ClickHouse/clickhouse-go/lib/binary" -) - -type querySettingType int - -// all possible query setting's data type -const ( - uintQS querySettingType = iota + 1 - intQS - boolQS - timeQS -) - -// description of single query setting -type querySettingInfo struct { - name string - qsType querySettingType -} - -// all possible query settings -var querySettingList = []querySettingInfo{ - {"min_compress_block_size", uintQS}, - {"max_compress_block_size", uintQS}, - {"max_block_size", uintQS}, - {"max_insert_block_size", uintQS}, - {"min_insert_block_size_rows", uintQS}, - {"min_insert_block_size_bytes", uintQS}, - {"max_read_buffer_size", uintQS}, - {"max_distributed_connections", uintQS}, - {"max_query_size", uintQS}, - {"interactive_delay", uintQS}, - {"poll_interval", uintQS}, - {"distributed_connections_pool_size", uintQS}, - {"connections_with_failover_max_tries", uintQS}, - {"background_pool_size", uintQS}, - {"background_schedule_pool_size", uintQS}, - {"replication_alter_partitions_sync", uintQS}, - {"replication_alter_columns_timeout", uintQS}, - {"min_count_to_compile", uintQS}, - {"min_count_to_compile_expression", uintQS}, - {"group_by_two_level_threshold", uintQS}, - {"group_by_two_level_threshold_bytes", uintQS}, - {"aggregation_memory_efficient_merge_threads", uintQS}, - {"max_parallel_replicas", uintQS}, - {"parallel_replicas_count", uintQS}, - {"parallel_replica_offset", uintQS}, - {"merge_tree_min_rows_for_concurrent_read", uintQS}, - {"merge_tree_min_bytes_for_concurrent_read", uintQS}, - {"merge_tree_min_rows_for_seek", uintQS}, - {"merge_tree_min_bytes_for_seek", uintQS}, - {"merge_tree_coarse_index_granularity", uintQS}, - {"merge_tree_max_rows_to_use_cache", uintQS}, - {"merge_tree_max_bytes_to_use_cache", uintQS}, - {"mysql_max_rows_to_insert", uintQS}, - {"optimize_min_equality_disjunction_chain_length", uintQS}, - {"min_bytes_to_use_direct_io", uintQS}, - {"mark_cache_min_lifetime", uintQS}, - {"priority", uintQS}, - {"log_queries_cut_to_length", uintQS}, - {"max_concurrent_queries_for_user", uintQS}, - {"insert_quorum", uintQS}, - {"select_sequential_consistency", uintQS}, - {"table_function_remote_max_addresses", uintQS}, - {"read_backoff_max_throughput", uintQS}, - {"read_backoff_min_events", uintQS}, - {"output_format_pretty_max_rows", uintQS}, - {"output_format_pretty_max_column_pad_width", uintQS}, - {"output_format_parquet_row_group_size", uintQS}, - {"http_headers_progress_interval_ms", uintQS}, - {"input_format_allow_errors_num", uintQS}, - {"preferred_block_size_bytes", uintQS}, - {"max_replica_delay_for_distributed_queries", uintQS}, - {"preferred_max_column_in_block_size_bytes", uintQS}, - {"insert_distributed_timeout", uintQS}, - {"odbc_max_field_size", uintQS}, - {"max_rows_to_read", uintQS}, - {"max_bytes_to_read", uintQS}, - {"max_rows_to_group_by", uintQS}, - {"max_bytes_before_external_group_by", uintQS}, - {"max_rows_to_sort", uintQS}, - {"max_bytes_to_sort", uintQS}, - {"max_bytes_before_external_sort", uintQS}, - {"max_bytes_before_remerge_sort", uintQS}, - {"max_result_rows", uintQS}, - {"max_result_bytes", uintQS}, - {"min_execution_speed", uintQS}, - {"max_execution_speed", uintQS}, - {"min_execution_speed_bytes", uintQS}, - {"max_execution_speed_bytes", uintQS}, - {"max_columns_to_read", uintQS}, - {"max_temporary_columns", uintQS}, - {"max_temporary_non_const_columns", uintQS}, - {"max_subquery_depth", uintQS}, - {"max_pipeline_depth", uintQS}, - {"max_ast_depth", uintQS}, - {"max_ast_elements", uintQS}, - {"max_expanded_ast_elements", uintQS}, - {"readonly", uintQS}, - {"max_rows_in_set", uintQS}, - {"max_bytes_in_set", uintQS}, - {"max_rows_in_join", uintQS}, - {"max_bytes_in_join", uintQS}, - {"max_rows_to_transfer", uintQS}, - {"max_bytes_to_transfer", uintQS}, - {"max_rows_in_distinct", uintQS}, - {"max_bytes_in_distinct", uintQS}, - {"max_memory_usage", uintQS}, - {"max_memory_usage_for_user", uintQS}, - {"max_memory_usage_for_all_queries", uintQS}, - {"max_network_bandwidth", uintQS}, - {"max_network_bytes", uintQS}, - {"max_network_bandwidth_for_user", uintQS}, - {"max_network_bandwidth_for_all_users", uintQS}, - {"low_cardinality_max_dictionary_size", uintQS}, - {"max_fetch_partition_retries_count", uintQS}, - {"http_max_multipart_form_data_size", uintQS}, - {"max_partitions_per_insert_block", uintQS}, - {"max_threads", uintQS}, - {"optimize_skip_unused_shards_nesting", uintQS}, - {"force_optimize_skip_unused_shards", uintQS}, - {"force_optimize_skip_unused_shards_nesting", uintQS}, - - {"network_zstd_compression_level", intQS}, - {"http_zlib_compression_level", intQS}, - {"distributed_ddl_task_timeout", intQS}, - - {"extremes", boolQS}, - {"use_uncompressed_cache", boolQS}, - {"replace_running_query", boolQS}, - {"distributed_directory_monitor_batch_inserts", boolQS}, - {"optimize_move_to_prewhere", boolQS}, - {"compile", boolQS}, - {"allow_suspicious_low_cardinality_types", boolQS}, - {"compile_expressions", boolQS}, - {"distributed_aggregation_memory_efficient", boolQS}, - {"skip_unavailable_shards", boolQS}, - {"distributed_group_by_no_merge", boolQS}, - {"optimize_skip_unused_shards", boolQS}, - {"merge_tree_uniform_read_distribution", boolQS}, - {"force_index_by_date", boolQS}, - {"force_primary_key", boolQS}, - {"log_queries", boolQS}, - {"insert_deduplicate", boolQS}, - {"enable_http_compression", boolQS}, - {"http_native_compression_disable_checksumming_on_decompress", boolQS}, - {"output_format_write_statistics", boolQS}, - {"add_http_cors_header", boolQS}, - {"input_format_skip_unknown_fields", boolQS}, - {"input_format_with_names_use_header", boolQS}, - {"input_format_import_nested_json", boolQS}, - {"input_format_defaults_for_omitted_fields", boolQS}, - {"input_format_values_interpret_expressions", boolQS}, - {"output_format_json_quote_64bit_integers", boolQS}, - {"output_format_json_quote_denormals", boolQS}, - {"output_format_json_escape_forward_slashes", boolQS}, - {"output_format_pretty_color", boolQS}, - {"use_client_time_zone", boolQS}, - {"send_progress_in_http_headers", boolQS}, - {"fsync_metadata", boolQS}, - {"join_use_nulls", boolQS}, - {"fallback_to_stale_replicas_for_distributed_queries", boolQS}, - {"insert_distributed_sync", boolQS}, - {"insert_allow_materialized_columns", boolQS}, - {"optimize_throw_if_noop", boolQS}, - {"use_index_for_in_with_subqueries", boolQS}, - {"empty_result_for_aggregation_by_empty_set", boolQS}, - {"allow_distributed_ddl", boolQS}, - {"join_any_take_last_row", boolQS}, - {"format_csv_allow_single_quotes", boolQS}, - {"format_csv_allow_double_quotes", boolQS}, - {"log_profile_events", boolQS}, - {"log_query_settings", boolQS}, - {"log_query_threads", boolQS}, - {"enable_optimize_predicate_expression", boolQS}, - {"low_cardinality_use_single_dictionary_for_part", boolQS}, - {"decimal_check_overflow", boolQS}, - {"prefer_localhost_replica", boolQS}, - //{"asterisk_left_columns_only", boolQS}, - {"calculate_text_stack_trace", boolQS}, - {"allow_ddl", boolQS}, - {"parallel_view_processing", boolQS}, - {"enable_debug_queries", boolQS}, - {"enable_unaligned_array_join", boolQS}, - {"low_cardinality_allow_in_native_format", boolQS}, - {"allow_experimental_multiple_joins_emulation", boolQS}, - {"allow_experimental_cross_to_join_conversion", boolQS}, - {"cancel_http_readonly_queries_on_client_close", boolQS}, - {"external_table_functions_use_nulls", boolQS}, - {"allow_experimental_data_skipping_indices", boolQS}, - {"allow_hyperscan", boolQS}, - {"allow_simdjson", boolQS}, - - {"connect_timeout", timeQS}, - {"connect_timeout_with_failover_ms", timeQS}, - {"receive_timeout", timeQS}, - {"send_timeout", timeQS}, - {"tcp_keep_alive_timeout", timeQS}, - {"queue_max_wait_ms", timeQS}, - {"distributed_directory_monitor_sleep_time_ms", timeQS}, - {"insert_quorum_timeout", timeQS}, - {"read_backoff_min_latency_ms", timeQS}, - {"read_backoff_min_interval_between_events_ms", timeQS}, - {"stream_flush_interval_ms", timeQS}, - {"stream_poll_timeout_ms", timeQS}, - {"http_connection_timeout", timeQS}, - {"http_send_timeout", timeQS}, - {"http_receive_timeout", timeQS}, - {"max_execution_time", timeQS}, - {"timeout_before_checking_execution_speed", timeQS}, -} - -type querySettingValueEncoder func(enc *binary.Encoder) error - -type querySettings struct { - settings map[string]querySettingValueEncoder - settingsStr string // used for debug output -} - -func makeQuerySettings(query url.Values) (*querySettings, error) { - qs := &querySettings{ - settings: make(map[string]querySettingValueEncoder), - settingsStr: "", - } - - for _, info := range querySettingList { - valueStr := query.Get(info.name) - if valueStr == "" { - continue - } - - switch info.qsType { - case uintQS, intQS, timeQS: - value, err := strconv.ParseUint(valueStr, 10, 64) - if err != nil { - return nil, err - } - qs.settings[info.name] = func(enc *binary.Encoder) error { return enc.Uvarint(value) } - - case boolQS: - valueBool, err := strconv.ParseBool(valueStr) - if err != nil { - return nil, err - } - value := uint64(0) - if valueBool { - value = 1 - } - qs.settings[info.name] = func(enc *binary.Encoder) error { return enc.Uvarint(value) } - - default: - err := fmt.Errorf("query setting %s has unsupported data type", info.name) - return nil, err - } - - if qs.settingsStr != "" { - qs.settingsStr += "&" - } - qs.settingsStr += info.name + "=" + valueStr - } - - return qs, nil -} - -func (qs *querySettings) IsEmpty() bool { - return len(qs.settings) == 0 -} - -func (qs *querySettings) Serialize(enc *binary.Encoder) error { - for name, fn := range qs.settings { - if err := enc.String(name); err != nil { - return err - } - if err := fn(enc); err != nil { - return err - } - } - - return nil -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/result.go b/vendor/github.com/ClickHouse/clickhouse-go/result.go deleted file mode 100644 index fc08cf4d..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/result.go +++ /dev/null @@ -1,8 +0,0 @@ -package clickhouse - -import "errors" - -type result struct{} - -func (*result) LastInsertId() (int64, error) { return 0, errors.New("LastInsertId is not supported") } -func (*result) RowsAffected() (int64, error) { return 0, errors.New("RowsAffected is not supported") } diff --git a/vendor/github.com/ClickHouse/clickhouse-go/rows.go b/vendor/github.com/ClickHouse/clickhouse-go/rows.go deleted file mode 100644 index 30e844f6..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/rows.go +++ /dev/null @@ -1,182 +0,0 @@ -package clickhouse - -import ( - "database/sql/driver" - "fmt" - "io" - "reflect" - "sync" - "time" - - "github.com/ClickHouse/clickhouse-go/lib/column" - "github.com/ClickHouse/clickhouse-go/lib/data" - "github.com/ClickHouse/clickhouse-go/lib/protocol" -) - -type rows struct { - ch *clickhouse - err error - mutex sync.RWMutex - finish func() - offset int - block *data.Block - totals *data.Block - extremes *data.Block - stream chan *data.Block - columns []string - blockColumns []column.Column -} - -func (rows *rows) Columns() []string { - return rows.columns -} - -func (rows *rows) ColumnTypeScanType(idx int) reflect.Type { - return rows.blockColumns[idx].ScanType() -} - -func (rows *rows) ColumnTypeDatabaseTypeName(idx int) string { - return rows.blockColumns[idx].CHType() -} - -func (rows *rows) Next(dest []driver.Value) error { - if rows.block == nil || int(rows.block.NumRows) <= rows.offset { - switch block, ok := <-rows.stream; true { - case !ok: - if err := rows.error(); err != nil { - return err - } - return io.EOF - default: - rows.block = block - rows.offset = 0 - } - } - for i := range dest { - dest[i] = rows.block.Values[i][rows.offset] - } - rows.offset++ - return nil -} - -func (rows *rows) HasNextResultSet() bool { - return rows.totals != nil || rows.extremes != nil -} - -func (rows *rows) NextResultSet() error { - switch { - case rows.totals != nil: - rows.block = rows.totals - rows.offset = 0 - rows.totals = nil - case rows.extremes != nil: - rows.block = rows.extremes - rows.offset = 0 - rows.extremes = nil - default: - return io.EOF - } - return nil -} - -func (rows *rows) receiveData() error { - defer close(rows.stream) - var ( - err error - packet uint64 - progress *progress - profileInfo *profileInfo - ) - for { - if packet, err = rows.ch.decoder.Uvarint(); err != nil { - return rows.setError(err) - } - switch packet { - case protocol.ServerException: - rows.ch.logf("[rows] <- exception") - return rows.setError(rows.ch.exception()) - case protocol.ServerProgress: - if progress, err = rows.ch.progress(); err != nil { - return rows.setError(err) - } - rows.ch.logf("[rows] <- progress: rows=%d, bytes=%d, total rows=%d", - progress.rows, - progress.bytes, - progress.totalRows, - ) - case protocol.ServerProfileInfo: - if profileInfo, err = rows.ch.profileInfo(); err != nil { - return rows.setError(err) - } - rows.ch.logf("[rows] <- profiling: rows=%d, bytes=%d, blocks=%d", profileInfo.rows, profileInfo.bytes, profileInfo.blocks) - case protocol.ServerData, protocol.ServerTotals, protocol.ServerExtremes: - var ( - block *data.Block - begin = time.Now() - ) - if block, err = rows.ch.readBlock(); err != nil { - return rows.setError(err) - } - rows.ch.logf("[rows] <- data: packet=%d, columns=%d, rows=%d, elapsed=%s", packet, block.NumColumns, block.NumRows, time.Since(begin)) - if block.NumRows == 0 { - continue - } - switch packet { - case protocol.ServerData: - rows.stream <- block - case protocol.ServerTotals: - rows.totals = block - case protocol.ServerExtremes: - rows.extremes = block - } - case protocol.ServerEndOfStream: - rows.ch.logf("[rows] <- end of stream") - return nil - default: - rows.ch.conn.Close() - rows.ch.logf("[rows] unexpected packet [%d]", packet) - return rows.setError(fmt.Errorf("[rows] unexpected packet [%d] from server", packet)) - } - } -} - -func (rows *rows) Close() error { - rows.ch.logf("[rows] close") - rows.columns = nil - for range rows.stream { - } - rows.finish() - return nil -} - -func (rows *rows) error() error { - rows.mutex.RLock() - defer rows.mutex.RUnlock() - return rows.err -} - -func (rows *rows) setError(err error) error { - rows.mutex.Lock() - rows.err = err - rows.mutex.Unlock() - return err -} - -func (rows *rows) ColumnTypeNullable(idx int) (nullable, ok bool) { - _, ok = rows.blockColumns[idx].(*column.Nullable) - return ok, true -} - -func (rows *rows) ColumnTypePrecisionScale(idx int) (precision, scale int64, ok bool) { - decimalVal, ok := rows.blockColumns[idx].(*column.Decimal) - if !ok { - if nullable, nullOk := rows.blockColumns[idx].(*column.Nullable); nullOk { - decimalVal, ok = nullable.GetColumn().(*column.Decimal) - } - } - if ok { - return int64(decimalVal.GetPrecision()), int64(decimalVal.GetScale()), ok - - } - return 0, 0, false -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/stmt.go b/vendor/github.com/ClickHouse/clickhouse-go/stmt.go deleted file mode 100644 index 168a0dfe..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/stmt.go +++ /dev/null @@ -1,215 +0,0 @@ -package clickhouse - -import ( - "bytes" - "context" - "database/sql/driver" - "unicode" - - "github.com/ClickHouse/clickhouse-go/lib/data" -) - -type stmt struct { - ch *clickhouse - query string - counter int - numInput int - isInsert bool -} - -var emptyResult = &result{} - -type key string - -var queryIDKey key - -//Put query ID into context and use it in ExecContext or QueryContext -func WithQueryID(ctx context.Context, queryID string) context.Context { - return context.WithValue(ctx, queryIDKey, queryID) -} - -func (stmt *stmt) NumInput() int { - switch { - case stmt.ch.block != nil: - return len(stmt.ch.block.Columns) - case stmt.numInput < 0: - return 0 - } - return stmt.numInput -} - -func (stmt *stmt) Exec(args []driver.Value) (driver.Result, error) { - return stmt.execContext(context.Background(), args) -} - -func (stmt *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) { - dargs := make([]driver.Value, len(args)) - for i, nv := range args { - dargs[i] = nv.Value - } - return stmt.execContext(ctx, dargs) -} - -func (stmt *stmt) execContext(ctx context.Context, args []driver.Value) (driver.Result, error) { - if stmt.isInsert { - stmt.counter++ - if err := stmt.ch.block.AppendRow(args); err != nil { - return nil, err - } - if (stmt.counter % stmt.ch.blockSize) == 0 { - stmt.ch.logf("[exec] flush block") - if err := stmt.ch.writeBlock(stmt.ch.block, ""); err != nil { - return nil, err - } - if err := stmt.ch.encoder.Flush(); err != nil { - return nil, err - } - } - return emptyResult, nil - } - query, externalTables := stmt.bind(convertOldArgs(args)) - if err := stmt.ch.sendQuery(ctx, query, externalTables); err != nil { - return nil, err - } - if err := stmt.ch.process(); err != nil { - return nil, err - } - return emptyResult, nil -} - -func (stmt *stmt) Query(args []driver.Value) (driver.Rows, error) { - return stmt.queryContext(context.Background(), convertOldArgs(args)) -} - -func (stmt *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) { - return stmt.queryContext(ctx, args) -} - -func (stmt *stmt) queryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) { - finish := stmt.ch.watchCancel(ctx) - query, externalTables := stmt.bind(args) - if err := stmt.ch.sendQuery(ctx, query, externalTables); err != nil { - finish() - return nil, err - } - meta, err := stmt.ch.readMeta() - if err != nil { - finish() - return nil, err - } - rows := rows{ - ch: stmt.ch, - finish: finish, - stream: make(chan *data.Block, 50), - columns: meta.ColumnNames(), - blockColumns: meta.Columns, - } - go rows.receiveData() - return &rows, nil -} - -func (stmt *stmt) Close() error { - stmt.ch.logf("[stmt] close") - return nil -} - -func (stmt *stmt) bind(args []driver.NamedValue) (string, []ExternalTable) { - var ( - buf bytes.Buffer - index int - keyword bool - inBetween bool - like = newMatcher("like") - limit = newMatcher("limit") - offset = newMatcher("offset") - between = newMatcher("between") - and = newMatcher("and") - in = newMatcher("in") - from = newMatcher("from") - join = newMatcher("join") - subSelect = newMatcher("select") - externalTables = make([]ExternalTable, 0) - ) - switch { - case stmt.NumInput() != 0: - reader := bytes.NewReader([]byte(stmt.query)) - for { - if char, _, err := reader.ReadRune(); err == nil { - switch char { - case '@': - if param := paramParser(reader); len(param) != 0 { - for _, v := range args { - if len(v.Name) != 0 && v.Name == param { - switch v := v.Value.(type) { - case ExternalTable: - buf.WriteString(v.Name) - externalTables = append(externalTables, v) - default: - buf.WriteString(quote(v)) - } - } - } - } - case '?': - if keyword && index < len(args) && len(args[index].Name) == 0 { - switch v := args[index].Value.(type) { - case ExternalTable: - buf.WriteString(v.Name) - externalTables = append(externalTables, v) - default: - buf.WriteString(quote(v)) - } - index++ - } else { - buf.WriteRune(char) - } - default: - switch { - case - char == '=', - char == '<', - char == '>', - char == '(', - char == ',', - char == '+', - char == '-', - char == '*', - char == '/', - char == '[': - keyword = true - default: - if limit.matchRune(char) || offset.matchRune(char) || like.matchRune(char) || - in.matchRune(char) || from.matchRune(char) || join.matchRune(char) || subSelect.matchRune(char) { - keyword = true - } else if between.matchRune(char) { - keyword = true - inBetween = true - } else if inBetween && and.matchRune(char) { - keyword = true - inBetween = false - } else { - keyword = keyword && unicode.IsSpace(char) - } - } - buf.WriteRune(char) - } - } else { - break - } - } - default: - buf.WriteString(stmt.query) - } - return buf.String(), externalTables -} - -func convertOldArgs(args []driver.Value) []driver.NamedValue { - dargs := make([]driver.NamedValue, len(args)) - for i, v := range args { - dargs[i] = driver.NamedValue{ - Ordinal: i + 1, - Value: v, - } - } - return dargs -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/tls_config.go b/vendor/github.com/ClickHouse/clickhouse-go/tls_config.go deleted file mode 100644 index d85cd341..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/tls_config.go +++ /dev/null @@ -1,44 +0,0 @@ -package clickhouse - -import ( - "crypto/tls" - "sync" -) - -// Based on the original implementation in the project go-sql-driver/mysql: -// https://github.com/go-sql-driver/mysql/blob/master/utils.go - -var ( - tlsConfigLock sync.RWMutex - tlsConfigRegistry map[string]*tls.Config -) - -// RegisterTLSConfig registers a custom tls.Config to be used with sql.Open. -func RegisterTLSConfig(key string, config *tls.Config) error { - tlsConfigLock.Lock() - if tlsConfigRegistry == nil { - tlsConfigRegistry = make(map[string]*tls.Config) - } - - tlsConfigRegistry[key] = config - tlsConfigLock.Unlock() - return nil -} - -// DeregisterTLSConfig removes the tls.Config associated with key. -func DeregisterTLSConfig(key string) { - tlsConfigLock.Lock() - if tlsConfigRegistry != nil { - delete(tlsConfigRegistry, key) - } - tlsConfigLock.Unlock() -} - -func getTLSConfigClone(key string) (config *tls.Config) { - tlsConfigLock.RLock() - if v, ok := tlsConfigRegistry[key]; ok { - config = v.Clone() - } - tlsConfigLock.RUnlock() - return -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/.gitignore b/vendor/github.com/ClickHouse/clickhouse-go/v2/.gitignore similarity index 93% rename from vendor/github.com/ClickHouse/clickhouse-go/.gitignore rename to vendor/github.com/ClickHouse/clickhouse-go/v2/.gitignore index 940583ff..7f0f42e8 100644 --- a/vendor/github.com/ClickHouse/clickhouse-go/.gitignore +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/.gitignore @@ -2,6 +2,7 @@ *.o *.a *.so +*.cap # Folders _obj @@ -25,4 +26,5 @@ _testmain.go *.prof coverage.txt -.idea/** \ No newline at end of file +.idea/** +dev/* \ No newline at end of file diff --git a/vendor/github.com/ClickHouse/clickhouse-go/CONTRIBUTING.md b/vendor/github.com/ClickHouse/clickhouse-go/v2/CONTRIBUTING.md similarity index 100% rename from vendor/github.com/ClickHouse/clickhouse-go/CONTRIBUTING.md rename to vendor/github.com/ClickHouse/clickhouse-go/v2/CONTRIBUTING.md diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/LICENSE b/vendor/github.com/ClickHouse/clickhouse-go/v2/LICENSE new file mode 100644 index 00000000..7a4a3ea2 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/Makefile b/vendor/github.com/ClickHouse/clickhouse-go/v2/Makefile new file mode 100644 index 00000000..e925c29a --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/Makefile @@ -0,0 +1,30 @@ +up: + @docker compose up -d +down: + @docker compose down + +cli: + docker run -it --rm --net clickhouse-go_clickhouse --link clickhouse:clickhouse-server yandex/clickhouse-client --host clickhouse-server + +test: + @go install -race -v + @go test -race -timeout 30s -count=1 -v . + @go test -race -timeout 30s -count=1 -v ./tests/... + +lint: + golangci-lint run || : + gocritic check -disable=singleCaseSwitch ./... || : + +contributors: + @git log --pretty="%an <%ae>%n%cn <%ce>" | sort -u -t '<' -k 2,2 | LC_ALL=C sort | \ + grep -v "users.noreply.github.com\|GitHub " \ + > contributors/list + +staticcheck: + staticcheck ./... + +codegen: contributors + @cd lib/column && go run codegen/main.go + @go-licenser -licensor "ClickHouse, Inc." + +.PHONY: contributors \ No newline at end of file diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/README.md b/vendor/github.com/ClickHouse/clickhouse-go/v2/README.md new file mode 100644 index 00000000..ad4c7184 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/README.md @@ -0,0 +1,163 @@ +# ClickHouse [![run-tests](https://github.com/ClickHouse/clickhouse-go/actions/workflows/run-tests.yml/badge.svg?branch=v2)](https://github.com/ClickHouse/clickhouse-go/actions/workflows/run-tests.yml) [![Go Reference](https://pkg.go.dev/badge/github.com/ClickHouse/clickhouse-go/v2.svg)](https://pkg.go.dev/github.com/ClickHouse/clickhouse-go/v2) + +Golang SQL database driver for [ClickHouse](https://clickhouse.com/). + +## Versions + +There are two version of this driver, v1 and v2, available as separate branches. + +**v1 is now in a state of a maintenance - we will only accept PRs for bug and security fixes.** + +Users should use v2 which is production ready and [significantly faster than v1](#benchmark). + +## Key features + +* Uses native ClickHouse TCP client-server protocol +* Compatibility with [`database/sql`](#std-databasesql-interface) ([slower](#benchmark) than [native interface](#native-interface)!) +* Marshal rows into structs ([ScanStruct](tests/scan_struct_test.go), [Select](examples/native/scan_struct/main.go)) +* Unmarshal struct to row ([AppendStruct](benchmark/v2/write-native-struct/main.go)) +* Connection pool +* Failover and load balancing +* [Bulk write support](examples/native/batch/main.go) (for `database/sql` [use](examples/std/batch/main.go) `begin->prepare->(in loop exec)->commit`) +* [AsyncInsert](benchmark/v2/write-async/main.go) +* Named and numeric placeholders support +* LZ4 compression support +* External data + +Support for the ClickHouse protocol advanced features using `Context`: + +* Query ID +* Quota Key +* Settings +* OpenTelemetry +* Execution events: + * Logs + * Progress + * Profile info + * Profile events + +# `database/sql` interface + +## OpenDB + +```go +conn := clickhouse.OpenDB(&clickhouse.Options{ + Addr: []string{"127.0.0.1:9999"}, + Auth: clickhouse.Auth{ + Database: "default", + Username: "default", + Password: "", + }, + TLS: &tls.Config{ + InsecureSkipVerify: true, + }, + Settings: clickhouse.Settings{ + "max_execution_time": 60, + }, + DialTimeout: 5 * time.Second, + Compression: &clickhouse.Compression{ + clickhouse.CompressionLZ4, + }, + Debug: true, +}) +conn.SetMaxIdleConns(5) +conn.SetMaxOpenConns(10) +conn.SetConnMaxLifetime(time.Hour) +``` +## DSN + +* hosts - comma-separated list of single address hosts for load-balancing and failover +* username/password - auth credentials +* database - select the current default database +* dial_timeout - a duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix such as "300ms", "1s". Valid time units are "ms", "s", "m". +* connection_open_strategy - random/in_order (default random). + * round-robin - choose a round-robin server from the set + * in_order - first live server is chosen in specified order +* debug - enable debug output (boolean value) +* compress - enable lz4 compression (boolean value) + +SSL/TLS parameters: + +* secure - establish secure connection (default is false) +* skip_verify - skip certificate verification (default is false) + +Example: + +```sh +clickhouse://username:password@host1:9000,host2:9000/database?dial_timeout=200ms&max_execution_time=60 +``` + +## Benchmark + +| [V1 (READ)](benchmark/v1/read/main.go) | [V2 (READ) std](benchmark/v2/read/main.go) | [V2 (READ) native](benchmark/v2/read-native/main.go) | +| -------------------------------------- | ------------------------------------------ | ---------------------------------------------------- | +| 1.218s | 924.390ms | 675.721ms | + + +| [V1 (WRITE)](benchmark/v1/write/main.go) | [V2 (WRITE) std](benchmark/v2/write/main.go) | [V2 (WRITE) native](benchmark/v2/write-native/main.go) | [V2 (WRITE) by column](benchmark/v2/write-native-columnar/main.go) | +| ---------------------------------------- | -------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------------------------ | +| 1.899s | 1.177s | 699.203ms | 661.973ms | + + + +## Install + +```sh +go get -u github.com/ClickHouse/clickhouse-go/v2 +``` + +## Examples + +### native interface + +* [batch](examples/native/batch/main.go) +* [async insert](examples/native/write-async) +* [batch struct](examples/native/write-struct/main.go) +* [columnar](examples/native/write-columnar/main.go) +* [scan struct](examples/native/scan_struct/main.go) +* [bind params](examples/native/bind/main.go) + +### std `database/sql` interface + +* [batch](examples/std/batch/main.go) +* [async insert](examples/std/write-async) +* [open db](examples/std/open_db/main.go) +* [bind params](examples/std/bind/main.go) + + +#### A Note on TLS/SSL + +At a low level all driver connect methods (DSN/OpenDB/Open) will use the [Go tls package](https://pkg.go.dev/crypto/tls) to establish a secure connection. The driver knows to use TLS if the Options struct contains a non-nil tls.Config pointer. + +Setting secure in the DSN creates a minimal tls.Config struct with only the InsecureSkipVerify field set (either true or false). It is equivalent to this code: + +```go +conn := clickhouse.OpenDB(&clickhouse.Options{ + ... + TLS: &tls.Config{ + InsecureSkipVerify: false + } + ... + }) +``` +This minimal tls.Config is normally all that is necessary to connect to the secure native port (normally 9440) on a ClickHouse server. If the ClickHouse server does not have a valid certificate (expired, wrong host name, not signed by a publicly recognized root Certificate Authority), InsecureSkipVerify can be to `true`, but that is strongly discouraged. + +If additional TLS parameters are necessary the application code should set the desired fields in the tls.Config struct. That can include specific cipher suites, forcing a particular TLS version (like 1.2 or 1.3), adding an internal CA certificate chain, adding a client certificate (and private key) if required by the ClickHouse server, and most of the other options that come with a more specialized security setup. + +## Alternatives + +* Database drivers + * [mailru/go-clickhouse](https://github.com/mailru/go-clickhouse) (uses the HTTP protocol) + * [uptrace/go-clickhouse](https://github.com/uptrace/go-clickhouse) (uses the native TCP protocol with `database/sql`-like API) + * drivers with columnar interface : + * [vahid-sohrabloo/chconn](https://github.com/vahid-sohrabloo/chconn) + * [go-faster/ch](https://github.com/go-faster/ch) + +* Insert collectors: + * [KittenHouse](https://github.com/YuriyNasretdinov/kittenhouse) + * [nikepan/clickhouse-bulk](https://github.com/nikepan/clickhouse-bulk) + +### Useful projects + +* [clickhouse-backup](https://github.com/AlexAkulov/clickhouse-backup) +* [go-graphite](https://github.com/go-graphite) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/bind.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/bind.go new file mode 100644 index 00000000..4223e89f --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/bind.go @@ -0,0 +1,183 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + std_driver "database/sql/driver" + "fmt" + "reflect" + "regexp" + "strings" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/driver" +) + +func Named(name string, value interface{}) driver.NamedValue { + return driver.NamedValue{ + Name: name, + Value: value, + } +} + +func bind(tz *time.Location, query string, args ...interface{}) (string, error) { + if len(args) == 0 { + return query, nil + } + var ( + haveNamed bool + haveNumeric bool + ) + for _, v := range args { + switch v.(type) { + case driver.NamedValue: + haveNamed = true + default: + haveNumeric = true + } + if haveNamed && haveNumeric { + return "", ErrBindMixedNamedAndNumericParams + } + } + if haveNamed { + return bindNamed(tz, query, args...) + } + return bindNumeric(tz, query, args...) +} + +var bindNumericRe = regexp.MustCompile(`\$[0-9]+`) + +func bindNumeric(tz *time.Location, query string, args ...interface{}) (_ string, err error) { + var ( + unbind = make(map[string]struct{}) + params = make(map[string]string) + ) + for i, v := range args { + if fn, ok := v.(std_driver.Valuer); ok { + if v, err = fn.Value(); err != nil { + return "", nil + } + } + params[fmt.Sprintf("$%d", i+1)] = format(tz, v) + } + query = bindNumericRe.ReplaceAllStringFunc(query, func(n string) string { + if _, found := params[n]; !found { + unbind[n] = struct{}{} + return "" + } + return params[n] + }) + for param := range unbind { + return "", fmt.Errorf("have no arg for %s param", param) + } + return query, nil +} + +var bindNamedRe = regexp.MustCompile(`@[a-zA-Z0-9\_]+`) + +func bindNamed(tz *time.Location, query string, args ...interface{}) (_ string, err error) { + var ( + unbind = make(map[string]struct{}) + params = make(map[string]string) + ) + for _, v := range args { + switch v := v.(type) { + case driver.NamedValue: + value := v.Value + if fn, ok := v.Value.(std_driver.Valuer); ok { + if value, err = fn.Value(); err != nil { + return "", err + } + } + params["@"+v.Name] = format(tz, value) + } + } + query = bindNamedRe.ReplaceAllStringFunc(query, func(n string) string { + if _, found := params[n]; !found { + unbind[n] = struct{}{} + return "" + } + return params[n] + }) + for param := range unbind { + return "", fmt.Errorf("have no arg for %q param", param) + } + return query, nil +} + +func format(tz *time.Location, v interface{}) string { + quote := func(v string) string { + return "'" + strings.NewReplacer(`\`, `\\`, `'`, `\'`).Replace(v) + "'" + } + switch v := v.(type) { + case nil: + return "NULL" + case string: + return quote(v) + case time.Time: + switch v.Location().String() { + case "Local": + return fmt.Sprintf("toDateTime(%d)", v.Unix()) + case tz.String(): + return v.Format("toDateTime('2006-01-02 15:04:05')") + } + return v.Format("toDateTime('2006-01-02 15:04:05', '" + v.Location().String() + "')") + case []interface{}: // tuple + elements := make([]string, 0, len(v)) + for _, e := range v { + elements = append(elements, format(tz, e)) + } + return "(" + strings.Join(elements, ", ") + ")" + case [][]interface{}: + items := make([]string, 0, len(v)) + for _, t := range v { + items = append(items, format(tz, t)) + } + return strings.Join(items, ", ") + case fmt.Stringer: + return quote(v.String()) + } + switch v := reflect.ValueOf(v); v.Kind() { + case reflect.String: + return quote(v.String()) + case reflect.Slice: + values := make([]string, 0, v.Len()) + for i := 0; i < v.Len(); i++ { + values = append(values, format(tz, v.Index(i).Interface())) + } + return strings.Join(values, ", ") + } + return fmt.Sprint(v) +} + +func rebind(in []std_driver.NamedValue) []interface{} { + args := make([]interface{}, 0, len(in)) + for _, v := range in { + switch { + case len(v.Name) != 0: + args = append(args, driver.NamedValue{ + Name: v.Name, + Value: v.Value, + }) + + default: + args = append(args, v.Value) + } + } + return args +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse.go new file mode 100644 index 00000000..0b37a311 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse.go @@ -0,0 +1,267 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" + "errors" + "fmt" + "sync/atomic" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/contributors" + "github.com/ClickHouse/clickhouse-go/v2/lib/column" + "github.com/ClickHouse/clickhouse-go/v2/lib/driver" + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +type Conn = driver.Conn + +type ( + Progress = proto.Progress + Exception = proto.Exception + ProfileInfo = proto.ProfileInfo + ServerVersion = proto.ServerHandshake +) + +var ( + ErrBatchAlreadySent = errors.New("clickhouse: batch has already been sent") + ErrAcquireConnTimeout = errors.New("clickhouse: acquire conn timeout. you can increase the number of max open conn or the dial timeout") + ErrUnsupportedServerRevision = errors.New("clickhouse: unsupported server revision") + ErrBindMixedNamedAndNumericParams = errors.New("clickhouse [bind]: mixed named and numeric parameters") +) + +type OpError struct { + Op string + ColumnName string + Err error +} + +func (e *OpError) Error() string { + switch err := e.Err.(type) { + case *column.Error: + return fmt.Sprintf("clickhouse [%s]: (%s %s) %s", e.Op, e.ColumnName, err.ColumnType, err.Err) + case *column.ColumnConverterError: + var hint string + if len(err.Hint) != 0 { + hint += ". " + err.Hint + } + return fmt.Sprintf("clickhouse [%s]: (%s) converting %s to %s is unsupported%s", + err.Op, e.ColumnName, + err.From, err.To, + hint, + ) + } + return fmt.Sprintf("clickhouse [%s]: %s", e.Op, e.Err) +} + +func Open(opt *Options) (driver.Conn, error) { + opt.setDefaults() + return &clickhouse{ + opt: opt, + idle: make(chan *connect, opt.MaxIdleConns), + open: make(chan struct{}, opt.MaxOpenConns), + }, nil +} + +type clickhouse struct { + opt *Options + idle chan *connect + open chan struct{} + connID int64 +} + +func (clickhouse) Contributors() []string { + list := contributors.List + if len(list[len(list)-1]) == 0 { + return list[:len(list)-1] + } + return list +} + +func (ch *clickhouse) ServerVersion() (*driver.ServerVersion, error) { + var ( + ctx, cancel = context.WithTimeout(context.Background(), ch.opt.DialTimeout) + conn, err = ch.acquire(ctx) + ) + defer cancel() + if err != nil { + return nil, err + } + ch.release(conn, nil) + return &conn.server, nil +} + +func (ch *clickhouse) Query(ctx context.Context, query string, args ...interface{}) (rows driver.Rows, err error) { + conn, err := ch.acquire(ctx) + if err != nil { + return nil, err + } + return conn.query(ctx, ch.release, query, args...) +} + +func (ch *clickhouse) QueryRow(ctx context.Context, query string, args ...interface{}) (rows driver.Row) { + conn, err := ch.acquire(ctx) + if err != nil { + return &row{ + err: err, + } + } + return conn.queryRow(ctx, ch.release, query, args...) +} + +func (ch *clickhouse) Exec(ctx context.Context, query string, args ...interface{}) error { + conn, err := ch.acquire(ctx) + if err != nil { + return err + } + if err := conn.exec(ctx, query, args...); err != nil { + ch.release(conn, err) + return err + } + ch.release(conn, nil) + return nil +} + +func (ch *clickhouse) PrepareBatch(ctx context.Context, query string) (driver.Batch, error) { + conn, err := ch.acquire(ctx) + if err != nil { + return nil, err + } + return conn.prepareBatch(ctx, query, ch.release) +} + +func (ch *clickhouse) AsyncInsert(ctx context.Context, query string, wait bool) error { + conn, err := ch.acquire(ctx) + if err != nil { + return err + } + if err := conn.asyncInsert(ctx, query, wait); err != nil { + ch.release(conn, err) + return err + } + ch.release(conn, nil) + return nil +} + +func (ch *clickhouse) Ping(ctx context.Context) (err error) { + conn, err := ch.acquire(ctx) + if err != nil { + return err + } + if err := conn.ping(ctx); err != nil { + ch.release(conn, err) + return err + } + ch.release(conn, nil) + return nil +} + +func (ch *clickhouse) Stats() driver.Stats { + return driver.Stats{ + Open: len(ch.open), + Idle: len(ch.idle), + MaxOpenConns: cap(ch.open), + MaxIdleConns: cap(ch.idle), + } +} + +func (ch *clickhouse) dial(ctx context.Context) (conn *connect, err error) { + connID := int(atomic.AddInt64(&ch.connID, 1)) + for num := range ch.opt.Addr { + if ch.opt.ConnOpenStrategy == ConnOpenRoundRobin { + num = int(connID) % len(ch.opt.Addr) + } + if conn, err = dial(ctx, ch.opt.Addr[num], connID, ch.opt); err == nil { + return conn, nil + } + } + return nil, err +} + +func (ch *clickhouse) acquire(ctx context.Context) (conn *connect, err error) { + timer := time.NewTimer(ch.opt.DialTimeout) + defer timer.Stop() + select { + case <-ctx.Done(): + return nil, ctx.Err() + default: + } + select { + case <-timer.C: + return nil, ErrAcquireConnTimeout + case ch.open <- struct{}{}: + } + select { + case <-timer.C: + return nil, ErrAcquireConnTimeout + case conn := <-ch.idle: + if conn.isBad() { + conn.close() + if conn, err = ch.dial(ctx); err != nil { + select { + case <-ch.open: + default: + } + return nil, err + } + } + conn.released = false + return conn, nil + default: + } + if conn, err = ch.dial(ctx); err != nil { + select { + case <-ch.open: + default: + } + return nil, err + } + return conn, nil +} + +func (ch *clickhouse) release(conn *connect, err error) { + if conn.released { + return + } + conn.released = true + select { + case <-ch.open: + default: + } + if err != nil || time.Since(conn.connectedAt) >= ch.opt.ConnMaxLifetime { + conn.close() + return + } + select { + case ch.idle <- conn: + default: + conn.close() + } +} + +func (ch *clickhouse) Close() error { + for { + select { + case c := <-ch.idle: + c.close() + default: + return nil + } + } +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_options.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_options.go new file mode 100644 index 00000000..5f2a8ef5 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_options.go @@ -0,0 +1,162 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" + "crypto/tls" + "fmt" + "net" + "net/url" + "strconv" + "strings" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/compress" +) + +var CompressionLZ4 compress.Method = compress.LZ4 + +type Auth struct { // has_control_character + Database string + Username string + Password string +} + +type Compression struct { + Method compress.Method +} + +type ConnOpenStrategy uint8 + +const ( + ConnOpenInOrder ConnOpenStrategy = iota + ConnOpenRoundRobin +) + +func ParseDSN(dsn string) (*Options, error) { + opt := &Options{} + if err := opt.fromDSN(dsn); err != nil { + return nil, err + } + return opt, nil +} + +type Options struct { + TLS *tls.Config + Addr []string + Auth Auth + DialContext func(ctx context.Context, addr string) (net.Conn, error) + Debug bool + Settings Settings + Compression *Compression + DialTimeout time.Duration // default 1 second + MaxOpenConns int // default MaxIdleConns + 5 + MaxIdleConns int // default 5 + ConnMaxLifetime time.Duration // default 1 hour + ConnOpenStrategy ConnOpenStrategy +} + +func (o *Options) fromDSN(in string) error { + dsn, err := url.Parse(in) + if err != nil { + return err + } + if o.Settings == nil { + o.Settings = make(Settings) + } + if dsn.User != nil { + o.Auth.Username = dsn.User.Username() + o.Auth.Password, _ = dsn.User.Password() + } + o.Addr = append(o.Addr, strings.Split(dsn.Host, ",")...) + var ( + secure bool + params = dsn.Query() + skipVerify bool + ) + o.Auth.Database = strings.TrimPrefix(dsn.Path, "/") + for v := range params { + switch v { + case "debug": + o.Debug, _ = strconv.ParseBool(params.Get(v)) + case "compress": + if on, _ := strconv.ParseBool(params.Get(v)); on { + o.Compression = &Compression{ + Method: CompressionLZ4, + } + } + case "dial_timeout": + duration, err := time.ParseDuration(params.Get(v)) + if err != nil { + return fmt.Errorf("clickhouse [dsn parse]: dial timeout: %s", err) + } + o.DialTimeout = duration + case "secure": + secure = true + case "skip_verify": + skipVerify = true + case "connection_open_strategy": + switch params.Get(v) { + case "in_order": + o.ConnOpenStrategy = ConnOpenInOrder + case "round_robin": + o.ConnOpenStrategy = ConnOpenRoundRobin + } + default: + switch p := strings.ToLower(params.Get(v)); p { + case "true": + o.Settings[v] = int(1) + case "false": + o.Settings[v] = int(0) + default: + if n, err := strconv.Atoi(p); err == nil { + o.Settings[v] = n + } + } + } + } + if secure { + o.TLS = &tls.Config{ + InsecureSkipVerify: skipVerify, + } + } + o.setDefaults() + return nil +} + +func (o *Options) setDefaults() { + if len(o.Auth.Database) == 0 { + o.Auth.Database = "default" + } + if len(o.Auth.Username) == 0 { + o.Auth.Username = "default" + } + if o.DialTimeout == 0 { + o.DialTimeout = time.Second + } + if o.MaxIdleConns <= 0 { + o.MaxIdleConns = 5 + } + if o.MaxOpenConns <= 0 { + o.MaxOpenConns = o.MaxIdleConns + 5 + } + if o.ConnMaxLifetime == 0 { + o.ConnMaxLifetime = time.Hour + } +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_rows.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_rows.go new file mode 100644 index 00000000..c9ff8921 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_rows.go @@ -0,0 +1,162 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "database/sql" + "io" + + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +type rows struct { + err error + row int + block *proto.Block + totals *proto.Block + errors chan error + stream chan *proto.Block + columns []string + structMap structMap +} + +func (r *rows) Next() (result bool) { + defer func() { + if !result { + r.Close() + } + }() + if r.block == nil { + return false + } +next: + if r.row >= r.block.Rows() { + select { + case err := <-r.errors: + if err != nil { + r.err = err + return false + } + goto next + case block := <-r.stream: + if block == nil { + return false + } + if block.Packet == proto.ServerTotals { + r.row, r.block, r.totals = 0, nil, block + return false + } + r.row, r.block = 0, block + } + } + r.row++ + return r.row <= r.block.Rows() +} + +func (r *rows) Scan(dest ...interface{}) error { + if r.block == nil || (r.row == 0 && r.row >= r.block.Rows()) { // call without next when result is empty + return io.EOF + } + return scan(r.block, r.row, dest...) +} + +func (r *rows) ScanStruct(dest interface{}) error { + values, err := r.structMap.Map("ScanStruct", r.columns, dest, true) + if err != nil { + return err + } + return r.Scan(values...) +} + +func (r *rows) Totals(dest ...interface{}) error { + if r.totals == nil { + return sql.ErrNoRows + } + return scan(r.totals, 1, dest...) +} + +func (r *rows) Columns() []string { + return r.columns +} + +func (r *rows) Close() error { + active := 2 + for { + select { + case _, ok := <-r.stream: + if !ok { + active-- + if active == 0 { + return r.err + } + } + case err, ok := <-r.errors: + if err != nil { + r.err = err + } + if !ok { + active-- + if active == 0 { + return r.err + } + } + } + } + return r.err +} + +func (r *rows) Err() error { + return r.err +} + +type row struct { + err error + rows *rows +} + +func (r *row) Err() error { + return r.err +} + +func (r *row) ScanStruct(dest interface{}) error { + if r.err != nil { + return r.err + } + values, err := r.rows.structMap.Map("ScanStruct", r.rows.columns, dest, true) + if err != nil { + return err + } + return r.Scan(values...) +} + +func (r *row) Scan(dest ...interface{}) error { + if r.err != nil { + return r.err + } + if !r.rows.Next() { + r.rows.Close() + if err := r.rows.Err(); err != nil { + return err + } + return sql.ErrNoRows + } + if err := r.rows.Scan(dest...); err != nil { + return err + } + return r.rows.Close() +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_rows_column_type.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_rows_column_type.go new file mode 100644 index 00000000..d0719e72 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_rows_column_type.go @@ -0,0 +1,62 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/column" + "github.com/ClickHouse/clickhouse-go/v2/lib/driver" +) + +type columnType struct { + name string + chType string + nullable bool + scanType reflect.Type +} + +func (c *columnType) Name() string { + return c.name +} + +func (c *columnType) Nullable() bool { + return c.nullable +} + +func (c *columnType) ScanType() reflect.Type { + return c.scanType +} + +func (c *columnType) DatabaseTypeName() string { + return c.chType +} + +func (r *rows) ColumnTypes() []driver.ColumnType { + types := make([]driver.ColumnType, 0, len(r.columns)) + for i, c := range r.block.Columns { + _, nullable := c.(*column.Nullable) + types = append(types, &columnType{ + name: r.columns[i], + chType: string(c.Type()), + nullable: nullable, + scanType: c.ScanType(), + }) + } + return types +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_std.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_std.go new file mode 100644 index 00000000..56f3dc10 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/clickhouse_std.go @@ -0,0 +1,284 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" + "database/sql" + "database/sql/driver" + "errors" + "fmt" + "io" + "reflect" + "strings" + "sync/atomic" + + "github.com/ClickHouse/clickhouse-go/v2/lib/column" +) + +var globalConnID int64 + +type stdConnOpener struct { + err error + opt *Options +} + +func (o *stdConnOpener) Driver() driver.Driver { + return &stdDriver{} +} + +func (o *stdConnOpener) Connect(ctx context.Context) (_ driver.Conn, err error) { + if o.err != nil { + return nil, o.err + } + var ( + conn *connect + connID = int(atomic.AddInt64(&globalConnID, 1)) + ) + for num := range o.opt.Addr { + if o.opt.ConnOpenStrategy == ConnOpenRoundRobin { + num = int(connID) % len(o.opt.Addr) + } + if conn, err = dial(ctx, o.opt.Addr[num], connID, o.opt); err == nil { + return &stdDriver{ + conn: conn, + }, nil + } + } + return nil, err +} + +func init() { + sql.Register("clickhouse", &stdDriver{}) +} + +func OpenDB(opt *Options) *sql.DB { + var settings []string + if opt.MaxIdleConns > 0 { + settings = append(settings, "SetMaxIdleConns") + } + if opt.MaxOpenConns > 0 { + settings = append(settings, "SetMaxOpenConns") + } + if opt.ConnMaxLifetime > 0 { + settings = append(settings, "SetConnMaxLifetime") + } + if len(settings) != 0 { + return sql.OpenDB(&stdConnOpener{ + err: fmt.Errorf("cannot connect. invalid settings. use %s (see https://pkg.go.dev/database/sql)", strings.Join(settings, ",")), + }) + } + opt.setDefaults() + return sql.OpenDB(&stdConnOpener{ + opt: opt, + }) +} + +type stdDriver struct { + conn *connect + commit func() error +} + +func (d *stdDriver) Open(dsn string) (_ driver.Conn, err error) { + var opt Options + if err := opt.fromDSN(dsn); err != nil { + return nil, err + } + return (&stdConnOpener{opt: &opt}).Connect(context.Background()) +} + +func (std *stdDriver) ResetSession(ctx context.Context) error { + if std.conn.isBad() { + return driver.ErrBadConn + } + return nil +} + +func (std *stdDriver) Ping(ctx context.Context) error { return std.conn.ping(ctx) } + +func (std *stdDriver) Begin() (driver.Tx, error) { return std, nil } + +func (std *stdDriver) Commit() error { + if std.commit == nil { + return nil + } + defer func() { + std.commit = nil + }() + return std.commit() +} + +func (std *stdDriver) Rollback() error { + std.commit = nil + std.conn.close() + return nil +} + +func (std *stdDriver) CheckNamedValue(nv *driver.NamedValue) error { return nil } + +func (std *stdDriver) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) { + if options := queryOptions(ctx); options.async.ok { + if len(args) != 0 { + return nil, errors.New("clickhouse: you can't use parameters in an asynchronous insert") + } + return driver.RowsAffected(0), std.conn.asyncInsert(ctx, query, options.async.wait) + } + if err := std.conn.exec(ctx, query, rebind(args)...); err != nil { + return nil, err + } + return driver.RowsAffected(0), nil +} + +func (std *stdDriver) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) { + r, err := std.conn.query(ctx, func(*connect, error) {}, query, rebind(args)...) + if err != nil { + return nil, err + } + return &stdRows{ + rows: r, + }, nil +} + +func (std *stdDriver) Prepare(query string) (driver.Stmt, error) { + return std.PrepareContext(context.Background(), query) +} + +func (std *stdDriver) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) { + batch, err := std.conn.prepareBatch(ctx, query, func(*connect, error) {}) + if err != nil { + return nil, err + } + std.commit = batch.Send + return &stdBatch{ + batch: batch, + }, nil +} + +func (std *stdDriver) Close() error { return std.conn.close() } + +type stdBatch struct { + batch *batch +} + +func (s *stdBatch) NumInput() int { return -1 } +func (s *stdBatch) Exec(args []driver.Value) (driver.Result, error) { + values := make([]interface{}, 0, len(args)) + for _, v := range args { + values = append(values, v) + } + if err := s.batch.Append(values...); err != nil { + return nil, err + } + return driver.RowsAffected(0), nil +} + +func (s *stdBatch) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) { + values := make([]driver.Value, 0, len(args)) + for _, v := range args { + values = append(values, v.Value) + } + return s.Exec(values) +} + +func (s *stdBatch) Query(args []driver.Value) (driver.Rows, error) { + return nil, errors.New("only Exec method supported in batch mode") +} + +func (s *stdBatch) Close() error { return nil } + +type stdRows struct { + rows *rows +} + +func (r *stdRows) Columns() []string { + return r.rows.Columns() +} + +func (r *stdRows) ColumnTypeScanType(idx int) reflect.Type { + return r.rows.block.Columns[idx].ScanType() +} + +func (r *stdRows) ColumnTypeDatabaseTypeName(idx int) string { + return string(r.rows.block.Columns[idx].Type()) +} + +func (r *stdRows) ColumnTypeNullable(idx int) (nullable, ok bool) { + _, ok = r.rows.block.Columns[idx].(*column.Nullable) + return ok, true +} + +func (r *stdRows) ColumnTypePrecisionScale(idx int) (precision, scale int64, ok bool) { + switch col := r.rows.block.Columns[idx].(type) { + case *column.Decimal: + return col.Precision(), col.Scale(), true + case interface{ Base() column.Interface }: + switch col := col.Base().(type) { + case *column.Decimal: + return col.Precision(), col.Scale(), true + } + } + return 0, 0, false +} + +func (r *stdRows) Next(dest []driver.Value) error { + if len(r.rows.block.Columns) != len(dest) { + return &OpError{ + Op: "Next", + Err: fmt.Errorf("expected %d destination arguments in Next, not %d", len(r.rows.block.Columns), len(dest)), + } + } + if r.rows.Next() { + for i := range dest { + nullable, ok := r.ColumnTypeNullable(i) + switch value := r.rows.block.Columns[i].Row(r.rows.row-1, nullable && ok).(type) { + case driver.Valuer: + v, err := value.Value() + if err != nil { + return err + } + dest[i] = v + default: + dest[i] = value + } + } + return nil + } + if err := r.rows.Err(); err != nil { + return err + } + return io.EOF +} + +func (r *stdRows) HasNextResultSet() bool { + return r.rows.totals != nil +} + +func (r *stdRows) NextResultSet() error { + switch { + case r.rows.totals != nil: + r.rows.block = r.rows.totals + r.rows.totals = nil + default: + return io.EOF + } + return nil +} + +func (r *stdRows) Close() error { + return r.rows.Close() +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn.go new file mode 100644 index 00000000..71a8d756 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn.go @@ -0,0 +1,196 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" + "crypto/tls" + "fmt" + "log" + "net" + "os" + "reflect" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "github.com/ClickHouse/clickhouse-go/v2/lib/io" + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +func dial(ctx context.Context, addr string, num int, opt *Options) (*connect, error) { + var ( + err error + conn net.Conn + debugf = func(format string, v ...interface{}) {} + ) + switch { + case opt.DialContext != nil: + conn, err = opt.DialContext(ctx, addr) + default: + switch { + case opt.TLS != nil: + conn, err = tls.DialWithDialer(&net.Dialer{Timeout: opt.DialTimeout}, "tcp", addr, opt.TLS) + default: + conn, err = net.DialTimeout("tcp", addr, opt.DialTimeout) + } + } + if err != nil { + return nil, err + } + if opt.Debug { + debugf = log.New(os.Stdout, fmt.Sprintf("[clickhouse][conn=%d][%s]", num, conn.RemoteAddr()), 0).Printf + } + var compression bool + if opt.Compression != nil { + compression = opt.Compression.Method == CompressionLZ4 + } + var ( + stream = io.NewStream(conn) + connect = &connect{ + opt: opt, + conn: conn, + debugf: debugf, + stream: stream, + encoder: binary.NewEncoder(stream), + decoder: binary.NewDecoder(stream), + revision: proto.ClientTCPProtocolVersion, + structMap: structMap{ + cache: make(map[reflect.Type]map[string][]int), + }, + compression: compression, + connectedAt: time.Now(), + } + ) + if err := connect.handshake(opt.Auth.Database, opt.Auth.Username, opt.Auth.Password); err != nil { + return nil, err + } + return connect, nil +} + +// https://github.com/ClickHouse/ClickHouse/blob/master/src/Client/Connection.cpp +type connect struct { + opt *Options + conn net.Conn + debugf func(format string, v ...interface{}) + server ServerVersion + stream *io.Stream + closed bool + encoder *binary.Encoder + decoder *binary.Decoder + released bool + revision uint64 + structMap structMap + compression bool + //lastUsedIn time.Time + connectedAt time.Time +} + +func (c *connect) settings(querySettings Settings) []proto.Setting { + settings := make([]proto.Setting, 0, len(c.opt.Settings)+len(querySettings)) + for k, v := range c.opt.Settings { + settings = append(settings, proto.Setting{ + Key: k, + Value: v, + }) + } + for k, v := range querySettings { + settings = append(settings, proto.Setting{ + Key: k, + Value: v, + }) + } + return settings +} + +func (c *connect) isBad() bool { + switch { + case c.closed: + return true + } + if err := c.connCheck(); err != nil { + return true + } + return false +} + +func (c *connect) close() error { + if c.closed { + return nil + } + c.closed = true + c.encoder = nil + c.decoder = nil + c.stream.Close() + if err := c.conn.Close(); err != nil { + return err + } + return nil +} + +func (c *connect) progress() (*Progress, error) { + var progress proto.Progress + if err := progress.Decode(c.decoder, c.revision); err != nil { + return nil, err + } + c.debugf("[progress] %s", &progress) + return &progress, nil +} + +func (c *connect) exception() error { + var e Exception + if err := e.Decode(c.decoder); err != nil { + return err + } + c.debugf("[exception] %s", e.Error()) + return &e +} + +func (c *connect) sendData(block *proto.Block, name string) error { + c.debugf("[send data] compression=%t", c.compression) + if err := c.encoder.Byte(proto.ClientData); err != nil { + return err + } + if err := c.encoder.String(name); err != nil { + return err + } + if c.compression { + c.stream.Compress(true) + defer func() { + c.stream.Compress(false) + c.encoder.Flush() + }() + } + return block.Encode(c.encoder, c.revision) +} + +func (c *connect) readData(packet byte, compressible bool) (*proto.Block, error) { + if _, err := c.decoder.String(); err != nil { + return nil, err + } + if compressible && c.compression { + c.stream.Compress(true) + defer c.stream.Compress(false) + } + var block proto.Block + if err := block.Decode(c.decoder, c.revision); err != nil { + return nil, err + } + block.Packet = packet + c.debugf("[read data] compression=%t. block: columns=%d, rows=%d", c.compression, len(block.Columns), block.Rows()) + return &block, nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_async_insert.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_async_insert.go new file mode 100644 index 00000000..a324bd1d --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_async_insert.go @@ -0,0 +1,37 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" +) + +func (c *connect) asyncInsert(ctx context.Context, query string, wait bool) error { + options := queryOptions(ctx) + { + options.settings["async_insert"] = 1 + options.settings["wait_for_async_insert"] = 0 + if wait { + options.settings["wait_for_async_insert"] = 1 + } + } + if err := c.sendQuery(query, &options); err != nil { + return err + } + return c.process(ctx, options.onProcess()) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_batch.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_batch.go new file mode 100644 index 00000000..c2af6204 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_batch.go @@ -0,0 +1,181 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" + "fmt" + "os" + "regexp" + "strings" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/column" + "github.com/ClickHouse/clickhouse-go/v2/lib/driver" + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +var splitInsertRe = regexp.MustCompile(`(?i)\sVALUES\s*\(`) + +func (c *connect) prepareBatch(ctx context.Context, query string, release func(*connect, error)) (*batch, error) { + query = splitInsertRe.Split(query, -1)[0] + if !strings.HasSuffix(strings.TrimSpace(strings.ToUpper(query)), "VALUES") { + query += " VALUES" + } + options := queryOptions(ctx) + if deadline, ok := ctx.Deadline(); ok { + c.conn.SetDeadline(deadline) + defer c.conn.SetDeadline(time.Time{}) + } + if err := c.sendQuery(query, &options); err != nil { + release(c, err) + return nil, err + } + var ( + onProcess = options.onProcess() + block, err = c.firstBlock(ctx, onProcess) + ) + if err != nil { + release(c, err) + return nil, err + } + return &batch{ + ctx: ctx, + conn: c, + block: block, + release: func(err error) { + release(c, err) + }, + onProcess: onProcess, + }, nil +} + +type batch struct { + err error + ctx context.Context + conn *connect + sent bool + block *proto.Block + release func(error) + onProcess *onProcess +} + +func (b *batch) Abort() error { + defer func() { + b.sent = true + b.release(os.ErrProcessDone) + }() + if b.sent { + return ErrBatchAlreadySent + } + return nil +} + +func (b *batch) Append(v ...interface{}) error { + if b.sent { + return ErrBatchAlreadySent + } + if err := b.block.Append(v...); err != nil { + b.release(err) + return err + } + return nil +} + +func (b *batch) AppendStruct(v interface{}) error { + values, err := b.conn.structMap.Map("AppendStruct", b.block.ColumnsNames(), v, false) + if err != nil { + return err + } + return b.Append(values...) +} + +func (b *batch) Column(idx int) driver.BatchColumn { + if len(b.block.Columns) <= idx { + b.release(nil) + return &batchColumn{ + err: &OpError{ + Op: "batch.Column", + Err: fmt.Errorf("invalid column index %d", idx), + }, + } + } + return &batchColumn{ + batch: b, + column: b.block.Columns[idx], + release: func(err error) { + b.err = err + b.release(err) + }, + } +} + +func (b *batch) Send() (err error) { + defer func() { + b.sent = true + b.release(err) + }() + if b.sent { + return ErrBatchAlreadySent + } + if b.err != nil { + return b.err + } + if b.block.Rows() != 0 { + if err = b.conn.sendData(b.block, ""); err != nil { + return err + } + } + if err = b.conn.sendData(&proto.Block{}, ""); err != nil { + return err + } + if err = b.conn.encoder.Flush(); err != nil { + return err + } + if err = b.conn.process(b.ctx, b.onProcess); err != nil { + return err + } + return nil +} + +type batchColumn struct { + err error + batch *batch + column column.Interface + release func(error) +} + +func (b *batchColumn) Append(v interface{}) (err error) { + if b.batch.sent { + return ErrBatchAlreadySent + } + if b.err != nil { + b.release(b.err) + return b.err + } + if _, err = b.column.Append(v); err != nil { + b.release(err) + return err + } + return nil +} + +var ( + _ (driver.Batch) = (*batch)(nil) + _ (driver.BatchColumn) = (*batchColumn)(nil) +) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_check.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_check.go new file mode 100644 index 00000000..f30194f8 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_check.go @@ -0,0 +1,60 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos +// +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos + +package clickhouse + +import ( + "errors" + "io" + "syscall" +) + +func (c *connect) connCheck() error { + var sysErr error + sysConn, ok := c.conn.(syscall.Conn) + if !ok { + return nil + } + rawConn, err := sysConn.SyscallConn() + if err != nil { + return err + } + + err = rawConn.Read(func(fd uintptr) bool { + var buf [1]byte + n, err := syscall.Read(int(fd), buf[:]) + switch { + case n == 0 && err == nil: + sysErr = io.EOF + case n > 0: + sysErr = errors.New("unexpected read from socket") + case err == syscall.EAGAIN || err == syscall.EWOULDBLOCK: + sysErr = nil + default: + sysErr = err + } + return true + }) + if err != nil { + return err + } + + return sysErr +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_check_ping.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_check_ping.go new file mode 100644 index 00000000..fe1fe7bf --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_check_ping.go @@ -0,0 +1,35 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//go:build !linux && !darwin && !dragonfly && !freebsd && !netbsd && !openbsd && !solaris && !illumos +// +build !linux,!darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!illumos + +package clickhouse + +import ( + "context" + "time" +) + +func (c *connect) connCheck() error { + ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Second)) + defer cancel() + if err := c.ping(ctx); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_exec.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_exec.go new file mode 100644 index 00000000..433aba77 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_exec.go @@ -0,0 +1,41 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" + "time" +) + +func (c *connect) exec(ctx context.Context, query string, args ...interface{}) error { + var ( + options = queryOptions(ctx) + body, err = bind(c.server.Timezone, query, args...) + ) + if err != nil { + return err + } + if deadline, ok := ctx.Deadline(); ok { + c.conn.SetDeadline(deadline) + defer c.conn.SetDeadline(time.Time{}) + } + if err := c.sendQuery(body, &options); err != nil { + return err + } + return c.process(ctx, options.onProcess()) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_handshake.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_handshake.go new file mode 100644 index 00000000..09af51c5 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_handshake.go @@ -0,0 +1,79 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "fmt" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +func (c *connect) handshake(database, username, password string) error { + c.debugf("[handshake] -> %s", proto.ClientHandshake{}) + c.conn.SetDeadline(time.Now().Add(c.opt.DialTimeout)) + defer c.conn.SetDeadline(time.Time{}) + { + c.encoder.Byte(proto.ClientHello) + if err := (&proto.ClientHandshake{}).Encode(c.encoder); err != nil { + return err + } + { + if err := c.encoder.String(database); err != nil { + return err + } + if err := c.encoder.String(username); err != nil { + return err + } + if err := c.encoder.String(password); err != nil { + return err + } + } + if err := c.encoder.Flush(); err != nil { + return err + } + } + { + packet, err := c.decoder.ReadByte() + if err != nil { + return err + } + switch packet { + case proto.ServerException: + return c.exception() + case proto.ServerHello: + if err := c.server.Decode(c.decoder); err != nil { + return err + } + case proto.ServerEndOfStream: + c.debugf("[handshake] <- end of stream") + return nil + default: + return fmt.Errorf("[handshake] unexpected packet [%d] from server", packet) + } + } + if c.server.Revision < proto.DBMS_MIN_REVISION_WITH_CLIENT_INFO { + return ErrUnsupportedServerRevision + } + if c.revision > c.server.Revision { + c.revision = c.server.Revision + c.debugf("[handshake] downgrade client proto") + } + c.debugf("[handshake] <- %s", c.server) + return nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_logs.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_logs.go new file mode 100644 index 00000000..4f234ccf --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_logs.go @@ -0,0 +1,88 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +type Log struct { + Time time.Time + TimeMicro uint32 + Hostname string + QueryID string + ThreadID uint64 + Priority int8 + Source string + Text string +} + +func (c *connect) logs() ([]Log, error) { + block, err := c.readData(proto.ServerLog, false) + if err != nil { + return nil, err + } + c.debugf("[logs] rows=%d", block.Rows()) + var ( + logs []Log + names = block.ColumnsNames() + ) + for r := 0; r < block.Rows(); r++ { + var log Log + for i, b := range block.Columns { + switch names[i] { + case "event_time": + if err := b.ScanRow(&log.Time, r); err != nil { + return nil, err + } + case "event_time_microseconds": + if err := b.ScanRow(&log.TimeMicro, r); err != nil { + return nil, err + } + case "host_name": + if err := b.ScanRow(&log.Hostname, r); err != nil { + return nil, err + } + case "query_id": + if err := b.ScanRow(&log.QueryID, r); err != nil { + return nil, err + } + case "thread_id": + if err := b.ScanRow(&log.ThreadID, r); err != nil { + return nil, err + } + case "priority": + if err := b.ScanRow(&log.Priority, r); err != nil { + return nil, err + } + case "source": + if err := b.ScanRow(&log.Source, r); err != nil { + return nil, err + } + case "text": + if err := b.ScanRow(&log.Text, r); err != nil { + return nil, err + } + } + } + logs = append(logs, log) + } + return logs, nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_ping.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_ping.go new file mode 100644 index 00000000..8426f34c --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_ping.go @@ -0,0 +1,61 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" + "fmt" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +// Connection::ping +// https://github.com/ClickHouse/ClickHouse/blob/master/src/Client/Connection.cpp +func (c *connect) ping(ctx context.Context) (err error) { + if deadline, ok := ctx.Deadline(); ok { + c.conn.SetDeadline(deadline) + defer c.conn.SetDeadline(time.Time{}) + } + c.debugf("[ping] -> ping") + if err := c.encoder.Byte(proto.ClientPing); err != nil { + return err + } + if err := c.encoder.Flush(); err != nil { + return err + } + var packet byte + for { + if packet, err = c.decoder.ReadByte(); err != nil { + return err + } + switch packet { + case proto.ServerException: + return c.exception() + case proto.ServerProgress: + if _, err = c.progress(); err != nil { + return err + } + case proto.ServerPong: + c.debugf("[ping] <- pong") + return nil + default: + return fmt.Errorf("unexpected packet %d", packet) + } + } +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_process.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_process.go new file mode 100644 index 00000000..88928c26 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_process.go @@ -0,0 +1,147 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" + "fmt" + "io" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +type onProcess struct { + data func(*proto.Block) + logs func([]Log) + progress func(*Progress) + profileInfo func(*ProfileInfo) + profileEvents func([]ProfileEvent) +} + +func (c *connect) firstBlock(ctx context.Context, on *onProcess) (*proto.Block, error) { + for { + select { + case <-ctx.Done(): + c.cancel() + return nil, ctx.Err() + default: + } + packet, err := c.decoder.ReadByte() + if err != nil { + return nil, err + } + switch packet { + case proto.ServerData: + return c.readData(packet, true) + case proto.ServerEndOfStream: + c.debugf("[end of stream]") + return nil, io.EOF + default: + if err := c.handle(packet, on); err != nil { + return nil, err + } + } + } +} + +func (c *connect) process(ctx context.Context, on *onProcess) error { + for { + select { + case <-ctx.Done(): + c.cancel() + return ctx.Err() + default: + } + packet, err := c.decoder.ReadByte() + if err != nil { + return err + } + switch packet { + case proto.ServerEndOfStream: + c.debugf("[end of stream]") + return nil + } + if err := c.handle(packet, on); err != nil { + return err + } + } +} + +func (c *connect) handle(packet byte, on *onProcess) error { + switch packet { + case proto.ServerData, proto.ServerTotals, proto.ServerExtremes: + block, err := c.readData(packet, true) + if err != nil { + return err + } + if block.Rows() != 0 && on.data != nil { + on.data(block) + } + case proto.ServerException: + return c.exception() + case proto.ServerProfileInfo: + var info proto.ProfileInfo + if err := info.Decode(c.decoder, c.revision); err != nil { + return err + } + c.debugf("[profile info] %s", &info) + on.profileInfo(&info) + case proto.ServerTableColumns: + var info proto.TableColumns + if err := info.Decode(c.decoder, c.revision); err != nil { + return err + } + c.debugf("[table columns]") + case proto.ServerProfileEvents: + events, err := c.profileEvents() + if err != nil { + return err + } + on.profileEvents(events) + case proto.ServerLog: + logs, err := c.logs() + if err != nil { + return err + } + on.logs(logs) + case proto.ServerProgress: + progress, err := c.progress() + if err != nil { + return err + } + c.debugf("[progress] %s", progress) + on.progress(progress) + default: + return &OpError{ + Op: "process", + Err: fmt.Errorf("unexpected packet %d", packet), + } + } + return nil +} + +func (c *connect) cancel() error { + c.conn.SetDeadline(time.Now().Add(2 * time.Second)) + c.debugf("[cancel]") + c.closed = true + if err := c.encoder.Uvarint(proto.ClientCancel); err == nil { + return err + } + return c.encoder.Flush() +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_profile_events.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_profile_events.go new file mode 100644 index 00000000..3fa7db74 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_profile_events.go @@ -0,0 +1,88 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "reflect" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +type ProfileEvent struct { + Hostname string + CurrentTime time.Time + ThreadID uint64 + Type string + Name string + Value int64 +} + +func (c *connect) profileEvents() ([]ProfileEvent, error) { + block, err := c.readData(proto.ServerProfileEvents, false) + if err != nil { + return nil, err + } + c.debugf("[profile events] rows=%d", block.Rows()) + var ( + events []ProfileEvent + names = block.ColumnsNames() + ) + for r := 0; r < block.Rows(); r++ { + var event ProfileEvent + for i, b := range block.Columns { + switch names[i] { + case "host_name": + if err := b.ScanRow(&event.Hostname, r); err != nil { + return nil, err + } + case "current_time": + if err := b.ScanRow(&event.CurrentTime, r); err != nil { + return nil, err + } + case "thread_id": + if err := b.ScanRow(&event.ThreadID, r); err != nil { + return nil, err + } + case "type": + if err := b.ScanRow(&event.Type, r); err != nil { + return nil, err + } + case "name": + if err := b.ScanRow(&event.Name, r); err != nil { + return nil, err + } + case "value": + switch b.ScanType().Kind() { + case reflect.Uint64: + var v uint64 + if err := b.ScanRow(&v, r); err != nil { + return nil, err + } + event.Value = int64(v) + default: + if err := b.ScanRow(&event.Value, r); err != nil { + return nil, err + } + } + } + } + events = append(events, event) + } + return events, nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_query.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_query.go new file mode 100644 index 00000000..821444b2 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_query.go @@ -0,0 +1,93 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +func (c *connect) query(ctx context.Context, release func(*connect, error), query string, args ...interface{}) (*rows, error) { + var ( + options = queryOptions(ctx) + onProcess = options.onProcess() + body, err = bind(c.server.Timezone, query, args...) + ) + + if err != nil { + release(c, err) + return nil, err + } + + if deadline, ok := ctx.Deadline(); ok { + c.conn.SetDeadline(deadline) + defer c.conn.SetDeadline(time.Time{}) + } + + if err = c.sendQuery(body, &options); err != nil { + release(c, err) + return nil, err + } + + init, err := c.firstBlock(ctx, onProcess) + + if err != nil { + release(c, err) + return nil, err + } + + var ( + errors = make(chan error) + stream = make(chan *proto.Block, 2) + ) + + go func() { + onProcess.data = func(b *proto.Block) { + stream <- b + } + err := c.process(ctx, onProcess) + if err != nil { + errors <- err + } + close(stream) + close(errors) + release(c, err) + }() + + return &rows{ + block: init, + stream: stream, + errors: errors, + columns: init.ColumnsNames(), + structMap: c.structMap, + }, nil +} + +func (c *connect) queryRow(ctx context.Context, release func(*connect, error), query string, args ...interface{}) *row { + rows, err := c.query(ctx, release, query, args...) + if err != nil { + return &row{ + err: err, + } + } + return &row{ + rows: rows, + } +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_send_query.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_send_query.go new file mode 100644 index 00000000..867dd8dd --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/conn_send_query.go @@ -0,0 +1,52 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +// Connection::sendQuery +// https://github.com/ClickHouse/ClickHouse/blob/master/src/Client/Connection.cpp +func (c *connect) sendQuery(body string, o *QueryOptions) error { + c.debugf("[send query] compression=%t %s", c.compression, body) + if err := c.encoder.Byte(proto.ClientQuery); err != nil { + return err + } + q := proto.Query{ + ID: o.queryID, + Body: body, + Span: o.span, + QuotaKey: o.quotaKey, + Compression: c.compression, + InitialAddress: c.conn.LocalAddr().String(), + Settings: c.settings(o.settings), + } + if err := q.Encode(c.encoder, c.revision); err != nil { + return err + } + for _, table := range o.external { + if err := c.sendData(table.Block(), table.Name()); err != nil { + return err + } + } + if err := c.sendData(&proto.Block{}, ""); err != nil { + return err + } + return c.encoder.Flush() +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/context.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/context.go new file mode 100644 index 00000000..b20f8be1 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/context.go @@ -0,0 +1,175 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/ext" + "go.opentelemetry.io/otel/trace" +) + +var _contextOptionKey = &QueryOptions{ + settings: Settings{ + "_contextOption": struct{}{}, + }, +} + +type Settings map[string]interface{} +type ( + QueryOption func(*QueryOptions) error + QueryOptions struct { + span trace.SpanContext + async struct { + ok bool + wait bool + } + queryID string + quotaKey string + events struct { + logs func(*Log) + progress func(*Progress) + profileInfo func(*ProfileInfo) + profileEvents func([]ProfileEvent) + } + settings Settings + external []*ext.Table + } +) + +func WithSpan(span trace.SpanContext) QueryOption { + return func(o *QueryOptions) error { + o.span = span + return nil + } +} + +func WithQueryID(queryID string) QueryOption { + return func(o *QueryOptions) error { + o.queryID = queryID + return nil + } +} + +func WithQuotaKey(quotaKey string) QueryOption { + return func(o *QueryOptions) error { + o.quotaKey = quotaKey + return nil + } +} + +func WithSettings(settings Settings) QueryOption { + return func(o *QueryOptions) error { + o.settings = settings + return nil + } +} + +func WithLogs(fn func(*Log)) QueryOption { + return func(o *QueryOptions) error { + o.events.logs = fn + return nil + } +} + +func WithProgress(fn func(*Progress)) QueryOption { + return func(o *QueryOptions) error { + o.events.progress = fn + return nil + } +} + +func WithProfileInfo(fn func(*ProfileInfo)) QueryOption { + return func(o *QueryOptions) error { + o.events.profileInfo = fn + return nil + } +} + +func WithProfileEvents(fn func([]ProfileEvent)) QueryOption { + return func(o *QueryOptions) error { + o.events.profileEvents = fn + return nil + } +} + +func WithExternalTable(t ...*ext.Table) QueryOption { + return func(o *QueryOptions) error { + o.external = append(o.external, t...) + return nil + } +} + +func WithStdAsync(wait bool) QueryOption { + return func(o *QueryOptions) error { + o.async.ok, o.async.wait = true, wait + return nil + } +} + +func Context(parent context.Context, options ...QueryOption) context.Context { + opt := QueryOptions{ + settings: make(Settings), + } + for _, f := range options { + f(&opt) + } + return context.WithValue(parent, _contextOptionKey, opt) +} + +func queryOptions(ctx context.Context) QueryOptions { + if o, ok := ctx.Value(_contextOptionKey).(QueryOptions); ok { + if deadline, ok := ctx.Deadline(); ok { + if sec := time.Until(deadline).Seconds(); sec > 1 { + o.settings["max_execution_time"] = int(sec + 5) + } + } + return o + } + return QueryOptions{ + settings: make(Settings), + } +} + +func (q *QueryOptions) onProcess() *onProcess { + return &onProcess{ + logs: func(logs []Log) { + if q.events.logs != nil { + for _, l := range logs { + q.events.logs(&l) + } + } + }, + progress: func(p *Progress) { + if q.events.progress != nil { + q.events.progress(p) + } + }, + profileInfo: func(p *ProfileInfo) { + if q.events.profileInfo != nil { + q.events.profileInfo(p) + } + }, + profileEvents: func(events []ProfileEvent) { + if q.events.profileEvents != nil { + q.events.profileEvents(events) + } + }, + } +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/contributors/contributors.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/contributors/contributors.go new file mode 100644 index 00000000..7fcbae29 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/contributors/contributors.go @@ -0,0 +1,28 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package contributors + +import ( + _ "embed" + "strings" +) + +//go:embed list +var source string + +var List []string = strings.Split(source, "\n") diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/contributors/list b/vendor/github.com/ClickHouse/clickhouse-go/v2/contributors/list new file mode 100644 index 00000000..34131a85 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/contributors/list @@ -0,0 +1,86 @@ +Abraham Adberstein +Aleksandr Petrukhin +Alex Bocharov +Alex Yang +Alexander Chumakov +Alexander Obukhov +Alexey Milovidov +Alexey Palazhchenko +Alvaro Tuso +Andrey Ustinov +Ashish Gaurav +Benjamin Rupp +Cem Sancak +Chao Wang +Chris Duncan +Dale McDiarmid +Damir Sayfutdinov +Dan Walters +Daniel Bershatsky +Danila Migalin +Danny.Dunn +Darío +Denis Krivak +Derek Perkins +Dmitry Markov +Dmitry Ponomarev +Dmitry Ponomarev +Egor.Gorlin +Eugene Formanenko +Evan Au +Ewan +Florian Lehner +Félix Mattrat +Geoff Genz +Ian McGraw +Ivan Blinkov +Ivan Ivanov +Jake Sylvestre +Jakub Chábek +James Hartig +Jan Was +Jeehoon Kim +John Troy +Jon Aquino +LI Tao +Maksim Sokolnikov +Marek Vavruša +Marek Vavruša +Mark Andrus Roberts +Michael Vigovsky +Nay Linn +Oleg Strokachuk +Richard Artoul +Robert Sköld +Robin Hahling +Ross Rothenstine +Sergei Sobolev +Sergey Melekhin +Taras Matsyk +Thibault Deutsch +Tsimafei Bredau +Vespertinus +Yury Korolev +Yury Yurochko +alex +anton troyanov +chengzhi +dmitry kuzmin +gaetan.rizio +hulb +ilker moral +jiyongwang +kshvakov +neverlee +nevseliev +pavel raskin +sundy-li <543950155@qq.com> +vahid sohrabloo +vasily.popov +vl4deee11 +vl4deee11 +vladislav doster +vvoronin +yuankun +zxc111 +李盼 diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/docker-compose.yml b/vendor/github.com/ClickHouse/clickhouse-go/v2/docker-compose.yml new file mode 100644 index 00000000..de88bb3c --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/docker-compose.yml @@ -0,0 +1,14 @@ +--- +version: '3.9' +services: + clickhouse: + networks: + - clickhouse + container_name: clickhouse + image: clickhouse/clickhouse-server + ports: + - 127.0.0.1:8123:8123 + - 127.0.0.1:9000:9000 + - 127.0.0.1:9009:9009 +networks: + clickhouse: null diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/ext/ext.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/ext/ext.go new file mode 100644 index 00000000..48836a82 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/ext/ext.go @@ -0,0 +1,59 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package ext + +import ( + "github.com/ClickHouse/clickhouse-go/v2/lib/column" + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +func NewTable(name string, columns ...func(t *Table) error) (*Table, error) { + table := &Table{ + name: name, + block: &proto.Block{}, + } + for _, column := range columns { + if err := column(table); err != nil { + return nil, err + } + } + return table, nil +} + +type Table struct { + name string + block *proto.Block +} + +func (tbl *Table) Name() string { + return tbl.name +} + +func (tbl *Table) Block() *proto.Block { + return tbl.block +} + +func (tbl *Table) Append(v ...interface{}) error { + return tbl.block.Append(v...) +} + +func Column(name string, ct column.Type) func(t *Table) error { + return func(tbl *Table) error { + return tbl.block.AddColumn(name, ct) + } +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/go.test.sh b/vendor/github.com/ClickHouse/clickhouse-go/v2/go.test.sh similarity index 100% rename from vendor/github.com/ClickHouse/clickhouse-go/go.test.sh rename to vendor/github.com/ClickHouse/clickhouse-go/v2/go.test.sh diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/decoder.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/decoder.go similarity index 64% rename from vendor/github.com/ClickHouse/clickhouse-go/lib/binary/decoder.go rename to vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/decoder.go index 1bf213be..6f34f2e8 100644 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/binary/decoder.go +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/decoder.go @@ -1,3 +1,20 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package binary import ( @@ -6,35 +23,26 @@ import ( "math" ) -func NewDecoder(input io.Reader) *Decoder { +func NewDecoder(r io.Reader) *Decoder { return &Decoder{ - input: input, - } -} - -func NewDecoderWithCompress(input io.Reader) *Decoder { - return &Decoder{ - input: input, - compressInput: NewCompressReader(input), + input: r, } } type Decoder struct { - compress bool - input io.Reader - compressInput io.Reader - scratch [binary.MaxVarintLen64]byte -} - -func (decoder *Decoder) SelectCompress(compress bool) { - decoder.compress = compress + input io.Reader + scratch [binary.MaxVarintLen64]byte } -func (decoder *Decoder) Get() io.Reader { - if decoder.compress && decoder.compressInput != nil { - return decoder.compressInput +func (decoder *Decoder) Raw(b []byte) error { + n, err := decoder.input.Read(b) + if err != nil { + return nil + } + if n != len(b) { + return io.EOF } - return decoder.input + return nil } func (decoder *Decoder) Bool() (bool, error) { @@ -90,14 +98,14 @@ func (decoder *Decoder) UInt8() (uint8, error) { } func (decoder *Decoder) UInt16() (uint16, error) { - if _, err := decoder.Get().Read(decoder.scratch[:2]); err != nil { + if _, err := decoder.input.Read(decoder.scratch[:2]); err != nil { return 0, err } return uint16(decoder.scratch[0]) | uint16(decoder.scratch[1])<<8, nil } func (decoder *Decoder) UInt32() (uint32, error) { - if _, err := decoder.Get().Read(decoder.scratch[:4]); err != nil { + if _, err := decoder.input.Read(decoder.scratch[:4]); err != nil { return 0, err } return uint32(decoder.scratch[0]) | @@ -107,7 +115,7 @@ func (decoder *Decoder) UInt32() (uint32, error) { } func (decoder *Decoder) UInt64() (uint64, error) { - if _, err := decoder.Get().Read(decoder.scratch[:8]); err != nil { + if _, err := decoder.input.Read(decoder.scratch[:8]); err != nil { return 0, err } return uint64(decoder.scratch[0]) | @@ -137,11 +145,11 @@ func (decoder *Decoder) Float64() (float64, error) { } func (decoder *Decoder) Fixed(ln int) ([]byte, error) { - if reader, ok := decoder.Get().(FixedReader); ok { + if reader, ok := decoder.input.(interface{ Fixed(ln int) ([]byte, error) }); ok { return reader.Fixed(ln) } buf := make([]byte, ln) - if _, err := decoder.Get().Read(buf); err != nil { + if _, err := decoder.input.Read(buf); err != nil { return nil, err } return buf, nil @@ -159,19 +167,9 @@ func (decoder *Decoder) String() (string, error) { return string(str), nil } -func (decoder *Decoder) Decimal128() ([]byte, error) { - bytes := make([]byte, 16) - _, err := decoder.Get().Read(bytes) - return bytes, err -} - func (decoder *Decoder) ReadByte() (byte, error) { - if _, err := decoder.Get().Read(decoder.scratch[:1]); err != nil { + if _, err := decoder.input.Read(decoder.scratch[:1]); err != nil { return 0x0, err } return decoder.scratch[0], nil } - -type FixedReader interface { - Fixed(ln int) ([]byte, error) -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/encoder.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/encoder.go new file mode 100644 index 00000000..1ebc45ca --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/encoder.go @@ -0,0 +1,146 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package binary + +import ( + "encoding/binary" + "io" + "math" +) + +func NewEncoder(w io.Writer) *Encoder { + return &Encoder{ + output: w, + } +} + +type Encoder struct { + output io.Writer + scratch [binary.MaxVarintLen64]byte +} + +func (enc *Encoder) Raw(b []byte) error { + if _, err := enc.output.Write(b); err != nil { + return err + } + return nil +} + +func (enc *Encoder) Bool(v bool) error { + if v { + return enc.UInt8(1) + } + return enc.UInt8(0) +} + +func (enc *Encoder) Byte(b byte) error { + return enc.UInt8(b) +} + +func (enc *Encoder) Int8(v int8) error { + return enc.UInt8(uint8(v)) +} + +func (enc *Encoder) Int16(v int16) error { + return enc.UInt16(uint16(v)) +} + +func (enc *Encoder) Int32(v int32) error { + return enc.UInt32(uint32(v)) +} + +func (enc *Encoder) Int64(v int64) error { + return enc.UInt64(uint64(v)) +} + +func (enc *Encoder) UInt8(v uint8) error { + enc.scratch[0] = v + if _, err := enc.output.Write(enc.scratch[:1]); err != nil { + return err + } + return nil +} + +func (enc *Encoder) UInt16(v uint16) error { + enc.scratch[0] = byte(v) + enc.scratch[1] = byte(v >> 8) + if _, err := enc.output.Write(enc.scratch[:2]); err != nil { + return err + } + return nil +} + +func (enc *Encoder) UInt32(v uint32) error { + enc.scratch[0] = byte(v) + enc.scratch[1] = byte(v >> 8) + enc.scratch[2] = byte(v >> 16) + enc.scratch[3] = byte(v >> 24) + if _, err := enc.output.Write(enc.scratch[:4]); err != nil { + return err + } + return nil +} + +func (enc *Encoder) UInt64(v uint64) error { + enc.scratch[0] = byte(v) + enc.scratch[1] = byte(v >> 8) + enc.scratch[2] = byte(v >> 16) + enc.scratch[3] = byte(v >> 24) + enc.scratch[4] = byte(v >> 32) + enc.scratch[5] = byte(v >> 40) + enc.scratch[6] = byte(v >> 48) + enc.scratch[7] = byte(v >> 56) + if _, err := enc.output.Write(enc.scratch[:8]); err != nil { + return err + } + return nil +} + +func (enc *Encoder) Float32(v float32) error { + return enc.UInt32(math.Float32bits(v)) +} + +func (enc *Encoder) Float64(v float64) error { + return enc.UInt64(math.Float64bits(v)) +} + +func (enc *Encoder) Uvarint(v uint64) error { + ln := binary.PutUvarint(enc.scratch[:binary.MaxVarintLen64], v) + if _, err := enc.output.Write(enc.scratch[0:ln]); err != nil { + return err + } + return nil +} + +func (enc *Encoder) Flush() error { + if w, ok := enc.output.(interface{ Flush() error }); ok { + return w.Flush() + } + return nil +} + +func (enc *Encoder) String(v string) error { + str := Str2Bytes(v) + if err := enc.Uvarint(uint64(len(str))); err != nil { + return err + } + if _, err := enc.output.Write(str); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/string.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/string.go new file mode 100644 index 00000000..f94ef288 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/string.go @@ -0,0 +1,39 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package binary + +import ( + "reflect" + "unsafe" +) + +// Copied from https://github.com/m3db/m3/blob/master/src/x/unsafe/string.go#L62 + +func unsafeStr2Bytes(str string) []byte { + if len(str) == 0 { + return nil + } + var scratch []byte + { + slice := (*reflect.SliceHeader)(unsafe.Pointer(&scratch)) + slice.Len = len(str) + slice.Cap = len(str) + slice.Data = (*reflect.StringHeader)(unsafe.Pointer(&str)).Data + } + return scratch +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/string_safe.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/string_safe.go new file mode 100644 index 00000000..0008b25d --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/string_safe.go @@ -0,0 +1,25 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//go:build !amd64 && !arm64 +// +build !amd64,!arm64 + +package binary + +func Str2Bytes(str string) []byte { + return []byte(str) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/string_unsafe.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/string_unsafe.go new file mode 100644 index 00000000..8a101d1c --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/binary/string_unsafe.go @@ -0,0 +1,25 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//go:build amd64 || arm64 +// +build amd64 arm64 + +package binary + +func Str2Bytes(str string) []byte { + return unsafeStr2Bytes(str) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/cityhash102/city64.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/cityhash102/city64.go new file mode 100644 index 00000000..1dc1f8ec --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/cityhash102/city64.go @@ -0,0 +1,62 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package cityhash102 + +import ( + "encoding/binary" + "hash" +) + +type City64 struct { + s []byte +} + +var _ hash.Hash64 = (*City64)(nil) +var _ hash.Hash = (*City64)(nil) + +func New64() hash.Hash64 { + return &City64{} +} + +func (this *City64) Sum(b []byte) []byte { + b2 := make([]byte, 8) + binary.BigEndian.PutUint64(b2, this.Sum64()) + b = append(b, b2...) + return b +} + +func (this *City64) Sum64() uint64 { + return CityHash64(this.s, uint32(len(this.s))) +} + +func (this *City64) Reset() { + this.s = this.s[0:0] +} + +func (this *City64) BlockSize() int { + return 1 +} + +func (this *City64) Write(s []byte) (n int, err error) { + this.s = append(this.s, s...) + return len(s), nil +} + +func (this *City64) Size() int { + return 8 +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/lib/cityhash102/cityhash.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/cityhash102/cityhash.go similarity index 92% rename from vendor/github.com/ClickHouse/clickhouse-go/lib/cityhash102/cityhash.go rename to vendor/github.com/ClickHouse/clickhouse-go/v2/lib/cityhash102/cityhash.go index dcc666b6..410aafda 100644 --- a/vendor/github.com/ClickHouse/clickhouse-go/lib/cityhash102/cityhash.go +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/cityhash102/cityhash.go @@ -1,3 +1,20 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + /* * Go implementation of Google city hash (MIT license) * https://code.google.com/p/cityhash/ diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/cityhash102/doc.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/cityhash102/doc.go new file mode 100644 index 00000000..e6046909 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/cityhash102/doc.go @@ -0,0 +1,22 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +/** COPY from https://github.com/zentures/cityhash/ + +NOTE: The code is modified to be compatible with CityHash128 used in ClickHouse +*/ +package cityhash102 diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/array.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/array.go new file mode 100644 index 00000000..d217c7df --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/array.go @@ -0,0 +1,255 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + "strings" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type offset struct { + values UInt64 + scanType reflect.Type +} + +type Array struct { + depth int + chType Type + values Interface + offsets []*offset + scanType reflect.Type +} + +func (col *Array) parse(t Type) (_ Interface, err error) { + col.chType = t + var typeStr = string(t) + +parse: + for { + switch { + case strings.HasPrefix(typeStr, "Array("): + col.depth++ + typeStr = strings.TrimPrefix(typeStr, "Array(") + typeStr = strings.TrimSuffix(typeStr, ")") + default: + break parse + } + } + if col.depth != 0 { + if col.values, err = Type(typeStr).Column(); err != nil { + return nil, err + } + offsetScanTypes := make([]reflect.Type, 0, col.depth) + col.offsets, col.scanType = make([]*offset, 0, col.depth), col.values.ScanType() + for i := 0; i < col.depth; i++ { + col.scanType = reflect.SliceOf(col.scanType) + offsetScanTypes = append(offsetScanTypes, col.scanType) + } + for i := len(offsetScanTypes) - 1; i >= 0; i-- { + col.offsets = append(col.offsets, &offset{ + scanType: offsetScanTypes[i], + }) + } + return col, nil + } + return nil, &UnsupportedColumnTypeError{ + t: t, + } +} + +func (col *Array) Base() Interface { + return col.values +} + +func (col *Array) Type() Type { + return col.chType +} + +func (col *Array) ScanType() reflect.Type { + return col.scanType +} + +func (col *Array) Rows() int { + if len(col.offsets) != 0 { + return len(col.offsets[0].values) + } + return 0 +} + +func (col *Array) Row(i int, ptr bool) interface{} { + return col.make(uint64(i), 0).Interface() +} + +func (col *Array) ScanRow(dest interface{}, row int) error { + elem := reflect.Indirect(reflect.ValueOf(dest)) + if elem.Type() != col.scanType { + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: string(col.chType), + Hint: fmt.Sprintf("try using *%s", col.scanType), + } + } + { + elem.Set(col.make(uint64(row), 0)) + } + return nil +} + +func (col *Array) Append(v interface{}) (nulls []uint8, err error) { + value := reflect.Indirect(reflect.ValueOf(v)) + if value.Kind() != reflect.Slice { + return nil, &ColumnConverterError{ + Op: "Append", + To: string(col.chType), + From: fmt.Sprintf("%T", v), + Hint: "value must be a slice", + } + } + for i := 0; i < value.Len(); i++ { + if err := col.AppendRow(value.Index(i)); err != nil { + return nil, err + } + } + return +} + +func (col *Array) AppendRow(v interface{}) error { + var elem reflect.Value + switch v := v.(type) { + case reflect.Value: + elem = reflect.Indirect(v) + default: + elem = reflect.Indirect(reflect.ValueOf(v)) + } + if !elem.IsValid() || elem.Type() != col.scanType { + from := fmt.Sprintf("%T", v) + if !elem.IsValid() { + from = fmt.Sprintf("%v", v) + } + return &ColumnConverterError{ + Op: "AppendRow", + To: string(col.chType), + From: from, + Hint: fmt.Sprintf("try using %s", col.scanType), + } + } + return col.append(elem, 0) +} + +func (col *Array) append(elem reflect.Value, level int) error { + if level < col.depth { + offset := uint64(elem.Len()) + if ln := len(col.offsets[level].values); ln != 0 { + offset += col.offsets[level].values[ln-1] + } + col.offsets[level].values = append(col.offsets[level].values, offset) + for i := 0; i < elem.Len(); i++ { + if err := col.append(elem.Index(i), level+1); err != nil { + return err + } + } + return nil + } + if elem.Kind() == reflect.Ptr && elem.IsNil() { + return col.values.AppendRow(nil) + } + return col.values.AppendRow(elem.Interface()) +} + +func (col *Array) Decode(decoder *binary.Decoder, rows int) error { + for _, offset := range col.offsets { + if err := offset.values.Decode(decoder, rows); err != nil { + return err + } + switch { + case len(offset.values) > 0: + rows = int(offset.values[len(offset.values)-1]) + default: + rows = 0 + } + } + return col.values.Decode(decoder, rows) +} + +func (col *Array) Encode(encoder *binary.Encoder) error { + for _, offset := range col.offsets { + if err := offset.values.Encode(encoder); err != nil { + return err + } + } + return col.values.Encode(encoder) +} + +func (col *Array) ReadStatePrefix(decoder *binary.Decoder) error { + if serialize, ok := col.values.(CustomSerialization); ok { + if err := serialize.ReadStatePrefix(decoder); err != nil { + return err + } + } + return nil +} + +func (col *Array) WriteStatePrefix(encoder *binary.Encoder) error { + if serialize, ok := col.values.(CustomSerialization); ok { + if err := serialize.WriteStatePrefix(encoder); err != nil { + return err + } + } + return nil +} + +func (col *Array) make(row uint64, level int) reflect.Value { + offset := col.offsets[level] + var ( + end = offset.values[row] + start = uint64(0) + ) + if row > 0 { + start = offset.values[row-1] + } + var ( + base = offset.scanType.Elem() + isPtr = base.Kind() == reflect.Ptr + slice = reflect.MakeSlice(offset.scanType, 0, int(end-start)) + ) + for i := start; i < end; i++ { + var value reflect.Value + switch { + case level == len(col.offsets)-1: + switch v := col.values.Row(int(i), isPtr); { + case v == nil: + value = reflect.Zero(base) + default: + value = reflect.ValueOf(v) + } + default: + value = col.make(i, level+1) + } + slice = reflect.Append(slice, value) + } + return slice +} + +var ( + _ Interface = (*Array)(nil) + _ CustomSerialization = (*Array)(nil) +) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/bigint.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/bigint.go new file mode 100644 index 00000000..163df0a9 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/bigint.go @@ -0,0 +1,179 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "math/big" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type BigInt struct { + size int + data []byte + chType Type +} + +func (col *BigInt) Type() Type { + return col.chType +} + +func (col *BigInt) ScanType() reflect.Type { + return scanTypeBigInt +} + +func (col *BigInt) Rows() int { + return len(col.data) / col.size +} + +func (col *BigInt) Row(i int, ptr bool) interface{} { + value := col.row(i) + if ptr { + return value + } + return *value +} + +func (col *BigInt) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *big.Int: + *d = *col.row(row) + case **big.Int: + *d = new(big.Int) + **d = *col.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: string(col.chType), + } + } + return nil +} + +func (col *BigInt) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []big.Int: + nulls = make([]uint8, len(v)) + for _, v := range v { + col.append(&v) + } + case []*big.Int: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + col.append(v) + default: + col.data, nulls[i] = append(col.data, make([]byte, col.size)...), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: string(col.chType), + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *BigInt) AppendRow(v interface{}) error { + switch v := v.(type) { + case big.Int: + col.append(&v) + case *big.Int: + switch { + case v != nil: + col.append(v) + default: + col.data = append(col.data, make([]byte, col.size)...) + } + case nil: + col.data = append(col.data, make([]byte, col.size)...) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: string(col.chType), + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *BigInt) Decode(decoder *binary.Decoder, rows int) error { + col.data = make([]byte, rows*col.size) + return decoder.Raw(col.data) +} + +func (col *BigInt) Encode(encoder *binary.Encoder) error { + return encoder.Raw(col.data) +} + +func (col *BigInt) row(i int) *big.Int { + return rawToBigInt(col.data[i*col.size : (i+1)*col.size]) +} + +func (col *BigInt) append(v *big.Int) { + dest := make([]byte, col.size) + bigIntToRaw(dest, new(big.Int).Set(v)) + col.data = append(col.data, dest...) +} + +func bigIntToRaw(dest []byte, v *big.Int) { + var sign int + if v.Sign() < 0 { + v.Not(v).FillBytes(dest) + sign = -1 + } else { + v.FillBytes(dest) + } + endianSwap(dest, sign < 0) +} + +func rawToBigInt(v []byte) *big.Int { + // LittleEndian to BigEndian + endianSwap(v, false) + var lt = new(big.Int) + if len(v) > 0 && v[0]&0x80 != 0 { + // [0] ^ will +1 + for i := 0; i < len(v); i++ { + v[i] = ^v[i] + } + lt.SetBytes(v) + // neg ^ will -1 + lt.Not(lt) + } else { + lt.SetBytes(v) + } + return lt +} + +func endianSwap(src []byte, not bool) { + for i := 0; i < len(src)/2; i++ { + if not { + src[i], src[len(src)-i-1] = ^src[len(src)-i-1], ^src[i] + } else { + src[i], src[len(src)-i-1] = src[len(src)-i-1], src[i] + } + } +} + +var _ Interface = (*BigInt)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/bool.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/bool.go new file mode 100644 index 00000000..f52fdd35 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/bool.go @@ -0,0 +1,145 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type Bool struct { + values UInt8 +} + +func (col *Bool) Type() Type { + return "Bool" +} + +func (col *Bool) ScanType() reflect.Type { + return scanTypeBool +} + +func (col *Bool) Rows() int { + return len(col.values) +} + +func (col *Bool) Row(i int, ptr bool) interface{} { + val := col.row(i) + if ptr { + return &val + } + return val +} + +func (col *Bool) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *bool: + *d = col.row(row) + case **bool: + *d = new(bool) + **d = col.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Bool", + } + } + return nil +} + +func (col *Bool) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []bool: + in := make([]uint8, 0, len(v)) + for _, v := range v { + switch { + case v: + in = append(in, 1) + default: + in = append(in, 0) + } + } + col.values, nulls = append(col.values, in...), make([]uint8, len(v)) + case []*bool: + nulls = make([]uint8, len(v)) + in := make([]uint8, 0, len(v)) + for i, v := range v { + var value uint8 + switch { + case v != nil: + if *v { + value = 1 + } + default: + nulls[i] = 1 + } + in = append(in, value) + } + col.values = append(col.values, in...) + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Bool", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *Bool) AppendRow(v interface{}) error { + var value bool + switch v := v.(type) { + case bool: + value = v + case *bool: + if v != nil { + value = *v + } + case nil: + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Bool", + From: fmt.Sprintf("%T", v), + } + } + switch { + case value: + col.values = append(col.values, 1) + default: + col.values = append(col.values, 0) + } + return nil +} + +func (col *Bool) Decode(decoder *binary.Decoder, rows int) error { + return col.values.Decode(decoder, rows) +} + +func (col *Bool) Encode(encoder *binary.Encoder) error { + return col.values.Encode(encoder) +} + +func (col *Bool) row(i int) bool { + return col.values[i] == 1 +} + +var _ Interface = (*Bool)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column.go new file mode 100644 index 00000000..a58e3b4f --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column.go @@ -0,0 +1,85 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + "strings" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type Type string + +func (t Type) params() string { + switch start, end := strings.Index(string(t), "("), strings.LastIndex(string(t), ")"); { + case len(t) == 0, start <= 0, end <= 0, end < start: + return "" + default: + return string(t[start+1 : end]) + } +} + +type Error struct { + ColumnType string + Err error +} + +func (e *Error) Error() string { + return fmt.Sprintf("%s: %s", e.ColumnType, e.Err) +} + +type ColumnConverterError struct { + Op string + Hint string + From, To string +} + +func (e *ColumnConverterError) Error() string { + var hint string + if len(e.Hint) != 0 { + hint += ". " + e.Hint + } + return fmt.Sprintf("clickhouse [%s]: converting %s to %s is unsupported%s", e.Op, e.From, e.To, hint) +} + +type UnsupportedColumnTypeError struct { + t Type +} + +func (e *UnsupportedColumnTypeError) Error() string { + return fmt.Sprintf("clickhouse: unsupported column type %q", e.t) +} + +type Interface interface { + Type() Type + Rows() int + Row(i int, ptr bool) interface{} + ScanRow(dest interface{}, row int) error + Append(v interface{}) (nulls []uint8, err error) + AppendRow(v interface{}) error + Decode(decoder *binary.Decoder, rows int) error + Encode(*binary.Encoder) error + ScanType() reflect.Type +} + +type CustomSerialization interface { + ReadStatePrefix(*binary.Decoder) error + WriteStatePrefix(*binary.Encoder) error +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column_gen.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column_gen.go new file mode 100644 index 00000000..7345c67e --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column_gen.go @@ -0,0 +1,1071 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Code generated by make codegen DO NOT EDIT. +// source: lib/column/codegen/column.tpl + +package column + +import ( + "fmt" + "github.com/google/uuid" + "github.com/paulmach/orb" + "github.com/shopspring/decimal" + "math/big" + "net" + "reflect" + "strings" + "time" +) + +func (t Type) Column() (Interface, error) { + switch t { + case "Float32": + return &Float32{}, nil + case "Float64": + return &Float64{}, nil + case "Int8": + return &Int8{}, nil + case "Int16": + return &Int16{}, nil + case "Int32": + return &Int32{}, nil + case "Int64": + return &Int64{}, nil + case "UInt8": + return &UInt8{}, nil + case "UInt16": + return &UInt16{}, nil + case "UInt32": + return &UInt32{}, nil + case "UInt64": + return &UInt64{}, nil + case "Int128": + return &BigInt{ + size: 16, + chType: t, + }, nil + case "Int256": + return &BigInt{ + size: 32, + chType: t, + }, nil + case "UInt256": + return &BigInt{ + size: 32, + chType: t, + }, nil + case "IPv4": + return &IPv4{}, nil + case "IPv6": + return &IPv6{}, nil + case "Bool", "Boolean": + return &Bool{}, nil + case "Date": + return &Date{}, nil + case "Date32": + return &Date32{}, nil + case "UUID": + return &UUID{}, nil + case "Nothing": + return &Nothing{}, nil + case "Ring": + v, err := (&Array{}).parse("Array(Point)") + if err != nil { + return nil, err + } + set := v.(*Array) + set.chType = "Ring" + return &Ring{ + set: set, + }, nil + case "Polygon": + v, err := (&Array{}).parse("Array(Ring)") + if err != nil { + return nil, err + } + set := v.(*Array) + set.chType = "Polygon" + return &Polygon{ + set: set, + }, nil + case "MultiPolygon": + v, err := (&Array{}).parse("Array(Polygon)") + if err != nil { + return nil, err + } + set := v.(*Array) + set.chType = "MultiPolygon" + return &MultiPolygon{ + set: set, + }, nil + case "Point": + return &Point{}, nil + case "String": + return &String{}, nil + } + + switch strType := string(t); { + case strings.HasPrefix(string(t), "Map("): + return (&Map{}).parse(t) + case strings.HasPrefix(string(t), "Tuple("): + return (&Tuple{}).parse(t) + case strings.HasPrefix(string(t), "Decimal("): + return (&Decimal{}).parse(t) + case strings.HasPrefix(strType, "Nested("): + return (&Nested{}).parse(t) + case strings.HasPrefix(string(t), "Array("): + return (&Array{}).parse(t) + case strings.HasPrefix(string(t), "Interval"): + return (&Interval{}).parse(t) + case strings.HasPrefix(string(t), "Nullable"): + return (&Nullable{}).parse(t) + case strings.HasPrefix(string(t), "FixedString"): + return (&FixedString{}).parse(t) + case strings.HasPrefix(string(t), "LowCardinality"): + return (&LowCardinality{}).parse(t) + case strings.HasPrefix(string(t), "SimpleAggregateFunction"): + return (&SimpleAggregateFunction{}).parse(t) + case strings.HasPrefix(string(t), "Enum8") || strings.HasPrefix(string(t), "Enum16"): + return Enum(t) + case strings.HasPrefix(string(t), "DateTime64"): + return (&DateTime64{}).parse(t) + case strings.HasPrefix(strType, "DateTime") && !strings.HasPrefix(strType, "DateTime64"): + return (&DateTime{}).parse(t) + } + return nil, &UnsupportedColumnTypeError{ + t: t, + } +} + +type ( + Float32 []float32 + Float64 []float64 + Int8 []int8 + Int16 []int16 + Int32 []int32 + Int64 []int64 + UInt8 []uint8 + UInt16 []uint16 + UInt32 []uint32 + UInt64 []uint64 +) + +var ( + _ Interface = (*Float32)(nil) + _ Interface = (*Float64)(nil) + _ Interface = (*Int8)(nil) + _ Interface = (*Int16)(nil) + _ Interface = (*Int32)(nil) + _ Interface = (*Int64)(nil) + _ Interface = (*UInt8)(nil) + _ Interface = (*UInt16)(nil) + _ Interface = (*UInt32)(nil) + _ Interface = (*UInt64)(nil) +) + +var ( + scanTypeFloat32 = reflect.TypeOf(float32(0)) + scanTypeFloat64 = reflect.TypeOf(float64(0)) + scanTypeInt8 = reflect.TypeOf(int8(0)) + scanTypeInt16 = reflect.TypeOf(int16(0)) + scanTypeInt32 = reflect.TypeOf(int32(0)) + scanTypeInt64 = reflect.TypeOf(int64(0)) + scanTypeUInt8 = reflect.TypeOf(uint8(0)) + scanTypeUInt16 = reflect.TypeOf(uint16(0)) + scanTypeUInt32 = reflect.TypeOf(uint32(0)) + scanTypeUInt64 = reflect.TypeOf(uint64(0)) + scanTypeIP = reflect.TypeOf(net.IP{}) + scanTypeBool = reflect.TypeOf(true) + scanTypeByte = reflect.TypeOf([]byte{}) + scanTypeUUID = reflect.TypeOf(uuid.UUID{}) + scanTypeTime = reflect.TypeOf(time.Time{}) + scanTypeRing = reflect.TypeOf(orb.Ring{}) + scanTypePoint = reflect.TypeOf(orb.Point{}) + scanTypeSlice = reflect.TypeOf([]interface{}{}) + scanTypeBigInt = reflect.TypeOf(&big.Int{}) + scanTypeString = reflect.TypeOf("") + scanTypePolygon = reflect.TypeOf(orb.Polygon{}) + scanTypeDecimal = reflect.TypeOf(decimal.Decimal{}) + scanTypeMultiPolygon = reflect.TypeOf(orb.MultiPolygon{}) +) + +func (col *Float32) Type() Type { + return "Float32" +} + +func (col *Float32) ScanType() reflect.Type { + return scanTypeFloat32 +} + +func (col *Float32) Rows() int { + return len(*col) +} + +func (col *Float32) ScanRow(dest interface{}, row int) error { + value := *col + switch d := dest.(type) { + case *float32: + *d = value[row] + case **float32: + *d = new(float32) + **d = value[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Float32", + Hint: fmt.Sprintf("try using *%s", scanTypeFloat32), + } + } + return nil +} + +func (col *Float32) Row(i int, ptr bool) interface{} { + value := *col + if ptr { + return &value[i] + } + return value[i] +} + +func (col *Float32) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []float32: + *col, nulls = append(*col, v...), make([]uint8, len(v)) + case []*float32: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + *col = append(*col, *v) + default: + *col, nulls[i] = append(*col, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Float32", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *Float32) AppendRow(v interface{}) error { + switch v := v.(type) { + case float32: + *col = append(*col, v) + case *float32: + switch { + case v != nil: + *col = append(*col, *v) + default: + *col = append(*col, 0) + } + case nil: + *col = append(*col, 0) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Float32", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *Float64) Type() Type { + return "Float64" +} + +func (col *Float64) ScanType() reflect.Type { + return scanTypeFloat64 +} + +func (col *Float64) Rows() int { + return len(*col) +} + +func (col *Float64) ScanRow(dest interface{}, row int) error { + value := *col + switch d := dest.(type) { + case *float64: + *d = value[row] + case **float64: + *d = new(float64) + **d = value[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Float64", + Hint: fmt.Sprintf("try using *%s", scanTypeFloat64), + } + } + return nil +} + +func (col *Float64) Row(i int, ptr bool) interface{} { + value := *col + if ptr { + return &value[i] + } + return value[i] +} + +func (col *Float64) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []float64: + *col, nulls = append(*col, v...), make([]uint8, len(v)) + case []*float64: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + *col = append(*col, *v) + default: + *col, nulls[i] = append(*col, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Float64", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *Float64) AppendRow(v interface{}) error { + switch v := v.(type) { + case float64: + *col = append(*col, v) + case *float64: + switch { + case v != nil: + *col = append(*col, *v) + default: + *col = append(*col, 0) + } + case nil: + *col = append(*col, 0) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Float64", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *Int8) Type() Type { + return "Int8" +} + +func (col *Int8) ScanType() reflect.Type { + return scanTypeInt8 +} + +func (col *Int8) Rows() int { + return len(*col) +} + +func (col *Int8) ScanRow(dest interface{}, row int) error { + value := *col + switch d := dest.(type) { + case *int8: + *d = value[row] + case **int8: + *d = new(int8) + **d = value[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Int8", + Hint: fmt.Sprintf("try using *%s", scanTypeInt8), + } + } + return nil +} + +func (col *Int8) Row(i int, ptr bool) interface{} { + value := *col + if ptr { + return &value[i] + } + return value[i] +} + +func (col *Int8) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []int8: + *col, nulls = append(*col, v...), make([]uint8, len(v)) + case []*int8: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + *col = append(*col, *v) + default: + *col, nulls[i] = append(*col, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Int8", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *Int8) AppendRow(v interface{}) error { + switch v := v.(type) { + case int8: + *col = append(*col, v) + case *int8: + switch { + case v != nil: + *col = append(*col, *v) + default: + *col = append(*col, 0) + } + case nil: + *col = append(*col, 0) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Int8", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *Int16) Type() Type { + return "Int16" +} + +func (col *Int16) ScanType() reflect.Type { + return scanTypeInt16 +} + +func (col *Int16) Rows() int { + return len(*col) +} + +func (col *Int16) ScanRow(dest interface{}, row int) error { + value := *col + switch d := dest.(type) { + case *int16: + *d = value[row] + case **int16: + *d = new(int16) + **d = value[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Int16", + Hint: fmt.Sprintf("try using *%s", scanTypeInt16), + } + } + return nil +} + +func (col *Int16) Row(i int, ptr bool) interface{} { + value := *col + if ptr { + return &value[i] + } + return value[i] +} + +func (col *Int16) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []int16: + *col, nulls = append(*col, v...), make([]uint8, len(v)) + case []*int16: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + *col = append(*col, *v) + default: + *col, nulls[i] = append(*col, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Int16", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *Int16) AppendRow(v interface{}) error { + switch v := v.(type) { + case int16: + *col = append(*col, v) + case *int16: + switch { + case v != nil: + *col = append(*col, *v) + default: + *col = append(*col, 0) + } + case nil: + *col = append(*col, 0) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Int16", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *Int32) Type() Type { + return "Int32" +} + +func (col *Int32) ScanType() reflect.Type { + return scanTypeInt32 +} + +func (col *Int32) Rows() int { + return len(*col) +} + +func (col *Int32) ScanRow(dest interface{}, row int) error { + value := *col + switch d := dest.(type) { + case *int32: + *d = value[row] + case **int32: + *d = new(int32) + **d = value[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Int32", + Hint: fmt.Sprintf("try using *%s", scanTypeInt32), + } + } + return nil +} + +func (col *Int32) Row(i int, ptr bool) interface{} { + value := *col + if ptr { + return &value[i] + } + return value[i] +} + +func (col *Int32) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []int32: + *col, nulls = append(*col, v...), make([]uint8, len(v)) + case []*int32: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + *col = append(*col, *v) + default: + *col, nulls[i] = append(*col, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Int32", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *Int32) AppendRow(v interface{}) error { + switch v := v.(type) { + case int32: + *col = append(*col, v) + case *int32: + switch { + case v != nil: + *col = append(*col, *v) + default: + *col = append(*col, 0) + } + case nil: + *col = append(*col, 0) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Int32", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *Int64) Type() Type { + return "Int64" +} + +func (col *Int64) ScanType() reflect.Type { + return scanTypeInt64 +} + +func (col *Int64) Rows() int { + return len(*col) +} + +func (col *Int64) ScanRow(dest interface{}, row int) error { + value := *col + switch d := dest.(type) { + case *int64: + *d = value[row] + case **int64: + *d = new(int64) + **d = value[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Int64", + Hint: fmt.Sprintf("try using *%s", scanTypeInt64), + } + } + return nil +} + +func (col *Int64) Row(i int, ptr bool) interface{} { + value := *col + if ptr { + return &value[i] + } + return value[i] +} + +func (col *Int64) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []int64: + *col, nulls = append(*col, v...), make([]uint8, len(v)) + case []*int64: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + *col = append(*col, *v) + default: + *col, nulls[i] = append(*col, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Int64", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *Int64) AppendRow(v interface{}) error { + switch v := v.(type) { + case int64: + *col = append(*col, v) + case *int64: + switch { + case v != nil: + *col = append(*col, *v) + default: + *col = append(*col, 0) + } + case nil: + *col = append(*col, 0) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Int64", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *UInt8) Type() Type { + return "UInt8" +} + +func (col *UInt8) ScanType() reflect.Type { + return scanTypeUInt8 +} + +func (col *UInt8) Rows() int { + return len(*col) +} + +func (col *UInt8) ScanRow(dest interface{}, row int) error { + value := *col + switch d := dest.(type) { + case *uint8: + *d = value[row] + case **uint8: + *d = new(uint8) + **d = value[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "UInt8", + Hint: fmt.Sprintf("try using *%s", scanTypeUInt8), + } + } + return nil +} + +func (col *UInt8) Row(i int, ptr bool) interface{} { + value := *col + if ptr { + return &value[i] + } + return value[i] +} + +func (col *UInt8) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []uint8: + *col, nulls = append(*col, v...), make([]uint8, len(v)) + case []*uint8: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + *col = append(*col, *v) + default: + *col, nulls[i] = append(*col, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "UInt8", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *UInt8) AppendRow(v interface{}) error { + switch v := v.(type) { + case uint8: + *col = append(*col, v) + case *uint8: + switch { + case v != nil: + *col = append(*col, *v) + default: + *col = append(*col, 0) + } + case nil: + *col = append(*col, 0) + case bool: + var t uint8 + if v { + t = 1 + } + *col = append(*col, t) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "UInt8", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *UInt16) Type() Type { + return "UInt16" +} + +func (col *UInt16) ScanType() reflect.Type { + return scanTypeUInt16 +} + +func (col *UInt16) Rows() int { + return len(*col) +} + +func (col *UInt16) ScanRow(dest interface{}, row int) error { + value := *col + switch d := dest.(type) { + case *uint16: + *d = value[row] + case **uint16: + *d = new(uint16) + **d = value[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "UInt16", + Hint: fmt.Sprintf("try using *%s", scanTypeUInt16), + } + } + return nil +} + +func (col *UInt16) Row(i int, ptr bool) interface{} { + value := *col + if ptr { + return &value[i] + } + return value[i] +} + +func (col *UInt16) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []uint16: + *col, nulls = append(*col, v...), make([]uint8, len(v)) + case []*uint16: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + *col = append(*col, *v) + default: + *col, nulls[i] = append(*col, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "UInt16", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *UInt16) AppendRow(v interface{}) error { + switch v := v.(type) { + case uint16: + *col = append(*col, v) + case *uint16: + switch { + case v != nil: + *col = append(*col, *v) + default: + *col = append(*col, 0) + } + case nil: + *col = append(*col, 0) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "UInt16", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *UInt32) Type() Type { + return "UInt32" +} + +func (col *UInt32) ScanType() reflect.Type { + return scanTypeUInt32 +} + +func (col *UInt32) Rows() int { + return len(*col) +} + +func (col *UInt32) ScanRow(dest interface{}, row int) error { + value := *col + switch d := dest.(type) { + case *uint32: + *d = value[row] + case **uint32: + *d = new(uint32) + **d = value[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "UInt32", + Hint: fmt.Sprintf("try using *%s", scanTypeUInt32), + } + } + return nil +} + +func (col *UInt32) Row(i int, ptr bool) interface{} { + value := *col + if ptr { + return &value[i] + } + return value[i] +} + +func (col *UInt32) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []uint32: + *col, nulls = append(*col, v...), make([]uint8, len(v)) + case []*uint32: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + *col = append(*col, *v) + default: + *col, nulls[i] = append(*col, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "UInt32", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *UInt32) AppendRow(v interface{}) error { + switch v := v.(type) { + case uint32: + *col = append(*col, v) + case *uint32: + switch { + case v != nil: + *col = append(*col, *v) + default: + *col = append(*col, 0) + } + case nil: + *col = append(*col, 0) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "UInt32", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *UInt64) Type() Type { + return "UInt64" +} + +func (col *UInt64) ScanType() reflect.Type { + return scanTypeUInt64 +} + +func (col *UInt64) Rows() int { + return len(*col) +} + +func (col *UInt64) ScanRow(dest interface{}, row int) error { + value := *col + switch d := dest.(type) { + case *uint64: + *d = value[row] + case **uint64: + *d = new(uint64) + **d = value[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "UInt64", + Hint: fmt.Sprintf("try using *%s", scanTypeUInt64), + } + } + return nil +} + +func (col *UInt64) Row(i int, ptr bool) interface{} { + value := *col + if ptr { + return &value[i] + } + return value[i] +} + +func (col *UInt64) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []uint64: + *col, nulls = append(*col, v...), make([]uint8, len(v)) + case []*uint64: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + *col = append(*col, *v) + default: + *col, nulls[i] = append(*col, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "UInt64", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *UInt64) AppendRow(v interface{}) error { + switch v := v.(type) { + case uint64: + *col = append(*col, v) + case *uint64: + switch { + case v != nil: + *col = append(*col, *v) + default: + *col = append(*col, 0) + } + case nil: + *col = append(*col, 0) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "UInt64", + From: fmt.Sprintf("%T", v), + } + } + return nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column_safe_gen.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column_safe_gen.go new file mode 100644 index 00000000..14cf5206 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column_safe_gen.go @@ -0,0 +1,228 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//go:build !amd64 && !arm64 +// +build !amd64,!arm64 + +// Code generated by make codegen DO NOT EDIT. +// source: lib/column/codegen/column_safe.tpl + +package column + +import ( + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +func (col *Float32) Decode(decoder *binary.Decoder, rows int) error { + for i := 0; i < rows; i++ { + v, err := decoder.Float32() + if err != nil { + return err + } + *col = append(*col, v) + } + return nil +} + +func (col *Float32) Encode(encoder *binary.Encoder) error { + for _, v := range *col { + if err := encoder.Float32(v); err != nil { + return err + } + } + return nil +} + +func (col *Float64) Decode(decoder *binary.Decoder, rows int) error { + for i := 0; i < rows; i++ { + v, err := decoder.Float64() + if err != nil { + return err + } + *col = append(*col, v) + } + return nil +} + +func (col *Float64) Encode(encoder *binary.Encoder) error { + for _, v := range *col { + if err := encoder.Float64(v); err != nil { + return err + } + } + return nil +} + +func (col *Int8) Decode(decoder *binary.Decoder, rows int) error { + for i := 0; i < rows; i++ { + v, err := decoder.Int8() + if err != nil { + return err + } + *col = append(*col, v) + } + return nil +} + +func (col *Int8) Encode(encoder *binary.Encoder) error { + for _, v := range *col { + if err := encoder.Int8(v); err != nil { + return err + } + } + return nil +} + +func (col *Int16) Decode(decoder *binary.Decoder, rows int) error { + for i := 0; i < rows; i++ { + v, err := decoder.Int16() + if err != nil { + return err + } + *col = append(*col, v) + } + return nil +} + +func (col *Int16) Encode(encoder *binary.Encoder) error { + for _, v := range *col { + if err := encoder.Int16(v); err != nil { + return err + } + } + return nil +} + +func (col *Int32) Decode(decoder *binary.Decoder, rows int) error { + for i := 0; i < rows; i++ { + v, err := decoder.Int32() + if err != nil { + return err + } + *col = append(*col, v) + } + return nil +} + +func (col *Int32) Encode(encoder *binary.Encoder) error { + for _, v := range *col { + if err := encoder.Int32(v); err != nil { + return err + } + } + return nil +} + +func (col *Int64) Decode(decoder *binary.Decoder, rows int) error { + for i := 0; i < rows; i++ { + v, err := decoder.Int64() + if err != nil { + return err + } + *col = append(*col, v) + } + return nil +} + +func (col *Int64) Encode(encoder *binary.Encoder) error { + for _, v := range *col { + if err := encoder.Int64(v); err != nil { + return err + } + } + return nil +} + +func (col *UInt8) Decode(decoder *binary.Decoder, rows int) error { + for i := 0; i < rows; i++ { + v, err := decoder.UInt8() + if err != nil { + return err + } + *col = append(*col, v) + } + return nil +} + +func (col *UInt8) Encode(encoder *binary.Encoder) error { + for _, v := range *col { + if err := encoder.UInt8(v); err != nil { + return err + } + } + return nil +} + +func (col *UInt16) Decode(decoder *binary.Decoder, rows int) error { + for i := 0; i < rows; i++ { + v, err := decoder.UInt16() + if err != nil { + return err + } + *col = append(*col, v) + } + return nil +} + +func (col *UInt16) Encode(encoder *binary.Encoder) error { + for _, v := range *col { + if err := encoder.UInt16(v); err != nil { + return err + } + } + return nil +} + +func (col *UInt32) Decode(decoder *binary.Decoder, rows int) error { + for i := 0; i < rows; i++ { + v, err := decoder.UInt32() + if err != nil { + return err + } + *col = append(*col, v) + } + return nil +} + +func (col *UInt32) Encode(encoder *binary.Encoder) error { + for _, v := range *col { + if err := encoder.UInt32(v); err != nil { + return err + } + } + return nil +} + +func (col *UInt64) Decode(decoder *binary.Decoder, rows int) error { + for i := 0; i < rows; i++ { + v, err := decoder.UInt64() + if err != nil { + return err + } + *col = append(*col, v) + } + return nil +} + +func (col *UInt64) Encode(encoder *binary.Encoder) error { + for _, v := range *col { + if err := encoder.UInt64(v); err != nil { + return err + } + } + return nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column_unsafe_gen.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column_unsafe_gen.go new file mode 100644 index 00000000..20ca4beb --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/column_unsafe_gen.go @@ -0,0 +1,410 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//go:build amd64 || arm64 +// +build amd64 arm64 + +// Code generated by make codegen DO NOT EDIT. +// source: lib/column/codegen/column_safe.tpl + +package column + +import ( + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "reflect" + "unsafe" +) + +func (col *Float32) Decode(decoder *binary.Decoder, rows int) error { + if rows == 0 { + return nil + } + const size = 32 / 8 + + *col = append(*col, make([]float32, rows)...) + + var dst []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + if err := decoder.Raw(dst); err != nil { + return err + } + return nil +} + +func (col *Float32) Encode(encoder *binary.Encoder) error { + if len(*col) == 0 { + return nil + } + const size = 32 / 8 + scratch := make([]byte, size*len(*col)) + { + var src []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&src)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + copy(scratch, src) + } + return encoder.Raw(scratch) +} + +func (col *Float64) Decode(decoder *binary.Decoder, rows int) error { + if rows == 0 { + return nil + } + const size = 64 / 8 + + *col = append(*col, make([]float64, rows)...) + + var dst []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + if err := decoder.Raw(dst); err != nil { + return err + } + return nil +} + +func (col *Float64) Encode(encoder *binary.Encoder) error { + if len(*col) == 0 { + return nil + } + const size = 64 / 8 + scratch := make([]byte, size*len(*col)) + { + var src []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&src)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + copy(scratch, src) + } + return encoder.Raw(scratch) +} + +func (col *Int8) Decode(decoder *binary.Decoder, rows int) error { + if rows == 0 { + return nil + } + const size = 8 / 8 + + *col = append(*col, make([]int8, rows)...) + + var dst []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + if err := decoder.Raw(dst); err != nil { + return err + } + return nil +} + +func (col *Int8) Encode(encoder *binary.Encoder) error { + if len(*col) == 0 { + return nil + } + const size = 8 / 8 + scratch := make([]byte, size*len(*col)) + { + var src []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&src)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + copy(scratch, src) + } + return encoder.Raw(scratch) +} + +func (col *Int16) Decode(decoder *binary.Decoder, rows int) error { + if rows == 0 { + return nil + } + const size = 16 / 8 + + *col = append(*col, make([]int16, rows)...) + + var dst []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + if err := decoder.Raw(dst); err != nil { + return err + } + return nil +} + +func (col *Int16) Encode(encoder *binary.Encoder) error { + if len(*col) == 0 { + return nil + } + const size = 16 / 8 + scratch := make([]byte, size*len(*col)) + { + var src []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&src)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + copy(scratch, src) + } + return encoder.Raw(scratch) +} + +func (col *Int32) Decode(decoder *binary.Decoder, rows int) error { + if rows == 0 { + return nil + } + const size = 32 / 8 + + *col = append(*col, make([]int32, rows)...) + + var dst []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + if err := decoder.Raw(dst); err != nil { + return err + } + return nil +} + +func (col *Int32) Encode(encoder *binary.Encoder) error { + if len(*col) == 0 { + return nil + } + const size = 32 / 8 + scratch := make([]byte, size*len(*col)) + { + var src []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&src)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + copy(scratch, src) + } + return encoder.Raw(scratch) +} + +func (col *Int64) Decode(decoder *binary.Decoder, rows int) error { + if rows == 0 { + return nil + } + const size = 64 / 8 + + *col = append(*col, make([]int64, rows)...) + + var dst []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + if err := decoder.Raw(dst); err != nil { + return err + } + return nil +} + +func (col *Int64) Encode(encoder *binary.Encoder) error { + if len(*col) == 0 { + return nil + } + const size = 64 / 8 + scratch := make([]byte, size*len(*col)) + { + var src []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&src)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + copy(scratch, src) + } + return encoder.Raw(scratch) +} + +func (col *UInt8) Decode(decoder *binary.Decoder, rows int) error { + if rows == 0 { + return nil + } + const size = 8 / 8 + + *col = append(*col, make([]uint8, rows)...) + + var dst []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + if err := decoder.Raw(dst); err != nil { + return err + } + return nil +} + +func (col *UInt8) Encode(encoder *binary.Encoder) error { + if len(*col) == 0 { + return nil + } + const size = 8 / 8 + scratch := make([]byte, size*len(*col)) + { + var src []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&src)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + copy(scratch, src) + } + return encoder.Raw(scratch) +} + +func (col *UInt16) Decode(decoder *binary.Decoder, rows int) error { + if rows == 0 { + return nil + } + const size = 16 / 8 + + *col = append(*col, make([]uint16, rows)...) + + var dst []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + if err := decoder.Raw(dst); err != nil { + return err + } + return nil +} + +func (col *UInt16) Encode(encoder *binary.Encoder) error { + if len(*col) == 0 { + return nil + } + const size = 16 / 8 + scratch := make([]byte, size*len(*col)) + { + var src []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&src)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + copy(scratch, src) + } + return encoder.Raw(scratch) +} + +func (col *UInt32) Decode(decoder *binary.Decoder, rows int) error { + if rows == 0 { + return nil + } + const size = 32 / 8 + + *col = append(*col, make([]uint32, rows)...) + + var dst []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + if err := decoder.Raw(dst); err != nil { + return err + } + return nil +} + +func (col *UInt32) Encode(encoder *binary.Encoder) error { + if len(*col) == 0 { + return nil + } + const size = 32 / 8 + scratch := make([]byte, size*len(*col)) + { + var src []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&src)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + copy(scratch, src) + } + return encoder.Raw(scratch) +} + +func (col *UInt64) Decode(decoder *binary.Decoder, rows int) error { + if rows == 0 { + return nil + } + const size = 64 / 8 + + *col = append(*col, make([]uint64, rows)...) + + var dst []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + if err := decoder.Raw(dst); err != nil { + return err + } + return nil +} + +func (col *UInt64) Encode(encoder *binary.Encoder) error { + if len(*col) == 0 { + return nil + } + const size = 64 / 8 + scratch := make([]byte, size*len(*col)) + { + var src []byte + slice := (*reflect.SliceHeader)(unsafe.Pointer(&src)) + slice.Data = (*reflect.SliceHeader)(unsafe.Pointer(col)).Data + slice.Len = len(*col) * size + slice.Cap = cap(*col) * size + + copy(scratch, src) + } + return encoder.Raw(scratch) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/date.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/date.go new file mode 100644 index 00000000..875f0189 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/date.go @@ -0,0 +1,147 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +var ( + minDate, _ = time.Parse("2006-01-02 15:04:05", "1970-01-01 00:00:00") + maxDate, _ = time.Parse("2006-01-02 15:04:05", "2106-01-01 00:00:00") +) + +type Date struct { + values Int16 +} + +func (dt *Date) Type() Type { + return "Date" +} + +func (col *Date) ScanType() reflect.Type { + return scanTypeTime +} + +func (dt *Date) Rows() int { + return len(dt.values) +} + +func (dt *Date) Row(i int, ptr bool) interface{} { + value := dt.row(i) + if ptr { + return &value + } + return value +} + +func (dt *Date) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *time.Time: + *d = dt.row(row) + case **time.Time: + *d = new(time.Time) + **d = dt.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Date", + } + } + return nil +} + +func (dt *Date) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []time.Time: + in := make([]int16, 0, len(v)) + for _, t := range v { + if err := dateOverflow(minDate, maxDate, t, "2006-01-02"); err != nil { + return nil, err + } + in = append(in, int16(t.Unix()/secInDay)) + } + dt.values, nulls = append(dt.values, in...), make([]uint8, len(v)) + case []*time.Time: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + if err := dateOverflow(minDate, maxDate, *v, "2006-01-02"); err != nil { + return nil, err + } + dt.values = append(dt.values, int16(v.Unix()/secInDay)) + default: + dt.values, nulls[i] = append(dt.values, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Date", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (dt *Date) AppendRow(v interface{}) error { + var date int16 + switch v := v.(type) { + case time.Time: + if err := dateOverflow(minDate, maxDate, v, "2006-01-02"); err != nil { + return err + } + date = int16(v.Unix() / secInDay) + case *time.Time: + if v != nil { + if err := dateOverflow(minDate, maxDate, *v, "2006-01-02"); err != nil { + return err + } + date = int16(v.Unix() / secInDay) + } + case nil: + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Date", + From: fmt.Sprintf("%T", v), + } + } + dt.values = append(dt.values, date) + return nil +} + +func (dt *Date) Decode(decoder *binary.Decoder, rows int) error { + return dt.values.Decode(decoder, rows) +} + +func (dt *Date) Encode(encoder *binary.Encoder) error { + return dt.values.Encode(encoder) +} + +func (dt *Date) row(i int) time.Time { + return time.Unix(int64(dt.values[i])*secInDay, 0).UTC() +} + +var _ Interface = (*Date)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/date32.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/date32.go new file mode 100644 index 00000000..37fa8002 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/date32.go @@ -0,0 +1,151 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +var ( + minDate32, _ = time.Parse("2006-01-02 15:04:05", "1925-01-01 00:00:00") + maxDate32, _ = time.Parse("2006-01-02 15:04:05", "2283-11-11 00:00:00") +) + +type Date32 struct { + values Int32 +} + +func (dt *Date32) Type() Type { + return "Date32" +} + +func (col *Date32) ScanType() reflect.Type { + return scanTypeTime +} + +func (dt *Date32) Rows() int { + return len(dt.values) +} + +func (dt *Date32) Row(i int, ptr bool) interface{} { + value := dt.row(i) + if ptr { + return &value + } + return value +} + +func (dt *Date32) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *time.Time: + *d = dt.row(row) + case **time.Time: + *d = new(time.Time) + **d = dt.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Date32", + } + } + return nil +} + +func (dt *Date32) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []time.Time: + in := make([]int32, 0, len(v)) + for _, t := range v { + if err := dateOverflow(minDate32, maxDate32, t, "2006-01-02"); err != nil { + return nil, err + } + in = append(in, timeToInt32(t)) + } + dt.values, nulls = append(dt.values, in...), make([]uint8, len(v)) + case []*time.Time: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + if err := dateOverflow(minDate32, maxDate32, *v, "2006-01-02"); err != nil { + return nil, err + } + dt.values = append(dt.values, timeToInt32(*v)) + default: + dt.values, nulls[i] = append(dt.values, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Date32", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (dt *Date32) AppendRow(v interface{}) error { + var date int32 + switch v := v.(type) { + case time.Time: + if err := dateOverflow(minDate32, maxDate32, v, "2006-01-02"); err != nil { + return err + } + date = timeToInt32(v) + case *time.Time: + if v != nil { + if err := dateOverflow(minDate32, maxDate32, *v, "2006-01-02"); err != nil { + return err + } + date = timeToInt32(*v) + } + case nil: + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Date32", + From: fmt.Sprintf("%T", v), + } + } + dt.values = append(dt.values, date) + return nil +} + +func (dt *Date32) Decode(decoder *binary.Decoder, rows int) error { + return dt.values.Decode(decoder, rows) +} + +func (dt *Date32) Encode(encoder *binary.Encoder) error { + return dt.values.Encode(encoder) +} + +func (dt *Date32) row(i int) time.Time { + return time.Unix((int64(dt.values[i]) * secInDay), 0).UTC() +} + +func timeToInt32(t time.Time) int32 { + return int32(t.Unix() / secInDay) +} + +var _ Interface = (*Date32)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/date_helpers.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/date_helpers.go new file mode 100644 index 00000000..2e6691ec --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/date_helpers.go @@ -0,0 +1,47 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "time" +) + +const secInDay = 24 * 60 * 60 + +func dateOverflow(min, max, v time.Time, format string) error { + if v.Before(min) || v.After(max) { + return &DateOverflowError{ + Min: min, + Max: max, + Value: v, + Format: format, + } + } + return nil +} + +type DateOverflowError struct { + Min, Max time.Time + Value time.Time + Format string +} + +func (e *DateOverflowError) Error() string { + return fmt.Sprintf("clickhouse: dateTime overflow. must be between %s and %s", e.Min.Format(e.Format), e.Max.Format(e.Format)) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/datetime.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/datetime.go new file mode 100644 index 00000000..b3f730c0 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/datetime.go @@ -0,0 +1,166 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + "strings" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "github.com/ClickHouse/clickhouse-go/v2/lib/timezone" +) + +var ( + minDateTime, _ = time.Parse("2006-01-02 15:04:05", "1970-01-01 00:00:00") + maxDateTime, _ = time.Parse("2006-01-02 15:04:05", "2105-12-31 23:59:59") +) + +type DateTime struct { + chType Type + values UInt32 + timezone *time.Location +} + +func (dt *DateTime) parse(t Type) (_ *DateTime, err error) { + if dt.chType = t; dt.chType == "DateTime" { + return dt, nil + } + var name = strings.TrimSuffix(strings.TrimPrefix(string(t), "DateTime('"), "')") + if dt.timezone, err = timezone.Load(name); err != nil { + return nil, err + } + return dt, nil +} + +func (dt *DateTime) Type() Type { + return dt.chType +} + +func (col *DateTime) ScanType() reflect.Type { + return scanTypeTime +} + +func (dt *DateTime) Rows() int { + return len(dt.values) +} + +func (dt *DateTime) Row(i int, ptr bool) interface{} { + value := dt.row(i) + if ptr { + return &value + } + return value +} + +func (dt *DateTime) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *time.Time: + *d = dt.row(row) + case **time.Time: + *d = new(time.Time) + **d = dt.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "DateTime", + } + } + return nil +} + +func (dt *DateTime) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []time.Time: + in := make([]uint32, 0, len(v)) + for _, t := range v { + if err := dateOverflow(minDateTime, maxDateTime, t, "2006-01-02 15:04:05"); err != nil { + return nil, err + } + in = append(in, uint32(t.Unix())) + } + dt.values, nulls = append(dt.values, in...), make([]uint8, len(v)) + case []*time.Time: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + if err := dateOverflow(minDateTime, maxDateTime, *v, "2006-01-02 15:04:05"); err != nil { + return nil, err + } + dt.values = append(dt.values, uint32(v.Unix())) + default: + dt.values, nulls[i] = append(dt.values, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "DateTime", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (dt *DateTime) AppendRow(v interface{}) error { + var datetime uint32 + switch v := v.(type) { + case time.Time: + if err := dateOverflow(minDateTime, maxDateTime, v, "2006-01-02 15:04:05"); err != nil { + return err + } + datetime = uint32(v.Unix()) + case *time.Time: + if v != nil { + if err := dateOverflow(minDateTime, maxDateTime, *v, "2006-01-02 15:04:05"); err != nil { + return err + } + datetime = uint32(v.Unix()) + } + case nil: + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "DateTime", + From: fmt.Sprintf("%T", v), + } + } + dt.values = append(dt.values, datetime) + return nil +} + +func (dt *DateTime) Decode(decoder *binary.Decoder, rows int) error { + return dt.values.Decode(decoder, rows) +} + +func (dt *DateTime) Encode(encoder *binary.Encoder) error { + return dt.values.Encode(encoder) +} + +func (dt *DateTime) row(i int) time.Time { + v := time.Unix(int64(dt.values[i]), 0) + if dt.timezone != nil { + v = v.In(dt.timezone) + } + return v +} + +var _ Interface = (*DateTime)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/datetime64.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/datetime64.go new file mode 100644 index 00000000..f8404f5d --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/datetime64.go @@ -0,0 +1,214 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "math" + "reflect" + "strconv" + "strings" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "github.com/ClickHouse/clickhouse-go/v2/lib/timezone" +) + +var ( + minDateTime64, _ = time.Parse("2006-01-02 15:04:05", "1925-01-01 00:00:00") + maxDateTime64, _ = time.Parse("2006-01-02 15:04:05", "2283-11-11 00:00:00") +) + +type DateTime64 struct { + chType Type + values Int64 + timezone *time.Location + precision int +} + +func (dt *DateTime64) parse(t Type) (_ Interface, err error) { + dt.chType = t + switch params := strings.Split(t.params(), ","); len(params) { + case 2: + if dt.precision, err = strconv.Atoi(params[0]); err != nil { + return nil, err + } + if dt.timezone, err = timezone.Load(params[1][2 : len(params[1])-1]); err != nil { + return nil, err + } + case 1: + if dt.precision, err = strconv.Atoi(params[0]); err != nil { + return nil, err + } + default: + return nil, &UnsupportedColumnTypeError{ + t: t, + } + } + return dt, nil +} + +func (dt *DateTime64) Type() Type { + return dt.chType +} + +func (col *DateTime64) ScanType() reflect.Type { + return scanTypeTime +} + +func (dt *DateTime64) Rows() int { + return len(dt.values) +} + +func (dt *DateTime64) Row(i int, ptr bool) interface{} { + value := dt.row(i) + if ptr { + return &value + } + return value +} + +func (dt *DateTime64) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *time.Time: + *d = dt.row(row) + case **time.Time: + *d = new(time.Time) + **d = dt.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Datetime64", + } + } + return nil +} + +func (dt *DateTime64) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []int64: + dt.values, nulls = append(dt.values, v...), make([]uint8, len(v)) + case []*int64: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + dt.values = append(dt.values, *v) + default: + dt.values, nulls[i] = append(dt.values, 0), 1 + } + } + case []time.Time: + in := make([]int64, 0, len(v)) + for _, t := range v { + if err := dateOverflow(minDateTime64, maxDateTime64, t, "2006-01-02 15:04:05"); err != nil { + return nil, err + } + in = append(in, dt.timeToInt64(t)) + } + dt.values, nulls = append(dt.values, in...), make([]uint8, len(v)) + case []*time.Time: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + if err := dateOverflow(minDateTime64, maxDateTime64, *v, "2006-01-02 15:04:05"); err != nil { + return nil, err + } + dt.values = append(dt.values, dt.timeToInt64(*v)) + default: + dt.values, nulls[i] = append(dt.values, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Datetime64", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (dt *DateTime64) AppendRow(v interface{}) error { + var datetime int64 + switch v := v.(type) { + case int64: + datetime = v + case *int64: + if v != nil { + datetime = *v + } + case time.Time: + if err := dateOverflow(minDateTime64, maxDateTime64, v, "2006-01-02 15:04:05"); err != nil { + return err + } + datetime = dt.timeToInt64(v) + case *time.Time: + if v != nil { + if err := dateOverflow(minDateTime64, maxDateTime64, *v, "2006-01-02 15:04:05"); err != nil { + return err + } + datetime = dt.timeToInt64(*v) + } + case nil: + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Datetime64", + From: fmt.Sprintf("%T", v), + } + } + dt.values = append(dt.values, datetime) + return nil +} + +func (dt *DateTime64) Decode(decoder *binary.Decoder, rows int) error { + return dt.values.Decode(decoder, rows) +} + +func (dt *DateTime64) Encode(encoder *binary.Encoder) error { + return dt.values.Encode(encoder) +} + +func (dt *DateTime64) row(i int) time.Time { + var nano int64 + if dt.precision < 19 { + nano = dt.values[i] * int64(math.Pow10(9-dt.precision)) + } + var ( + sec = nano / int64(10e8) + nsec = nano - sec*10e8 + time = time.Unix(sec, nsec) + ) + if dt.timezone != nil { + time = time.In(dt.timezone) + } + return time +} + +func (dt *DateTime64) timeToInt64(t time.Time) int64 { + var timestamp int64 + if !t.IsZero() { + timestamp = t.UnixNano() + } + return timestamp / int64(math.Pow10(9-dt.precision)) +} + +var _ Interface = (*DateTime64)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/decimal.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/decimal.go new file mode 100644 index 00000000..72dddd5f --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/decimal.go @@ -0,0 +1,249 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "errors" + "fmt" + "math/big" + "reflect" + "strconv" + "strings" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "github.com/shopspring/decimal" +) + +type Decimal struct { + chType Type + scale int + nobits int // its domain is {32, 64, 128, 256} + precision int + values []decimal.Decimal +} + +func (col *Decimal) parse(t Type) (_ *Decimal, err error) { + col.chType = t + params := strings.Split(t.params(), ",") + if len(params) != 2 { + return nil, fmt.Errorf("invalid Decimal format: '%s'", t) + } + params[0] = strings.TrimSpace(params[0]) + params[1] = strings.TrimSpace(params[1]) + + if col.precision, err = strconv.Atoi(params[0]); err != nil { + return nil, fmt.Errorf("'%s' is not Decimal type: %s", t, err) + } else if col.precision < 1 { + return nil, errors.New("wrong precision of Decimal type") + } + + if col.scale, err = strconv.Atoi(params[1]); err != nil { + return nil, fmt.Errorf("'%s' is not Decimal type: %s", t, err) + } else if col.scale < 0 || col.scale > col.precision { + return nil, errors.New("wrong scale of Decimal type") + } + switch { + case col.precision <= 9: + col.nobits = 32 + case col.precision <= 18: + col.nobits = 64 + case col.precision <= 38: + col.nobits = 128 + default: + col.nobits = 256 + } + return col, nil +} + +func (col *Decimal) Type() Type { + return col.chType +} + +func (col *Decimal) ScanType() reflect.Type { + return scanTypeDecimal +} + +func (col *Decimal) Rows() int { + return len(col.values) +} + +func (col *Decimal) Row(i int, ptr bool) interface{} { + value := col.values[i] + if ptr { + return &value + } + return value +} + +func (col *Decimal) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *decimal.Decimal: + *d = col.values[row] + case **decimal.Decimal: + *d = new(decimal.Decimal) + **d = col.values[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Decimal", + } + } + return nil +} + +func (col *Decimal) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []decimal.Decimal: + col.values, nulls = append(col.values, v...), make([]uint8, len(v)) + case []*decimal.Decimal: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + col.values = append(col.values, *v) + default: + col.values, nulls[i] = append(col.values, decimal.New(0, 0)), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: string(col.chType), + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *Decimal) AppendRow(v interface{}) error { + value := decimal.New(0, 0) + switch v := v.(type) { + case decimal.Decimal: + value = v + case *decimal.Decimal: + if v != nil { + value = *v + } + case nil: + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: string(col.chType), + From: fmt.Sprintf("%T", v), + } + } + col.values = append(col.values, value) + return nil +} + +func (col *Decimal) Decode(decoder *binary.Decoder, rows int) error { + switch col.nobits { + case 32: + var base UInt32 + if err := base.Decode(decoder, rows); err != nil { + return err + } + for _, v := range base { + col.values = append(col.values, decimal.New(int64(v), int32(-col.scale))) + } + case 64: + var base UInt64 + if err := base.Decode(decoder, rows); err != nil { + return err + } + for _, v := range base { + col.values = append(col.values, decimal.New(int64(v), int32(-col.scale))) + } + case 128, 256: + var ( + size = col.nobits / 8 + scratch = make([]byte, rows*size) + ) + if err := decoder.Raw(scratch); err != nil { + return err + } + for i := 0; i < rows; i++ { + col.values = append(col.values, decimal.NewFromBigInt( + rawToBigInt(scratch[i*size:(i+1)*size]), + int32(-col.scale), + )) + } + default: + return fmt.Errorf("unsupported %s", col.chType) + } + return nil +} + +func (col *Decimal) Encode(encoder *binary.Encoder) error { + switch col.nobits { + case 32: + var base UInt32 + for _, v := range col.values { + var part uint32 + switch { + case v.Exponent() != int32(col.scale): + part = uint32(decimal.NewFromBigInt(v.Coefficient(), v.Exponent()+int32(col.scale)).IntPart()) + default: + part = uint32(v.IntPart()) + } + base = append(base, part) + } + return base.Encode(encoder) + case 64: + var base UInt64 + for _, v := range col.values { + var part uint64 + switch { + case v.Exponent() != int32(col.scale): + part = uint64(decimal.NewFromBigInt(v.Coefficient(), v.Exponent()+int32(col.scale)).IntPart()) + default: + part = uint64(v.IntPart()) + } + base = append(base, part) + } + return base.Encode(encoder) + case 128, 256: + var ( + size = col.nobits / 8 + scratch = make([]byte, col.Rows()*size) + ) + for i, v := range col.values { + var bi *big.Int + switch { + case v.Exponent() != int32(col.scale): + bi = decimal.NewFromBigInt(v.Coefficient(), v.Exponent()+int32(col.scale)).BigInt() + default: + bi = v.BigInt() + } + bigIntToRaw(scratch[i*size:(i+1)*size], bi) + } + return encoder.Raw(scratch) + } + return fmt.Errorf("unsupported %s", col.chType) +} + +func (col *Decimal) Scale() int64 { + return int64(col.scale) +} + +func (col *Decimal) Precision() int64 { + return int64(col.precision) +} + +var _ Interface = (*Decimal)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/enum.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/enum.go new file mode 100644 index 00000000..cdca0955 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/enum.go @@ -0,0 +1,102 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "errors" + "math" + "strconv" + "strings" +) + +func Enum(chType Type) (Interface, error) { + var ( + payload string + columnType = string(chType) + ) + if len(columnType) < 8 { + return nil, &Error{ + ColumnType: string(chType), + Err: errors.New("invalid Enum"), + } + } + switch { + case strings.HasPrefix(columnType, "Enum8"): + payload = columnType[6:] + case strings.HasPrefix(columnType, "Enum16"): + payload = columnType[7:] + default: + return nil, &Error{ + ColumnType: string(chType), + Err: errors.New("invalid Enum"), + } + } + var ( + idents []string + indexes []int64 + ) + for _, block := range strings.Split(payload[:len(payload)-1], ",") { + parts := strings.Split(block, "=") + if len(parts) != 2 { + return nil, &Error{ + ColumnType: string(chType), + Err: errors.New("invalid Enum"), + } + } + var ( + ident = strings.TrimSpace(parts[0]) + index, err = strconv.ParseInt(strings.TrimSpace(parts[1]), 10, 16) + ) + if err != nil || len(ident) < 2 { + return nil, &Error{ + ColumnType: string(chType), + Err: errors.New("invalid Enum"), + } + } + ident = ident[1 : len(ident)-1] + idents, indexes = append(idents, ident), append(indexes, index) + } + if strings.HasPrefix(columnType, "Enum8") { + enum := Enum8{ + iv: make(map[string]uint8, len(idents)), + vi: make(map[uint8]string, len(idents)), + chType: chType, + } + for i := range idents { + if indexes[i] > math.MaxUint8 { + return nil, &Error{ + ColumnType: string(chType), + Err: errors.New("invalid Enum"), + } + } + enum.iv[idents[i]] = uint8(indexes[i]) + enum.vi[uint8(indexes[i])] = idents[i] + } + return &enum, nil + } + enum := Enum16{ + iv: make(map[string]uint16, len(idents)), + vi: make(map[uint16]string, len(idents)), + chType: chType, + } + for i := range idents { + enum.iv[idents[i]] = uint16(indexes[i]) + enum.vi[uint16(indexes[i])] = idents[i] + } + return &enum, nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/enum16.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/enum16.go new file mode 100644 index 00000000..687a3c1c --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/enum16.go @@ -0,0 +1,151 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type Enum16 struct { + iv map[string]uint16 + vi map[uint16]string + chType Type + values UInt16 +} + +func (e *Enum16) Type() Type { + return e.chType +} + +func (col *Enum16) ScanType() reflect.Type { + return scanTypeString +} + +func (e *Enum16) Rows() int { + return len(e.values) +} + +func (e *Enum16) Row(i int, ptr bool) interface{} { + value := e.vi[e.values[i]] + if ptr { + return &value + } + return value +} + +func (e *Enum16) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *string: + *d = e.vi[e.values[row]] + case **string: + *d = new(string) + **d = e.vi[e.values[row]] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Enum16", + } + } + return nil +} + +func (e *Enum16) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []string: + nulls = make([]uint8, len(v)) + for _, elem := range v { + v, ok := e.iv[elem] + if !ok { + return nil, &Error{ + Err: fmt.Errorf("unknown element %q", elem), + ColumnType: string(e.chType), + } + } + e.values = append(e.values, v) + } + case []*string: + nulls = make([]uint8, len(v)) + for i, elem := range v { + switch { + case elem != nil: + v, ok := e.iv[*elem] + if !ok { + return nil, &Error{ + Err: fmt.Errorf("unknown element %q", *elem), + ColumnType: string(e.chType), + } + } + e.values = append(e.values, v) + default: + e.values, nulls[i] = append(e.values, 0), 1 + } + } + } + return +} + +func (e *Enum16) AppendRow(elem interface{}) error { + switch elem := elem.(type) { + case string: + v, ok := e.iv[elem] + if !ok { + return &Error{ + Err: fmt.Errorf("unknown element %q", elem), + ColumnType: string(e.chType), + } + } + e.values = append(e.values, v) + case *string: + switch { + case elem != nil: + v, ok := e.iv[*elem] + if !ok { + return &Error{ + Err: fmt.Errorf("unknown element %q", *elem), + ColumnType: string(e.chType), + } + } + e.values = append(e.values, v) + default: + e.values = append(e.values, 0) + } + case nil: + e.values = append(e.values, 0) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Enum16", + From: fmt.Sprintf("%T", elem), + } + } + return nil +} + +func (e *Enum16) Decode(decoder *binary.Decoder, rows int) error { + return e.values.Decode(decoder, rows) +} + +func (e *Enum16) Encode(encoder *binary.Encoder) error { + return e.values.Encode(encoder) +} + +var _ Interface = (*Enum16)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/enum8.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/enum8.go new file mode 100644 index 00000000..bdbb4902 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/enum8.go @@ -0,0 +1,157 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type Enum8 struct { + iv map[string]uint8 + vi map[uint8]string + chType Type + values UInt8 +} + +func (e *Enum8) Type() Type { + return e.chType +} + +func (col *Enum8) ScanType() reflect.Type { + return scanTypeString +} + +func (e *Enum8) Rows() int { + return len(e.values) +} + +func (e *Enum8) Row(i int, ptr bool) interface{} { + value := e.vi[e.values[i]] + if ptr { + return &value + } + return value +} + +func (e *Enum8) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *string: + *d = e.vi[e.values[row]] + case **string: + *d = new(string) + **d = e.vi[e.values[row]] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Enum8", + } + } + return nil +} + +func (e *Enum8) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []string: + nulls = make([]uint8, len(v)) + for _, elem := range v { + v, ok := e.iv[elem] + if !ok { + return nil, &Error{ + Err: fmt.Errorf("unknown element %q", elem), + ColumnType: string(e.chType), + } + } + e.values = append(e.values, v) + } + case []*string: + nulls = make([]uint8, len(v)) + for i, elem := range v { + switch { + case elem != nil: + v, ok := e.iv[*elem] + if !ok { + return nil, &Error{ + Err: fmt.Errorf("unknown element %q", *elem), + ColumnType: string(e.chType), + } + } + e.values = append(e.values, v) + default: + e.values, nulls[i] = append(e.values, 0), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Enum8", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (e *Enum8) AppendRow(elem interface{}) error { + switch elem := elem.(type) { + case string: + v, ok := e.iv[elem] + if !ok { + return &Error{ + Err: fmt.Errorf("unknown element %q", elem), + ColumnType: string(e.chType), + } + } + e.values = append(e.values, v) + case *string: + switch { + case elem != nil: + v, ok := e.iv[*elem] + if !ok { + return &Error{ + Err: fmt.Errorf("unknown element %q", *elem), + ColumnType: string(e.chType), + } + } + e.values = append(e.values, v) + default: + e.values = append(e.values, 0) + } + case nil: + e.values = append(e.values, 0) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Enum8", + From: fmt.Sprintf("%T", elem), + } + } + return nil +} + +func (e *Enum8) Decode(decoder *binary.Decoder, rows int) error { + return e.values.Decode(decoder, rows) +} + +func (e *Enum8) Encode(encoder *binary.Encoder) error { + return e.values.Encode(encoder) +} + +var _ Interface = (*Enum8)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/fixed_string.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/fixed_string.go new file mode 100644 index 00000000..8e9b4c4e --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/fixed_string.go @@ -0,0 +1,178 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "encoding" + "fmt" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type FixedString struct { + data []byte + size int +} + +func (col *FixedString) parse(t Type) (*FixedString, error) { + if _, err := fmt.Sscanf(string(t), "FixedString(%d)", &col.size); err != nil { + return nil, err + } + return col, nil +} + +func (col *FixedString) Type() Type { + return Type(fmt.Sprintf("FixedString(%d)", col.size)) +} + +func (col *FixedString) ScanType() reflect.Type { + return scanTypeString +} + +func (col *FixedString) Rows() int { + if col.size == 0 { + return 0 + } + return len(col.data) / col.size +} + +func (col *FixedString) Row(i int, ptr bool) interface{} { + value := col.row(i) + if ptr { + return &value + } + return value +} + +func (col *FixedString) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *string: + *d = col.row(row) + case **string: + *d = new(string) + **d = col.row(row) + case encoding.BinaryUnmarshaler: + return d.UnmarshalBinary(col.rowBytes(row)) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "FixedString", + } + } + return nil +} + +func (col *FixedString) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []string: + for _, v := range v { + if v == "" { + col.data = append(col.data, make([]byte, col.size)...) + } else { + col.data = append(col.data, binary.Str2Bytes(v)...) + } + } + nulls = make([]uint8, len(v)) + case []*string: + nulls = make([]uint8, len(v)) + for i, v := range v { + if v == nil { + nulls[i] = 1 + } + switch { + case v == nil: + col.data = append(col.data, make([]byte, col.size)...) + default: + if *v == "" { + col.data = append(col.data, make([]byte, col.size)...) + } else { + col.data = append(col.data, binary.Str2Bytes(*v)...) + } + } + } + case encoding.BinaryMarshaler: + data, err := v.MarshalBinary() + if err != nil { + return nil, err + } + col.data, nulls = append(col.data, data...), make([]uint8, len(data)/col.size) + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "FixedString", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *FixedString) AppendRow(v interface{}) (err error) { + data := make([]byte, col.size) + switch v := v.(type) { + case string: + if v != "" { + data = binary.Str2Bytes(v) + } + case *string: + if v != nil { + if *v != "" { + data = binary.Str2Bytes(*v) + } + } + case nil: + case encoding.BinaryMarshaler: + if data, err = v.MarshalBinary(); err != nil { + return err + } + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "FixedString", + From: fmt.Sprintf("%T", v), + } + } + col.data = append(col.data, data...) + return nil +} + +func (col *FixedString) Decode(decoder *binary.Decoder, rows int) error { + col.data = make([]byte, col.size*rows) + return decoder.Raw(col.data) +} + +func (col *FixedString) Encode(encoder *binary.Encoder) error { + if len(col.data)%col.size != 0 { + return &Error{ + ColumnType: string(col.Type()), + Err: fmt.Errorf("invalid column size. must be a multiple of %d bytes got %d bytes", col.size, len(col.data)), + } + } + return encoder.Raw(col.data) +} + +func (col *FixedString) row(i int) string { + return string(col.data[i*col.size : (i+1)*col.size]) +} + +func (col *FixedString) rowBytes(i int) []byte { + return col.data[i*col.size : (i+1)*col.size] +} + +var _ Interface = (*FixedString)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_multi_polygon.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_multi_polygon.go new file mode 100644 index 00000000..5ac32808 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_multi_polygon.go @@ -0,0 +1,117 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "github.com/paulmach/orb" +) + +type MultiPolygon struct { + set *Array +} + +func (col *MultiPolygon) Type() Type { + return "MultiPolygon" +} + +func (col *MultiPolygon) ScanType() reflect.Type { + return scanTypeMultiPolygon +} + +func (col *MultiPolygon) Rows() int { + return col.set.Rows() +} + +func (col *MultiPolygon) Row(i int, ptr bool) interface{} { + value := col.row(i) + if ptr { + return &value + } + return value +} + +func (col *MultiPolygon) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *orb.MultiPolygon: + *d = col.row(row) + case **orb.MultiPolygon: + *d = new(orb.MultiPolygon) + **d = col.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "MultiPolygon", + Hint: fmt.Sprintf("try using *%s", col.ScanType()), + } + } + return nil +} + +func (col *MultiPolygon) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []orb.MultiPolygon: + values := make([][]orb.Polygon, 0, len(v)) + for _, v := range v { + values = append(values, v) + } + return col.set.Append(values) + + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "MultiPolygon", + From: fmt.Sprintf("%T", v), + } + } +} + +func (col *MultiPolygon) AppendRow(v interface{}) error { + switch v := v.(type) { + case orb.MultiPolygon: + return col.set.AppendRow([]orb.Polygon(v)) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "MultiPolygon", + From: fmt.Sprintf("%T", v), + } + } +} + +func (col *MultiPolygon) Decode(decoder *binary.Decoder, rows int) error { + return col.set.Decode(decoder, rows) +} + +func (col *MultiPolygon) Encode(encoder *binary.Encoder) error { + return col.set.Encode(encoder) +} + +func (col *MultiPolygon) row(i int) orb.MultiPolygon { + var value []orb.Polygon + { + col.set.ScanRow(&value, i) + } + return value +} + +var _ Interface = (*MultiPolygon)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_point.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_point.go new file mode 100644 index 00000000..54845442 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_point.go @@ -0,0 +1,127 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "github.com/paulmach/orb" +) + +type Point struct { + lon Float64 + lat Float64 +} + +func (col *Point) Type() Type { + return "Point" +} + +func (col *Point) ScanType() reflect.Type { + return scanTypePoint +} + +func (col *Point) Rows() int { + return col.lon.Rows() +} + +func (col *Point) Row(i int, ptr bool) interface{} { + value := col.row(i) + if ptr { + return &value + } + return value +} + +func (col *Point) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *orb.Point: + *d = col.row(row) + case **orb.Point: + *d = new(orb.Point) + **d = col.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Point", + Hint: fmt.Sprintf("try using *%s", col.ScanType()), + } + } + return nil +} + +func (col *Point) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []orb.Point: + nulls = make([]uint8, len(v)) + for _, v := range v { + col.lon = append(col.lon, v.Lon()) + col.lat = append(col.lat, v.Lat()) + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Point", + From: fmt.Sprintf("%T", v), + } + } + return +} +func (col *Point) AppendRow(v interface{}) error { + switch v := v.(type) { + case orb.Point: + col.lon = append(col.lon, v.Lon()) + col.lat = append(col.lat, v.Lat()) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Point", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *Point) Decode(decoder *binary.Decoder, rows int) error { + if err := col.lon.Decode(decoder, rows); err != nil { + return err + } + if err := col.lat.Decode(decoder, rows); err != nil { + return err + } + return nil +} + +func (col *Point) Encode(encoder *binary.Encoder) error { + if err := col.lon.Encode(encoder); err != nil { + return err + } + return col.lat.Encode(encoder) +} + +func (col *Point) row(i int) orb.Point { + return orb.Point{ + col.lon[i], + col.lat[i], + } +} + +var _ Interface = (*Point)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_polygon.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_polygon.go new file mode 100644 index 00000000..e5397b78 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_polygon.go @@ -0,0 +1,117 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "github.com/paulmach/orb" +) + +type Polygon struct { + set *Array +} + +func (col *Polygon) Type() Type { + return "Polygon" +} + +func (col *Polygon) ScanType() reflect.Type { + return scanTypePolygon +} + +func (col *Polygon) Rows() int { + return col.set.Rows() +} + +func (col *Polygon) Row(i int, ptr bool) interface{} { + value := col.row(i) + if ptr { + return &value + } + return value +} + +func (col *Polygon) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *orb.Polygon: + *d = col.row(row) + case **orb.Polygon: + *d = new(orb.Polygon) + **d = col.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Polygon", + Hint: fmt.Sprintf("try using *%s", col.ScanType()), + } + } + return nil +} + +func (col *Polygon) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []orb.Polygon: + values := make([][]orb.Ring, 0, len(v)) + for _, v := range v { + values = append(values, v) + } + return col.set.Append(values) + + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Polygon", + From: fmt.Sprintf("%T", v), + } + } +} + +func (col *Polygon) AppendRow(v interface{}) error { + switch v := v.(type) { + case orb.Polygon: + return col.set.AppendRow([]orb.Ring(v)) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Polygon", + From: fmt.Sprintf("%T", v), + } + } +} + +func (col *Polygon) Decode(decoder *binary.Decoder, rows int) error { + return col.set.Decode(decoder, rows) +} + +func (col *Polygon) Encode(encoder *binary.Encoder) error { + return col.set.Encode(encoder) +} + +func (col *Polygon) row(i int) orb.Polygon { + var value []orb.Ring + { + col.set.ScanRow(&value, i) + } + return value +} + +var _ Interface = (*Polygon)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_ring.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_ring.go new file mode 100644 index 00000000..8641ad37 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/geo_ring.go @@ -0,0 +1,117 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "github.com/paulmach/orb" +) + +type Ring struct { + set *Array +} + +func (col *Ring) Type() Type { + return "Ring" +} + +func (col *Ring) ScanType() reflect.Type { + return scanTypeRing +} + +func (col *Ring) Rows() int { + return col.set.Rows() +} + +func (col *Ring) Row(i int, ptr bool) interface{} { + value := col.row(i) + if ptr { + return &value + } + return value +} + +func (col *Ring) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *orb.Ring: + *d = col.row(row) + case **orb.Ring: + *d = new(orb.Ring) + **d = col.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Ring", + Hint: fmt.Sprintf("try using *%s", col.ScanType()), + } + } + return nil +} + +func (col *Ring) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []orb.Ring: + values := make([][]orb.Point, 0, len(v)) + for _, v := range v { + values = append(values, v) + } + return col.set.Append(values) + + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "Ring", + From: fmt.Sprintf("%T", v), + } + } +} + +func (col *Ring) AppendRow(v interface{}) error { + switch v := v.(type) { + case orb.Ring: + return col.set.AppendRow([]orb.Point(v)) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "Ring", + From: fmt.Sprintf("%T", v), + } + } +} + +func (col *Ring) Decode(decoder *binary.Decoder, rows int) error { + return col.set.Decode(decoder, rows) +} + +func (col *Ring) Encode(encoder *binary.Encoder) error { + return col.set.Encode(encoder) +} + +func (col *Ring) row(i int) orb.Ring { + var value []orb.Point + { + col.set.ScanRow(&value, i) + } + return value +} + +var _ Interface = (*Ring)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/interval.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/interval.go new file mode 100644 index 00000000..abd2be29 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/interval.go @@ -0,0 +1,100 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "errors" + "fmt" + "reflect" + "strings" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type Interval struct { + chType Type + values Int64 +} + +func (col *Interval) parse(t Type) (Interface, error) { + switch col.chType = t; col.chType { + case "IntervalSecond", "IntervalMinute", "IntervalHour", "IntervalDay", "IntervalWeek", "IntervalMonth", "IntervalYear": + return col, nil + } + return nil, &UnsupportedColumnTypeError{ + t: t, + } +} + +func (col *Interval) Type() Type { return col.chType } +func (col *Interval) ScanType() reflect.Type { return scanTypeString } +func (col *Interval) Rows() int { return len(col.values) } +func (col *Interval) Row(i int, ptr bool) interface{} { + return col.row(i) +} +func (col *Interval) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *string: + *d = col.row(row) + case **string: + *d = new(string) + **d = col.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "Interval", + } + } + return nil +} + +func (Interval) Append(interface{}) ([]uint8, error) { + return nil, &Error{ + ColumnType: "Interval", + Err: errors.New("data type values can't be stored in tables"), + } +} + +func (Interval) AppendRow(interface{}) error { + return &Error{ + ColumnType: "Interval", + Err: errors.New("data type values can't be stored in tables"), + } +} + +func (col *Interval) Decode(decoder *binary.Decoder, rows int) error { + return col.values.Decode(decoder, rows) +} + +func (Interval) Encode(*binary.Encoder) error { + return &Error{ + ColumnType: "Interval", + Err: errors.New("data type values can't be stored in tables"), + } +} + +func (col *Interval) row(i int) string { + v := fmt.Sprintf("%d %s", col.values[i], strings.TrimPrefix(string(col.chType), "Interval")) + if col.values[i] > 1 { + v += "s" + } + return v +} + +var _ Interface = (*Interval)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/ipv4.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/ipv4.go new file mode 100644 index 00000000..b785e3f4 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/ipv4.go @@ -0,0 +1,166 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "net" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type IPv4 struct { + data []byte +} + +func (col *IPv4) Type() Type { + return "IPv4" +} + +func (col *IPv4) ScanType() reflect.Type { + return scanTypeIP +} + +func (col *IPv4) Rows() int { + return len(col.data) / net.IPv4len +} + +func (col *IPv4) Row(i int, ptr bool) interface{} { + value := col.row(i) + if ptr { + return &value + } + return value +} + +func (col *IPv4) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *net.IP: + *d = col.row(row) + case **net.IP: + *d = new(net.IP) + **d = col.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "IPv4", + } + } + return nil +} + +func (col *IPv4) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []net.IP: + nulls = make([]uint8, len(v)) + for _, v := range v { + ip := v.To4() + if ip == nil { + return nil, &ColumnConverterError{ + Op: "Append", + To: "IPv4", + From: "IPv6", + Hint: "invalid IP version", + } + } + col.data = append(col.data, IPv4ToBytes(ip)...) + } + case []*net.IP: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + ip := v.To4() + if ip == nil { + return nil, &ColumnConverterError{ + Op: "Append", + To: "IPv4", + From: "IPv6", + Hint: "invalid IP version", + } + } + col.data = append(col.data, IPv4ToBytes(ip)...) + default: + col.data, nulls[i] = append(col.data, make([]byte, net.IPv4len)...), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "IPv4", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *IPv4) AppendRow(v interface{}) error { + var ip net.IP + switch v := v.(type) { + case net.IP: + ip = v + case *net.IP: + switch { + case v != nil: + ip = *v + default: + ip = make(net.IP, net.IPv4len) + } + case nil: + ip = make(net.IP, net.IPv4len) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "IPv4", + From: fmt.Sprintf("%T", v), + } + } + data := ip.To4() + if data == nil { + return &ColumnConverterError{ + Op: "AppendRow", + To: "IPv4", + From: "IPv6", + Hint: "invalid IP version", + } + } + col.data = append(col.data, IPv4ToBytes(data)...) + return nil +} + +func (col *IPv4) Decode(decoder *binary.Decoder, rows int) error { + col.data = make([]byte, net.IPv4len*rows) + return decoder.Raw(col.data) +} + +func (col *IPv4) Encode(encoder *binary.Encoder) error { + return encoder.Raw(col.data) +} + +func (col *IPv4) row(i int) net.IP { + src := col.data[i*net.IPv4len : (i+1)*net.IPv4len] + return net.IPv4(src[3], src[2], src[1], src[0]).To4() +} + +func IPv4ToBytes(ip net.IP) []byte { + return []byte{ip[3], ip[2], ip[1], ip[0]} +} + +var _ Interface = (*IPv4)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/ipv6.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/ipv6.go new file mode 100644 index 00000000..c1435cef --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/ipv6.go @@ -0,0 +1,153 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "net" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type IPv6 struct { + data []byte +} + +func (col *IPv6) Type() Type { + return "IPv6" +} + +func (col *IPv6) ScanType() reflect.Type { + return scanTypeIP +} + +func (col *IPv6) Rows() int { + return len(col.data) / net.IPv6len +} + +func (col *IPv6) Row(i int, ptr bool) interface{} { + value := col.row(i) + if ptr { + return &value + } + return value +} + +func (col *IPv6) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *net.IP: + *d = col.row(row) + case **net.IP: + *d = new(net.IP) + **d = col.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "IPv6", + } + } + return nil +} + +func (col *IPv6) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []net.IP: + nulls = make([]uint8, len(v)) + for _, v := range v { + if len(v) != net.IPv6len { + return nil, &Error{ + ColumnType: string(col.Type()), + Err: fmt.Errorf("invalid size. expected %d got %d", net.IPv6len, len(v)), + } + } + col.data = append(col.data, v[:]...) + } + case []*net.IP: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + if len(*v) != net.IPv6len { + return nil, &Error{ + ColumnType: string(col.Type()), + Err: fmt.Errorf("invalid size. expected %d got %d", net.IPv6len, len(*v)), + } + } + tmp := *v + col.data = append(col.data, tmp[:]...) + default: + col.data, nulls[i] = append(col.data, make([]byte, net.IPv6len)...), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "IPv6", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *IPv6) AppendRow(v interface{}) error { + var ip net.IP + switch v := v.(type) { + case net.IP: + ip = v + case *net.IP: + switch { + case v != nil: + ip = *v + default: + ip = make(net.IP, net.IPv6len) + } + case nil: + ip = make(net.IP, net.IPv6len) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "IPv6", + From: fmt.Sprintf("%T", v), + } + } + if len(ip) != net.IPv6len { + return &Error{ + ColumnType: string(col.Type()), + Err: fmt.Errorf("invalid size. expected %d got %d", net.IPv6len, len(ip)), + } + } + col.data = append(col.data, ip[:]...) + return nil +} + +func (col *IPv6) Decode(decoder *binary.Decoder, rows int) error { + col.data = make([]byte, net.IPv6len*rows) + return decoder.Raw(col.data) +} + +func (col *IPv6) Encode(encoder *binary.Encoder) error { + return encoder.Raw(col.data) +} + +func (col *IPv6) row(i int) net.IP { + return col.data[i*net.IPv6len : (i+1)*net.IPv6len] +} + +var _ Interface = (*IPv6)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/lowcardinality.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/lowcardinality.go new file mode 100644 index 00000000..f311bde4 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/lowcardinality.go @@ -0,0 +1,297 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "errors" + "fmt" + "math" + "reflect" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +const indexTypeMask = 0b11111111 + +const ( + keyUInt8 = 0 + keyUInt16 = 1 + keyUInt32 = 2 + keyUInt64 = 3 +) +const ( + /// Need to read dictionary if it wasn't. + needGlobalDictionaryBit = 1 << 8 + /// Need to read additional keys. Additional keys are stored before indexes as value N and N keys after them. + hasAdditionalKeysBit = 1 << 9 + /// Need to update dictionary. It means that previous granule has different dictionary. + needUpdateDictionary = 1 << 10 + + updateAll = hasAdditionalKeysBit | needUpdateDictionary +) + +const sharedDictionariesWithAdditionalKeys = 1 + +// https://github.com/ClickHouse/ClickHouse/blob/master/src/Columns/ColumnLowCardinality.cpp +// https://github.com/ClickHouse/clickhouse-cpp/blob/master/clickhouse/columns/lowcardinality.cpp +type LowCardinality struct { + key byte + rows int + index Interface + chType Type + nullable bool + + keys8 UInt8 + keys16 UInt16 + keys32 UInt32 + keys64 UInt64 + + append struct { + keys []int + index map[interface{}]int + } +} + +func (col *LowCardinality) parse(t Type) (_ *LowCardinality, err error) { + col.chType = t + col.append.index = make(map[interface{}]int) + if col.index, err = Type(t.params()).Column(); err != nil { + return nil, err + } + if nullable, ok := col.index.(*Nullable); ok { + col.nullable, nullable.enable = true, false + } + return col, nil +} + +func (col *LowCardinality) Type() Type { + return col.chType +} + +func (col *LowCardinality) ScanType() reflect.Type { + return col.index.ScanType() +} + +func (col *LowCardinality) Rows() int { + return col.rows +} + +func (col *LowCardinality) Row(i int, ptr bool) interface{} { + idx := col.indexRowNum(i) + if idx == 0 && col.nullable { + return nil + } + return col.index.Row(idx, ptr) +} + +func (col *LowCardinality) ScanRow(dest interface{}, row int) error { + idx := col.indexRowNum(row) + if idx == 0 && col.nullable { + return nil + } + return col.index.ScanRow(dest, idx) +} + +func (col *LowCardinality) Append(v interface{}) (nulls []uint8, err error) { + value := reflect.Indirect(reflect.ValueOf(v)) + if value.Kind() != reflect.Slice { + return nil, &ColumnConverterError{ + Op: "Append", + To: string(col.chType), + From: fmt.Sprintf("%T", v), + } + } + for i := 0; i < value.Len(); i++ { + if err := col.AppendRow(value.Index(i).Interface()); err != nil { + return nil, err + } + } + return +} + +func (col *LowCardinality) AppendRow(v interface{}) error { + col.rows++ + if col.index.Rows() == 0 { // init + if col.index.AppendRow(nil); col.nullable { + col.index.AppendRow(nil) + } + } + if v == nil { + col.append.keys = append(col.append.keys, 0) + return nil + } + switch x := v.(type) { + case time.Time: + v = x.Truncate(time.Second) + } + if _, found := col.append.index[v]; !found { + if err := col.index.AppendRow(v); err != nil { + return err + } + col.append.index[v] = col.index.Rows() - 1 + } + col.append.keys = append(col.append.keys, col.append.index[v]) + return nil +} + +func (col *LowCardinality) Decode(decoder *binary.Decoder, rows int) error { + if rows == 0 { + return nil + } + indexSerializationType, err := decoder.UInt64() + if err != nil { + return err + } + col.key = byte(indexSerializationType & indexTypeMask) + switch col.key { + case keyUInt8, keyUInt16, keyUInt32, keyUInt64: + default: + return &Error{ + ColumnType: "LowCardinality", + Err: errors.New("invalid index serialization version value"), + } + } + switch { + case indexSerializationType&needGlobalDictionaryBit == 1: + return &Error{ + ColumnType: "LowCardinality", + Err: errors.New("global dictionary is not supported"), + } + case indexSerializationType&hasAdditionalKeysBit == 0: + return &Error{ + ColumnType: "LowCardinality", + Err: errors.New("additional keys bit is missing"), + } + } + indexRows, err := decoder.Int64() + if err != nil { + return err + } + if err := col.index.Decode(decoder, int(indexRows)); err != nil { + return err + } + keysRows, err := decoder.Int64() + if err != nil { + return err + } + col.rows = int(keysRows) + return col.keys().Decode(decoder, col.rows) +} + +func (col *LowCardinality) Encode(encoder *binary.Encoder) error { + if col.rows == 0 { + return nil + } + defer func() { + col.append.keys, col.append.index = nil, nil + }() + switch { + case len(col.append.index) < math.MaxUint8: + col.key = keyUInt8 + for _, v := range col.append.keys { + if err := col.keys8.AppendRow(uint8(v)); err != nil { + return err + } + } + case len(col.append.index) < math.MaxUint16: + col.key = keyUInt16 + for _, v := range col.append.keys { + if err := col.keys16.AppendRow(uint16(v)); err != nil { + return err + } + } + case len(col.append.index) < math.MaxUint32: + col.key = keyUInt32 + for _, v := range col.append.keys { + if err := col.keys32.AppendRow(uint32(v)); err != nil { + return err + } + } + default: + col.key = keyUInt64 + for _, v := range col.append.keys { + if err := col.keys64.AppendRow(uint64(v)); err != nil { + return err + } + } + } + if err := encoder.UInt64(updateAll | uint64(col.key)); err != nil { + return err + } + if err := encoder.Int64(int64(col.index.Rows())); err != nil { + return err + } + if err := col.index.Encode(encoder); err != nil { + return err + } + keys := col.keys() + if err := encoder.Int64(int64(keys.Rows())); err != nil { + return err + } + return keys.Encode(encoder) +} + +func (col *LowCardinality) ReadStatePrefix(decoder *binary.Decoder) error { + keyVersion, err := decoder.UInt64() + if err != nil { + return err + } + if keyVersion != sharedDictionariesWithAdditionalKeys { + return &Error{ + ColumnType: "LowCardinality", + Err: errors.New("invalid key serialization version value"), + } + } + return nil +} + +func (col *LowCardinality) WriteStatePrefix(encoder *binary.Encoder) error { + return encoder.UInt64(sharedDictionariesWithAdditionalKeys) +} + +func (col *LowCardinality) keys() Interface { + switch col.key { + case keyUInt8: + return &col.keys8 + case keyUInt16: + return &col.keys16 + case keyUInt32: + return &col.keys32 + } + return &col.keys64 +} + +func (col *LowCardinality) indexRowNum(row int) int { + switch v := col.keys().Row(row, false).(type) { + case uint8: + return int(v) + case uint16: + return int(v) + case uint32: + return int(v) + case uint64: + return int(v) + } + return 0 +} + +var ( + _ Interface = (*LowCardinality)(nil) + _ CustomSerialization = (*LowCardinality)(nil) +) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/map.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/map.go new file mode 100644 index 00000000..89313e25 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/map.go @@ -0,0 +1,211 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + "strings" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +// https://github.com/ClickHouse/ClickHouse/blob/master/src/Columns/ColumnMap.cpp +type Map struct { + keys Interface + values Interface + chType Type + offsets Int64 + scanType reflect.Type +} + +func (col *Map) parse(t Type) (_ Interface, err error) { + col.chType = t + if types := strings.SplitN(t.params(), ",", 2); len(types) == 2 { + if col.keys, err = Type(strings.TrimSpace(types[0])).Column(); err != nil { + return nil, err + } + if col.values, err = Type(strings.TrimSpace(types[1])).Column(); err != nil { + return nil, err + } + col.scanType = reflect.MapOf( + col.keys.ScanType(), + col.values.ScanType(), + ) + return col, nil + } + return nil, &UnsupportedColumnTypeError{ + t: t, + } +} + +func (col *Map) Type() Type { + return col.chType +} + +func (col *Map) ScanType() reflect.Type { + return col.scanType +} + +func (col *Map) Rows() int { + return len(col.offsets) +} + +func (col *Map) Row(i int, ptr bool) interface{} { + return col.row(i).Interface() +} + +func (col *Map) ScanRow(dest interface{}, i int) error { + value := reflect.Indirect(reflect.ValueOf(dest)) + if value.Type() != col.scanType { + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: string(col.chType), + Hint: fmt.Sprintf("try using %s", col.scanType), + } + } + { + value.Set(col.row(i)) + } + return nil +} + +func (col *Map) Append(v interface{}) (nulls []uint8, err error) { + value := reflect.Indirect(reflect.ValueOf(v)) + if value.Kind() != reflect.Slice { + return nil, &ColumnConverterError{ + Op: "Append", + To: string(col.chType), + From: fmt.Sprintf("%T", v), + Hint: fmt.Sprintf("try using %s", col.scanType), + } + } + for i := 0; i < value.Len(); i++ { + if err := col.AppendRow(value.Index(i).Interface()); err != nil { + return nil, err + } + } + return +} + +func (col *Map) AppendRow(v interface{}) error { + value := reflect.Indirect(reflect.ValueOf(v)) + if value.Type() != col.scanType { + return &ColumnConverterError{ + Op: "AppendRow", + To: string(col.chType), + From: fmt.Sprintf("%T", v), + Hint: fmt.Sprintf("try using %s", col.scanType), + } + } + var ( + size int64 + iter = value.MapRange() + ) + for iter.Next() { + size++ + if err := col.keys.AppendRow(iter.Key().Interface()); err != nil { + return err + } + if err := col.values.AppendRow(iter.Value().Interface()); err != nil { + return err + } + } + var prev int64 + if n := len(col.offsets); n != 0 { + prev = col.offsets[n-1] + } + col.offsets = append(col.offsets, prev+size) + return nil +} + +func (col *Map) Decode(decoder *binary.Decoder, rows int) error { + if err := col.offsets.Decode(decoder, rows); err != nil { + return err + } + size := int(col.offsets[len(col.offsets)-1]) + if err := col.keys.Decode(decoder, size); err != nil { + return err + } + return col.values.Decode(decoder, size) +} + +func (col *Map) Encode(encoder *binary.Encoder) error { + if err := col.offsets.Encode(encoder); err != nil { + return err + } + if err := col.keys.Encode(encoder); err != nil { + return err + } + return col.values.Encode(encoder) +} + +func (col *Map) ReadStatePrefix(decoder *binary.Decoder) error { + if serialize, ok := col.keys.(CustomSerialization); ok { + if err := serialize.ReadStatePrefix(decoder); err != nil { + return err + } + } + if serialize, ok := col.values.(CustomSerialization); ok { + if err := serialize.ReadStatePrefix(decoder); err != nil { + return err + } + } + return nil +} + +func (col *Map) WriteStatePrefix(encoder *binary.Encoder) error { + if serialize, ok := col.keys.(CustomSerialization); ok { + if err := serialize.WriteStatePrefix(encoder); err != nil { + return err + } + } + if serialize, ok := col.values.(CustomSerialization); ok { + if err := serialize.WriteStatePrefix(encoder); err != nil { + return err + } + } + return nil +} + +func (col *Map) row(n int) reflect.Value { + var ( + prev int64 + value = reflect.MakeMap(col.scanType) + ) + if n != 0 { + prev = col.offsets[n-1] + } + var ( + size = int(col.offsets[n] - prev) + from = int(prev) + ) + for next := 0; next < size; next++ { + value.SetMapIndex( + reflect.ValueOf(col.keys.Row(from+next, false)), + reflect.ValueOf(col.values.Row(from+next, false)), + ) + } + return value +} + +var ( + _ Interface = (*Map)(nil) + _ CustomSerialization = (*Map)(nil) +) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/nested.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/nested.go new file mode 100644 index 00000000..c6efef80 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/nested.go @@ -0,0 +1,67 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "strings" +) + +type Nested struct { + Interface +} + +func (col *Nested) parse(t Type) (_ Interface, err error) { + columns := fmt.Sprintf("Array(Tuple(%s))", strings.Join(nestedColumns(t.params()), ", ")) + if col.Interface, err = (&Array{}).parse(Type(columns)); err != nil { + return nil, err + } + return col, nil +} + +func nestedColumns(raw string) (columns []string) { + var ( + begin int + brackets int + ) + for i, r := range raw + "," { + switch r { + case '(': + brackets++ + case ')': + brackets-- + case ' ': + if brackets == 0 { + begin = i + 1 + } + case ',': + if brackets == 0 { + columns, begin = append(columns, raw[begin:i]), i+1 + continue + } + } + } + for i, column := range columns { + if strings.HasPrefix(column, "Nested(") { + columns[i] = fmt.Sprintf("Array(Tuple(%s))", strings.Join(nestedColumns(Type(column).params()), ", ")) + } + } + return +} + +var _ Interface = (*Nested)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/nothing.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/nothing.go new file mode 100644 index 00000000..c13ce3c6 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/nothing.go @@ -0,0 +1,60 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "errors" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type Nothing struct{} + +func (Nothing) Type() Type { return "Nothing" } +func (Nothing) ScanType() reflect.Type { return reflect.TypeOf(nil) } +func (Nothing) Rows() int { return 0 } +func (Nothing) Row(int, bool) interface{} { return nil } +func (Nothing) ScanRow(interface{}, int) error { return nil } +func (Nothing) Append(interface{}) ([]uint8, error) { + return nil, &Error{ + ColumnType: "Nothing", + Err: errors.New("data type values can't be stored in tables"), + } +} +func (Nothing) AppendRow(interface{}) error { + return &Error{ + ColumnType: "Nothing", + Err: errors.New("data type values can't be stored in tables"), + } +} +func (Nothing) Decode(decoder *binary.Decoder, rows int) error { + scratch := make([]byte, rows) + if err := decoder.Raw(scratch); err != nil { + return err + } + return nil +} +func (Nothing) Encode(*binary.Encoder) error { + return &Error{ + ColumnType: "Nothing", + Err: errors.New("data type values can't be stored in tables"), + } +} + +var _ Interface = (*Nothing)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/nullable.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/nullable.go new file mode 100644 index 00000000..80c5ab37 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/nullable.go @@ -0,0 +1,128 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type Nullable struct { + base Interface + nulls UInt8 + enable bool + scanType reflect.Type +} + +func (col *Nullable) parse(t Type) (_ *Nullable, err error) { + col.enable = true + if col.base, err = Type(t.params()).Column(); err != nil { + return nil, err + } + switch base := col.base.ScanType(); { + case base == nil: + col.scanType = reflect.TypeOf(nil) + case base.Kind() == reflect.Ptr: + col.scanType = base + default: + col.scanType = reflect.New(base).Type() + } + return col, nil +} + +func (col *Nullable) Base() Interface { + return col.base +} + +func (col *Nullable) Type() Type { + return "Nullable(" + col.base.Type() + ")" +} + +func (col *Nullable) ScanType() reflect.Type { + return col.scanType +} + +func (col *Nullable) Rows() int { + if !col.enable { + return col.base.Rows() + } + return len(col.nulls) +} + +func (col *Nullable) Row(i int, ptr bool) interface{} { + if col.enable { + if col.nulls[i] == 1 { + return nil + } + } + return col.base.Row(i, true) +} + +func (col *Nullable) ScanRow(dest interface{}, row int) error { + if col.enable { + if col.nulls[row] == 1 { + return nil + } + } + return col.base.ScanRow(dest, row) +} + +func (col *Nullable) Append(v interface{}) ([]uint8, error) { + nulls, err := col.base.Append(v) + if err != nil { + return nil, err + } + col.nulls = append(col.nulls, nulls...) + return nulls, nil +} + +func (col *Nullable) AppendRow(v interface{}) error { + if v == nil || (reflect.ValueOf(v).Kind() == reflect.Ptr && reflect.ValueOf(v).IsNil()) { + col.nulls = append(col.nulls, 1) + } else { + col.nulls = append(col.nulls, 0) + } + return col.base.AppendRow(v) +} + +func (col *Nullable) Decode(decoder *binary.Decoder, rows int) (err error) { + if col.enable { + if err := col.nulls.Decode(decoder, rows); err != nil { + return err + } + } + if err := col.base.Decode(decoder, rows); err != nil { + return err + } + return nil +} + +func (col *Nullable) Encode(encoder *binary.Encoder) error { + if col.enable { + if err := col.nulls.Encode(encoder); err != nil { + return err + } + } + if err := col.base.Encode(encoder); err != nil { + return err + } + return nil +} + +var _ Interface = (*Nullable)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/simple_aggregate_function.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/simple_aggregate_function.go new file mode 100644 index 00000000..d0858e29 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/simple_aggregate_function.go @@ -0,0 +1,71 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "reflect" + "strings" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type SimpleAggregateFunction struct { + base Interface + chType Type +} + +func (col *SimpleAggregateFunction) parse(t Type) (_ Interface, err error) { + col.chType = t + base := strings.TrimSpace(strings.SplitN(t.params(), ",", 2)[1]) + if col.base, err = Type(base).Column(); err == nil { + return col, nil + } + return nil, &UnsupportedColumnTypeError{ + t: t, + } +} + +func (col *SimpleAggregateFunction) Type() Type { + return col.chType +} +func (col *SimpleAggregateFunction) ScanType() reflect.Type { + return col.base.ScanType() +} +func (col *SimpleAggregateFunction) Rows() int { + return col.base.Rows() +} +func (col *SimpleAggregateFunction) Row(i int, ptr bool) interface{} { + return col.base.Row(i, ptr) +} +func (col *SimpleAggregateFunction) ScanRow(dest interface{}, rows int) error { + return col.base.ScanRow(dest, rows) +} +func (col *SimpleAggregateFunction) Append(v interface{}) ([]uint8, error) { + return col.base.Append(v) +} +func (col *SimpleAggregateFunction) AppendRow(v interface{}) error { + return col.base.AppendRow(v) +} +func (col *SimpleAggregateFunction) Decode(decoder *binary.Decoder, rows int) error { + return col.base.Decode(decoder, rows) +} +func (col *SimpleAggregateFunction) Encode(encoder *binary.Encoder) error { + return col.base.Encode(encoder) +} + +var _ Interface = (*SimpleAggregateFunction)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/string.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/string.go new file mode 100644 index 00000000..f66c5f4e --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/string.go @@ -0,0 +1,134 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type String []string + +func (String) Type() Type { + return "String" +} + +func (String) ScanType() reflect.Type { + return scanTypeString +} + +func (col *String) Rows() int { + return len(*col) +} + +func (col *String) Row(i int, ptr bool) interface{} { + value := *col + if ptr { + return &value[i] + } + return value[i] +} + +func (col *String) ScanRow(dest interface{}, row int) error { + v := *col + switch d := dest.(type) { + case *string: + *d = v[row] + case **string: + *d = new(string) + **d = v[row] + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "String", + } + } + return nil +} + +func (col *String) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []string: + *col, nulls = append(*col, v...), make([]uint8, len(v)) + case []*string: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + *col = append(*col, *v) + default: + *col, nulls[i] = append(*col, ""), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "String", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *String) AppendRow(v interface{}) error { + switch v := v.(type) { + case string: + *col = append(*col, v) + case *string: + switch { + case v != nil: + *col = append(*col, *v) + default: + *col = append(*col, "") + } + case nil: + *col = append(*col, "") + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "String", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *String) Decode(decoder *binary.Decoder, rows int) error { + for i := 0; i < int(rows); i++ { + v, err := decoder.String() + if err != nil { + return err + } + *col = append(*col, v) + } + return nil +} + +func (col *String) Encode(encoder *binary.Encoder) error { + for _, v := range *col { + if err := encoder.String(v); err != nil { + return err + } + } + return nil +} + +var _ Interface = (*String)(nil) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/tuple.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/tuple.go new file mode 100644 index 00000000..89b48441 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/tuple.go @@ -0,0 +1,206 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + "strings" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type Tuple struct { + chType Type + columns []Interface +} + +func (col *Tuple) parse(t Type) (_ Interface, err error) { + col.chType = t + var ( + element []rune + elements []string + brackets int + appendElement = func() { + if len(element) != 0 { + name := strings.TrimSpace(string(element)) + if parts := strings.SplitN(name, " ", 2); len(parts) == 2 { + if !strings.Contains(parts[0], "(") { + name = parts[1] + } + } + elements = append(elements, name) + } + } + ) + for _, r := range t.params() { + switch r { + case '(': + brackets++ + case ')': + brackets-- + case ',': + if brackets == 0 { + appendElement() + element = element[:0] + continue + } + } + element = append(element, r) + } + appendElement() + for _, ct := range elements { + column, err := Type(strings.TrimSpace(ct)).Column() + if err != nil { + return nil, err + } + col.columns = append(col.columns, column) + } + if len(col.columns) != 0 { + return col, nil + } + return nil, &UnsupportedColumnTypeError{ + t: t, + } +} + +func (col *Tuple) Type() Type { + return col.chType +} + +func (Tuple) ScanType() reflect.Type { + return scanTypeSlice +} + +func (col *Tuple) Rows() int { + if len(col.columns) != 0 { + return col.columns[0].Rows() + } + return 0 +} + +func (col *Tuple) Row(i int, ptr bool) interface{} { + tuple := make([]interface{}, 0, len(col.columns)) + for _, c := range col.columns { + tuple = append(tuple, c.Row(i, ptr)) + } + return tuple +} + +func (col *Tuple) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *[]interface{}: + tuple := make([]interface{}, 0, len(col.columns)) + for _, c := range col.columns { + tuple = append(tuple, c.Row(row, false)) + } + *d = tuple + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: string(col.chType), + } + } + return nil +} + +func (col *Tuple) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case [][]interface{}: + for _, v := range v { + if err := col.AppendRow(v); err != nil { + return nil, err + } + } + return nil, nil + } + return nil, &ColumnConverterError{ + Op: "Append", + To: string(col.chType), + From: fmt.Sprintf("%T", v), + } +} + +func (col *Tuple) AppendRow(v interface{}) error { + switch v := v.(type) { + case []interface{}: + if len(v) != len(col.columns) { + return &Error{ + ColumnType: string(col.chType), + Err: fmt.Errorf("invalid size. expected %d got %d", len(col.columns), len(v)), + } + } + for i, v := range v { + if err := col.columns[i].AppendRow(v); err != nil { + return err + } + } + return nil + } + return &ColumnConverterError{ + Op: "AppendRow", + To: string(col.chType), + From: fmt.Sprintf("%T", v), + } +} + +func (col *Tuple) Decode(decoder *binary.Decoder, rows int) error { + for _, c := range col.columns { + if err := c.Decode(decoder, rows); err != nil { + return err + } + } + return nil +} + +func (col *Tuple) Encode(encoder *binary.Encoder) error { + for _, c := range col.columns { + if err := c.Encode(encoder); err != nil { + return err + } + } + return nil +} + +func (col *Tuple) ReadStatePrefix(decoder *binary.Decoder) error { + for _, c := range col.columns { + if serialize, ok := c.(CustomSerialization); ok { + if err := serialize.ReadStatePrefix(decoder); err != nil { + return err + } + } + } + return nil +} + +func (col *Tuple) WriteStatePrefix(encoder *binary.Encoder) error { + for _, c := range col.columns { + if serialize, ok := c.(CustomSerialization); ok { + if err := serialize.WriteStatePrefix(encoder); err != nil { + return err + } + } + } + return nil +} + +var ( + _ Interface = (*Tuple)(nil) + _ CustomSerialization = (*Tuple)(nil) +) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/uuid.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/uuid.go new file mode 100644 index 00000000..edc3b5c3 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/column/uuid.go @@ -0,0 +1,152 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package column + +import ( + "fmt" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "github.com/google/uuid" +) + +const uuidSize = 16 + +type UUID struct { + data []byte +} + +func (col *UUID) Type() Type { + return "UUID" +} + +func (col *UUID) ScanType() reflect.Type { + return scanTypeUUID +} + +func (col *UUID) Rows() int { + return len(col.data) / uuidSize +} + +func (col *UUID) Row(i int, ptr bool) interface{} { + value := col.row(i) + if ptr { + return &value + } + return value +} + +func (col *UUID) ScanRow(dest interface{}, row int) error { + switch d := dest.(type) { + case *uuid.UUID: + *d = col.row(row) + case **uuid.UUID: + *d = new(uuid.UUID) + **d = col.row(row) + default: + return &ColumnConverterError{ + Op: "ScanRow", + To: fmt.Sprintf("%T", dest), + From: "UUID", + Hint: fmt.Sprintf("try using *%s", col.ScanType()), + } + } + return nil +} + +func (col *UUID) Append(v interface{}) (nulls []uint8, err error) { + switch v := v.(type) { + case []uuid.UUID: + nulls = make([]uint8, len(v)) + for _, v := range v { + col.data = append(col.data, swap(v[:])...) + } + case []*uuid.UUID: + nulls = make([]uint8, len(v)) + for i, v := range v { + switch { + case v != nil: + tmp := *v + col.data = append(col.data, swap(tmp[:])...) + default: + col.data, nulls[i] = append(col.data, make([]byte, uuidSize)...), 1 + } + } + default: + return nil, &ColumnConverterError{ + Op: "Append", + To: "UUID", + From: fmt.Sprintf("%T", v), + } + } + return +} + +func (col *UUID) AppendRow(v interface{}) error { + switch v := v.(type) { + case uuid.UUID: + col.data = append(col.data, swap(v[:])...) + case *uuid.UUID: + switch { + case v != nil: + tmp := *v + col.data = append(col.data, swap(tmp[:])...) + default: + col.data = append(col.data, make([]byte, uuidSize)...) + } + case nil: + col.data = append(col.data, make([]byte, uuidSize)...) + default: + return &ColumnConverterError{ + Op: "AppendRow", + To: "UUID", + From: fmt.Sprintf("%T", v), + } + } + return nil +} + +func (col *UUID) Decode(decoder *binary.Decoder, rows int) error { + col.data = make([]byte, uuidSize*rows) + return decoder.Raw(col.data) +} + +func (col *UUID) Encode(encoder *binary.Encoder) error { + return encoder.Raw(col.data) +} + +func (col *UUID) row(i int) (uuid uuid.UUID) { + copy(uuid[:], col.data[i*uuidSize:(i+1)*uuidSize]) + swap(uuid[:]) + return +} + +var _ Interface = (*UUID)(nil) + +func swap(src []byte) []byte { + _ = src[15] + src[0], src[7] = src[7], src[0] + src[1], src[6] = src[6], src[1] + src[2], src[5] = src[5], src[2] + src[3], src[4] = src[4], src[3] + src[8], src[15] = src[15], src[8] + src[9], src[14] = src[14], src[9] + src[10], src[13] = src[13], src[10] + src[11], src[12] = src[12], src[11] + return src +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/compress/compress.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/compress/compress.go new file mode 100644 index 00000000..cfa16980 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/compress/compress.go @@ -0,0 +1,41 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package compress + +import ( + "encoding/binary" +) + +var endian = binary.LittleEndian + +type Method byte + +const ( + NONE Method = 0x02 + LZ4 = 0x82 + ZSTD = 0x90 +) + +const ( + // ChecksumSize is 128bits for cityhash102 checksum + checksumSize = 16 + // CompressHeader magic + compressed_size + uncompressed_size + compressHeaderSize = 1 + 4 + 4 + headerSize = checksumSize + compressHeaderSize + maxBlockSize = 1 << 20 +) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/compress/compress_reader.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/compress/compress_reader.go new file mode 100644 index 00000000..68be5c54 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/compress/compress_reader.go @@ -0,0 +1,111 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package compress + +import ( + "fmt" + "io" + + "github.com/pierrec/lz4/v4" +) + +func NewReader(r io.Reader) *Reader { + return &Reader{ + r: r, + pos: maxBlockSize, + data: make([]byte, maxBlockSize), + zdata: make([]byte, lz4.CompressBlockBound(maxBlockSize)+headerSize), + header: make([]byte, headerSize), + } +} + +type Reader struct { + r io.Reader + pos int + data []byte + zdata []byte + header []byte +} + +func (r *Reader) Read(p []byte) (int, error) { + bytesRead, n := 0, len(p) + if r.pos < len(r.data) { + copyedSize := copy(p, r.data[r.pos:]) + { + bytesRead += copyedSize + r.pos += copyedSize + } + } + for bytesRead < n { + if err := r.readBlock(); err != nil { + return bytesRead, err + } + copyedSize := copy(p[bytesRead:], r.data) + { + bytesRead += copyedSize + r.pos = copyedSize + } + } + return n, nil +} + +func (r *Reader) readBlock() (err error) { + r.pos = 0 + var n int + if n, err = io.ReadFull(r.r, r.header); err != nil { + return + } + if n != len(r.header) { + return fmt.Errorf("LZ4 decompression header EOF") + } + var ( + compressedSize = int(endian.Uint32(r.header[17:])) - 9 + decompressedSize = int(endian.Uint32(r.header[21:])) + ) + if compressedSize > cap(r.zdata) { + r.zdata = make([]byte, compressedSize) + } + if decompressedSize > cap(r.data) { + r.data = make([]byte, decompressedSize) + } + + r.data, r.zdata = r.data[:decompressedSize], r.zdata[:compressedSize] + + switch r.header[16] { + case LZ4: + default: + return fmt.Errorf("unknown compression method: 0x%02x ", r.header[16]) + } + // @TODO checksum + if n, err = io.ReadFull(r.r, r.zdata); err != nil { + return + } + if n != len(r.zdata) { + return fmt.Errorf("decompress read size not match") + } + if _, err = lz4.UncompressBlock(r.zdata, r.data); err != nil { + return + } + return nil +} + +func (r *Reader) Close() error { + r.data = nil + r.zdata = nil + return nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/compress/compress_writer.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/compress/compress_writer.go new file mode 100644 index 00000000..1fb9f7c1 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/compress/compress_writer.go @@ -0,0 +1,91 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package compress + +import ( + "io" + + "github.com/ClickHouse/clickhouse-go/v2/lib/cityhash102" + "github.com/pierrec/lz4/v4" +) + +func NewWriter(wr io.Writer) *Writer { + return &Writer{ + wr: wr, + data: make([]byte, maxBlockSize), + zdata: make([]byte, lz4.CompressBlockBound(maxBlockSize)+headerSize), + } +} + +type Writer struct { + wr io.Writer + pos int + data []byte + zdata []byte + compressor lz4.Compressor +} + +func (w *Writer) Write(p []byte) (n int, err error) { + for len(p) > 0 { + m := copy(w.data[w.pos:], p) + w.pos += m + p = p[m:] + if w.pos == len(w.data) { + if err = w.Flush(); err != nil { + return n, err + } + } + n += m + } + return n, nil +} + +func (w *Writer) Flush() (err error) { + if w.pos == 0 { + return + } + compressedSize, err := w.compressor.CompressBlock(w.data[:w.pos], w.zdata[headerSize:]) + if err != nil { + return err + } + compressedSize += compressHeaderSize + // fill the header, compressed_size_32 + uncompressed_size_32 + w.zdata[16] = LZ4 + endian.PutUint32(w.zdata[17:], uint32(compressedSize)) + endian.PutUint32(w.zdata[21:], uint32(w.pos)) + // fill the checksum + checkSum := cityhash102.CityHash128(w.zdata[16:], uint32(compressedSize)) + { + endian.PutUint64(w.zdata[0:], checkSum.Lower64()) + endian.PutUint64(w.zdata[8:], checkSum.Higher64()) + } + if _, err := w.wr.Write(w.zdata[:compressedSize+checksumSize]); err != nil { + return err + } + /*if w, ok := cw.writer.(WriteFlusher); ok { + err = w.Flush() + }*/ + w.pos = 0 + return +} + +func (w *Writer) Close() error { + w.data = nil + w.zdata = nil + return nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/driver/driver.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/driver/driver.go new file mode 100644 index 00000000..629512b4 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/driver/driver.go @@ -0,0 +1,87 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package driver + +import ( + "context" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +type ServerVersion = proto.ServerHandshake + +type ( + NamedValue struct { + Name string + Value interface{} + } + Stats struct { + MaxOpenConns int + MaxIdleConns int + Open int + Idle int + } +) + +type ( + Conn interface { + Contributors() []string + ServerVersion() (*ServerVersion, error) + Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error + Query(ctx context.Context, query string, args ...interface{}) (Rows, error) + QueryRow(ctx context.Context, query string, args ...interface{}) Row + PrepareBatch(ctx context.Context, query string) (Batch, error) + Exec(ctx context.Context, query string, args ...interface{}) error + AsyncInsert(ctx context.Context, query string, wait bool) error + Ping(context.Context) error + Stats() Stats + Close() error + } + Row interface { + Err() error + Scan(dest ...interface{}) error + ScanStruct(dest interface{}) error + } + Rows interface { + Next() bool + Scan(dest ...interface{}) error + ScanStruct(dest interface{}) error + ColumnTypes() []ColumnType + Totals(dest ...interface{}) error + Columns() []string + Close() error + Err() error + } + Batch interface { + Abort() error + Append(v ...interface{}) error + AppendStruct(v interface{}) error + Column(int) BatchColumn + Send() error + } + BatchColumn interface { + Append(interface{}) error + } + ColumnType interface { + Name() string + Nullable() bool + ScanType() reflect.Type + DatabaseTypeName() string + } +) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/io/stream.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/io/stream.go new file mode 100644 index 00000000..ead3ce2c --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/io/stream.go @@ -0,0 +1,82 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package io + +import ( + "bufio" + "io" + + "github.com/ClickHouse/clickhouse-go/v2/lib/compress" +) + +const ( + maxReaderSize = 1 << 20 + maxWriterSize = 1 << 20 +) + +func NewStream(rw io.ReadWriter) *Stream { + stream := Stream{ + r: bufio.NewReaderSize(rw, maxReaderSize), + w: bufio.NewWriterSize(rw, maxWriterSize), + } + stream.compress.r = compress.NewReader(stream.r) + stream.compress.w = compress.NewWriter(stream.w) + return &stream +} + +type Stream struct { + r *bufio.Reader + w *bufio.Writer + compress struct { + enable bool + r *compress.Reader + w *compress.Writer + } +} + +func (s *Stream) Compress(v bool) { + s.compress.enable = v +} + +func (s *Stream) Read(p []byte) (int, error) { + if s.compress.enable { + return io.ReadFull(s.compress.r, p) + } + return io.ReadFull(s.r, p) +} + +func (s *Stream) Write(p []byte) (int, error) { + if s.compress.enable { + return s.compress.w.Write(p) + } + return s.w.Write(p) +} + +func (s *Stream) Flush() error { + if err := s.compress.w.Flush(); err != nil { + return err + } + return s.w.Flush() +} + +func (s *Stream) Close() error { + s.r, s.w = nil, nil + s.compress.r.Close() + s.compress.w.Close() + return nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/block.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/block.go new file mode 100644 index 00000000..401555fa --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/block.go @@ -0,0 +1,239 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package proto + +import ( + "errors" + "fmt" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "github.com/ClickHouse/clickhouse-go/v2/lib/column" +) + +type Block struct { + names []string + Packet byte + Columns []column.Interface +} + +func (b *Block) Rows() int { + if len(b.Columns) == 0 { + return 0 + } + return b.Columns[0].Rows() +} + +func (b *Block) AddColumn(name string, ct column.Type) error { + column, err := ct.Column() + if err != nil { + return err + } + b.names, b.Columns = append(b.names, name), append(b.Columns, column) + return nil +} + +func (b *Block) Append(v ...interface{}) (err error) { + columns := b.Columns + if len(columns) != len(v) { + return &BlockError{ + Op: "Append", + Err: fmt.Errorf("clickhouse: expected %d arguments, got %d", len(columns), len(v)), + } + } + for i, v := range v { + if err := b.Columns[i].AppendRow(v); err != nil { + return &BlockError{ + Op: "AppendRow", + Err: err, + ColumnName: b.names[i], + } + } + } + return nil +} + +func (b *Block) ColumnsNames() []string { + return b.names +} + +func (b *Block) Encode(encoder *binary.Encoder, revision uint64) error { + if revision > 0 { + if err := encodeBlockInfo(encoder); err != nil { + return err + } + } + var rows int + if len(b.Columns) != 0 { + rows = b.Columns[0].Rows() + for _, c := range b.Columns[1:] { + if rows != c.Rows() { + return &BlockError{ + Op: "Encode", + Err: errors.New("mismatched len of columns"), + } + } + } + } + if err := encoder.Uvarint(uint64(len(b.Columns))); err != nil { + return err + } + if err := encoder.Uvarint(uint64(rows)); err != nil { + return err + } + for i, c := range b.Columns { + if err := encoder.String(b.names[i]); err != nil { + return err + } + if err := encoder.String(string(c.Type())); err != nil { + return err + } + if serialize, ok := c.(column.CustomSerialization); ok { + if err := serialize.WriteStatePrefix(encoder); err != nil { + return &BlockError{ + Op: "Encode", + Err: err, + ColumnName: b.names[i], + } + } + } + if err := c.Encode(encoder); err != nil { + return &BlockError{ + Op: "Encode", + Err: err, + ColumnName: b.names[i], + } + } + } + return nil +} + +func (b *Block) Decode(decoder *binary.Decoder, revision uint64) (err error) { + if revision > 0 { + if err := decodeBlockInfo(decoder); err != nil { + return err + } + } + var ( + numRows uint64 + numCols uint64 + ) + if numCols, err = decoder.Uvarint(); err != nil { + return err + } + if numRows, err = decoder.Uvarint(); err != nil { + return err + } + if numRows > 1_000_000_000 { + return &BlockError{ + Op: "Decode", + Err: errors.New("more then 1 billion rows in block"), + } + } + b.Columns = make([]column.Interface, 0, numCols) + for i := 0; i < int(numCols); i++ { + var ( + columnName string + columnType string + ) + if columnName, err = decoder.String(); err != nil { + return err + } + if columnType, err = decoder.String(); err != nil { + return err + } + c, err := column.Type(columnType).Column() + if err != nil { + return err + } + if numRows != 0 { + if serialize, ok := c.(column.CustomSerialization); ok { + if err := serialize.ReadStatePrefix(decoder); err != nil { + return &BlockError{ + Op: "Decode", + Err: err, + ColumnName: columnName, + } + } + } + if err := c.Decode(decoder, int(numRows)); err != nil { + return &BlockError{ + Op: "Decode", + Err: err, + ColumnName: columnName, + } + } + } + b.names, b.Columns = append(b.names, columnName), append(b.Columns, c) + } + return nil +} + +func encodeBlockInfo(encoder *binary.Encoder) error { + { + if err := encoder.Uvarint(1); err != nil { + return err + } + if err := encoder.Bool(false); err != nil { + return err + } + if err := encoder.Uvarint(2); err != nil { + return err + } + if err := encoder.Int32(-1); err != nil { + return err + } + } + return encoder.Uvarint(0) +} + +func decodeBlockInfo(decoder *binary.Decoder) error { + { + if _, err := decoder.Uvarint(); err != nil { + return err + } + if _, err := decoder.Bool(); err != nil { + return err + } + if _, err := decoder.Uvarint(); err != nil { + return err + } + if _, err := decoder.Int32(); err != nil { + return err + } + } + if _, err := decoder.Uvarint(); err != nil { + return err + } + return nil +} + +type BlockError struct { + Op string + Err error + ColumnName string +} + +func (e *BlockError) Error() string { + switch err := e.Err.(type) { + case *column.Error: + return fmt.Sprintf("clickhouse [%s]: (%s %s) %s", e.Op, e.ColumnName, err.ColumnType, err.Err) + case *column.DateOverflowError: + return fmt.Sprintf("clickhouse: dateTime overflow. %s must be between %s and %s", e.ColumnName, err.Min.Format(err.Format), err.Max.Format(err.Format)) + } + return fmt.Sprintf("clickhouse [%s]: %s %s", e.Op, e.ColumnName, e.Err) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/const.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/const.go new file mode 100644 index 00000000..6eac3cdf --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/const.go @@ -0,0 +1,78 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package proto + +// see https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Protocol.h +const ( + DBMS_MIN_REVISION_WITH_CLIENT_INFO = 54032 + DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE = 54058 + DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO = 54060 + DBMS_MIN_REVISION_WITH_SERVER_DISPLAY_NAME = 54372 + DBMS_MIN_REVISION_WITH_VERSION_PATCH = 54401 + DBMS_MIN_REVISION_WITH_CLIENT_WRITE_INFO = 54420 + DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS = 54429 + DBMS_MIN_REVISION_WITH_INTERSERVER_SECRET = 54441 + DBMS_MIN_REVISION_WITH_OPENTELEMETRY = 54442 + DBMS_MIN_PROTOCOL_VERSION_WITH_DISTRIBUTED_DEPTH = 54448 + DBMS_MIN_PROTOCOL_VERSION_WITH_INITIAL_QUERY_START_TIME = 54449 + DBMS_MIN_PROTOCOL_VERSION_WITH_INCREMENTAL_PROFILE_EVENTS = 54451 + DBMS_MIN_REVISION_WITH_PARALLEL_REPLICAS = 54453 + DBMS_TCP_PROTOCOL_VERSION = DBMS_MIN_REVISION_WITH_PARALLEL_REPLICAS +) + +const ( + ClientHello = 0 + ClientQuery = 1 + ClientData = 2 + ClientCancel = 3 + ClientPing = 4 +) + +const ( + ClientQueryNone = 0 + ClientQueryInitial = 1 + ClientQuerySecondary = 2 +) + +const ( + CompressEnable uint64 = 1 + CompressDisable uint64 = 0 +) + +const ( + StateComplete = 2 +) + +const ( + ServerHello = 0 + ServerData = 1 + ServerException = 2 + ServerProgress = 3 + ServerPong = 4 + ServerEndOfStream = 5 + ServerProfileInfo = 6 + ServerTotals = 7 + ServerExtremes = 8 + ServerTablesStatus = 9 + ServerLog = 10 + ServerTableColumns = 11 + ServerPartUUIDs = 12 + ServerReadTaskRequest = 13 + ServerProfileEvents = 14 + ServerTreeReadTaskRequest = 15 +) diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/exception.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/exception.go new file mode 100644 index 00000000..c58bef0d --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/exception.go @@ -0,0 +1,81 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package proto + +import ( + "fmt" + "strings" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type Exception struct { + Code int32 + Name string + Message string + StackTrace string + Nested []Exception + nested bool +} + +func (e *Exception) Error() string { + return fmt.Sprintf("code: %d, message: %s", e.Code, e.Message) +} + +func (e *Exception) Decode(decoder *binary.Decoder) (err error) { + var exceptions []Exception + for { + var ex Exception + if err := ex.decode(decoder); err != nil { + return err + } + if exceptions = append(exceptions, ex); !ex.nested { + break + } + } + if len(exceptions) != 0 { + e.Code = exceptions[0].Code + e.Name = exceptions[0].Name + e.Message = exceptions[0].Message + e.StackTrace = exceptions[0].StackTrace + if exceptions[0].nested { + e.Nested = exceptions[1:] + } + } + return nil +} + +func (e *Exception) decode(decoder *binary.Decoder) (err error) { + if e.Code, err = decoder.Int32(); err != nil { + return err + } + if e.Name, err = decoder.String(); err != nil { + return err + } + if e.Message, err = decoder.String(); err != nil { + return err + } + e.Message = strings.TrimSpace(strings.TrimPrefix(e.Message, e.Name+":")) + if e.StackTrace, err = decoder.String(); err != nil { + return err + } + if e.nested, err = decoder.Bool(); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/handshake.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/handshake.go new file mode 100644 index 00000000..e82957b4 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/handshake.go @@ -0,0 +1,112 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package proto + +import ( + "fmt" + "time" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "github.com/ClickHouse/clickhouse-go/v2/lib/timezone" +) + +const ClientName = "Golang SQLDriver" + +const ( + ClientVersionMajor = 1 + ClientVersionMinor = 1 + ClientTCPProtocolVersion = DBMS_TCP_PROTOCOL_VERSION +) + +type ClientHandshake struct{} + +func (ClientHandshake) Encode(encoder *binary.Encoder) error { + if err := encoder.String(ClientName); err != nil { + return err + } + if err := encoder.Uvarint(ClientVersionMajor); err != nil { + return err + } + if err := encoder.Uvarint(ClientVersionMinor); err != nil { + return err + } + return encoder.Uvarint(ClientTCPProtocolVersion) +} + +func (ClientHandshake) String() string { + return fmt.Sprintf("%s %d.%d.%d", ClientName, ClientVersionMajor, ClientVersionMinor, ClientTCPProtocolVersion) +} + +type ServerHandshake struct { + Name string + DisplayName string + Revision uint64 + Version struct { + Major uint64 + Minor uint64 + Patch uint64 + } + Timezone *time.Location +} + +func (srv *ServerHandshake) Decode(decoder *binary.Decoder) (err error) { + if srv.Name, err = decoder.String(); err != nil { + return fmt.Errorf("could not read server name: %v", err) + } + if srv.Version.Major, err = decoder.Uvarint(); err != nil { + return fmt.Errorf("could not read server major version: %v", err) + } + if srv.Version.Minor, err = decoder.Uvarint(); err != nil { + return fmt.Errorf("could not read server minor version: %v", err) + } + if srv.Revision, err = decoder.Uvarint(); err != nil { + return fmt.Errorf("could not read server revision: %v", err) + } + if srv.Revision >= DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE { + name, err := decoder.String() + if err != nil { + return fmt.Errorf("could not read server timezone: %v", err) + } + if srv.Timezone, err = timezone.Load(name); err != nil { + return fmt.Errorf("could not load time location: %v", err) + } + } + if srv.Revision >= DBMS_MIN_REVISION_WITH_SERVER_DISPLAY_NAME { + if srv.DisplayName, err = decoder.String(); err != nil { + return fmt.Errorf("could not read server display name: %v", err) + } + } + if srv.Revision >= DBMS_MIN_REVISION_WITH_VERSION_PATCH { + if srv.Version.Patch, err = decoder.Uvarint(); err != nil { + return fmt.Errorf("could not read server patch: %v", err) + } + } else { + srv.Version.Patch = srv.Revision + } + return nil +} + +func (srv ServerHandshake) String() string { + return fmt.Sprintf("%s (%s) server version %d.%d.%d revision %d (timezone %s)", srv.Name, srv.DisplayName, + srv.Version.Major, + srv.Version.Minor, + srv.Version.Patch, + srv.Revision, + srv.Timezone, + ) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/profile_info.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/profile_info.go new file mode 100644 index 00000000..5617529d --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/profile_info.go @@ -0,0 +1,66 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package proto + +import ( + "fmt" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type ProfileInfo struct { + Rows uint64 + Bytes uint64 + Blocks uint64 + AppliedLimit bool + RowsBeforeLimit uint64 + CalculatedRowsBeforeLimit bool +} + +func (p *ProfileInfo) Decode(decoder *binary.Decoder, revision uint64) (err error) { + if p.Rows, err = decoder.Uvarint(); err != nil { + return err + } + if p.Blocks, err = decoder.Uvarint(); err != nil { + return err + } + if p.Bytes, err = decoder.Uvarint(); err != nil { + return err + } + if p.AppliedLimit, err = decoder.Bool(); err != nil { + return err + } + if p.RowsBeforeLimit, err = decoder.Uvarint(); err != nil { + return err + } + if p.CalculatedRowsBeforeLimit, err = decoder.Bool(); err != nil { + return err + } + return nil +} + +func (p *ProfileInfo) String() string { + return fmt.Sprintf("rows=%d, bytes=%d, blocks=%d, rows before limit=%d, applied limit=%t, calculated rows before limit=%t", + p.Rows, + p.Bytes, + p.Blocks, + p.RowsBeforeLimit, + p.AppliedLimit, + p.CalculatedRowsBeforeLimit, + ) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/progress.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/progress.go new file mode 100644 index 00000000..7e77c47b --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/progress.go @@ -0,0 +1,68 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package proto + +import ( + "fmt" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type Progress struct { + Rows uint64 + Bytes uint64 + TotalRows uint64 + WroteRows uint64 + WroteBytes uint64 + withClient bool +} + +func (p *Progress) Decode(decoder *binary.Decoder, revision uint64) (err error) { + if p.Rows, err = decoder.Uvarint(); err != nil { + return err + } + if p.Bytes, err = decoder.Uvarint(); err != nil { + return err + } + if p.TotalRows, err = decoder.Uvarint(); err != nil { + return err + } + if revision >= DBMS_MIN_REVISION_WITH_CLIENT_WRITE_INFO { + p.withClient = true + if p.WroteRows, err = decoder.Uvarint(); err != nil { + return err + } + if p.WroteBytes, err = decoder.Uvarint(); err != nil { + return err + } + } + return nil +} + +func (p *Progress) String() string { + if !p.withClient { + return fmt.Sprintf("rows=%d, bytes=%d, total rows=%d", p.Rows, p.Bytes, p.TotalRows) + } + return fmt.Sprintf("rows=%d, bytes=%d, total rows=%d, wrote rows=%d wrote bytes=%d", + p.Rows, + p.Bytes, + p.TotalRows, + p.WroteRows, + p.WroteBytes, + ) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/query.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/query.go new file mode 100644 index 00000000..b88bbd90 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/query.go @@ -0,0 +1,159 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package proto + +import ( + "fmt" + "os" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" + "go.opentelemetry.io/otel/trace" +) + +var ( + osUser = os.Getenv("USER") + hostname, _ = os.Hostname() +) + +type Query struct { + ID string + Span trace.SpanContext + Body string + QuotaKey string + Settings Settings + Compression bool + InitialUser string + InitialAddress string +} + +func (q *Query) Encode(encoder *binary.Encoder, revision uint64) error { + if err := encoder.String(q.ID); err != nil { + return err + } + // client_info + if err := q.encodeClientInfo(encoder, revision); err != nil { + return err + } + // settings + if err := q.Settings.Encode(encoder, revision); err != nil { + return err + } + encoder.String("" /* empty string is a marker of the end of setting */) + + if revision >= DBMS_MIN_REVISION_WITH_INTERSERVER_SECRET { + encoder.String("") + } + { + encoder.Byte(StateComplete) + encoder.Bool(q.Compression) + } + return encoder.String(q.Body) +} + +func (q *Query) encodeClientInfo(encoder *binary.Encoder, revision uint64) error { + encoder.Byte(ClientQueryInitial) + encoder.String(q.InitialUser) // initial_user + encoder.String("") // initial_query_id + encoder.String(q.InitialAddress) // initial_address + if revision >= DBMS_MIN_PROTOCOL_VERSION_WITH_INITIAL_QUERY_START_TIME { + encoder.Int64(0) // initial_query_start_time_microseconds + } + encoder.Byte(1) // interface [tcp - 1, http - 2] + { + encoder.String(osUser) + encoder.String(hostname) + encoder.String(ClientName) + encoder.Uvarint(ClientVersionMajor) + encoder.Uvarint(ClientVersionMinor) + encoder.Uvarint(ClientTCPProtocolVersion) + } + if revision >= DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO { + encoder.String(q.QuotaKey) + } + if revision >= DBMS_MIN_PROTOCOL_VERSION_WITH_DISTRIBUTED_DEPTH { + encoder.Uvarint(0) + } + if revision >= DBMS_MIN_REVISION_WITH_VERSION_PATCH { + encoder.Uvarint(0) + } + if revision >= DBMS_MIN_REVISION_WITH_OPENTELEMETRY { + switch { + case q.Span.IsValid(): + encoder.Byte(1) + { + v := q.Span.TraceID() + encoder.Raw(v[:]) + } + { + v := q.Span.SpanID() + encoder.Raw(v[:]) + } + encoder.String(q.Span.TraceState().String()) + encoder.Byte(byte(q.Span.TraceFlags())) + + default: + encoder.Byte(0) + } + } + if revision >= DBMS_MIN_REVISION_WITH_PARALLEL_REPLICAS { + encoder.Uvarint(0) // collaborate_with_initiator + encoder.Uvarint(0) // count_participating_replicas + encoder.Uvarint(0) // number_of_current_replica + } + return nil +} + +type Settings []Setting + +type Setting struct { + Key string + Value interface{} +} + +func (s Settings) Encode(encoder *binary.Encoder, revision uint64) error { + for _, s := range s { + if err := s.encode(encoder, revision); err != nil { + return err + } + } + return nil +} + +func (s *Setting) encode(encoder *binary.Encoder, revision uint64) error { + if err := encoder.String(s.Key); err != nil { + return err + } + if revision <= DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS { + var value uint64 + switch v := s.Value.(type) { + case int: + value = uint64(v) + case bool: + if value = 0; v { + value = 1 + } + default: + return fmt.Errorf("query setting %s has unsupported data type", s.Key) + } + return encoder.Uvarint(value) + } + if err := encoder.Bool(true); err != nil { // is_important + return err + } + return encoder.String(fmt.Sprint(s.Value)) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/table_columns.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/table_columns.go new file mode 100644 index 00000000..0f37d513 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/proto/table_columns.go @@ -0,0 +1,43 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package proto + +import ( + "fmt" + + "github.com/ClickHouse/clickhouse-go/v2/lib/binary" +) + +type TableColumns struct { + First string + Second string +} + +func (t *TableColumns) Decode(decoder *binary.Decoder, revision uint64) (err error) { + if t.First, err = decoder.String(); err != nil { + return err + } + if t.Second, err = decoder.String(); err != nil { + return err + } + return nil +} + +func (t *TableColumns) String() string { + return fmt.Sprintf("first=%s, second=%s", t.First, t.Second) +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/timezone/timezone.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/timezone/timezone.go new file mode 100644 index 00000000..09eeffd0 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/lib/timezone/timezone.go @@ -0,0 +1,44 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package timezone + +import ( + "sync" + "time" +) + +var cache = struct { + mutex sync.Mutex + items map[string]*time.Location +}{ + items: make(map[string]*time.Location), +} + +func Load(name string) (*time.Location, error) { + cache.mutex.Lock() + defer cache.mutex.Unlock() + if tz, found := cache.items[name]; found { + return tz, nil + } + tz, err := time.LoadLocation(name) + if err != nil { + return nil, err + } + cache.items[name] = tz + return tz, nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/scan.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/scan.go new file mode 100644 index 00000000..bb1b1ba0 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/scan.go @@ -0,0 +1,85 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "context" + "errors" + "fmt" + "reflect" + + "github.com/ClickHouse/clickhouse-go/v2/lib/proto" +) + +func (ch *clickhouse) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error { + value := reflect.ValueOf(dest) + if value.Kind() != reflect.Ptr { + return &OpError{ + Op: "Select", + Err: errors.New("must pass a pointer, not a value, to Select destination"), + } + } + if value.IsNil() { + return &OpError{ + Op: "Select", + Err: errors.New("nil pointer passed to Select destination"), + } + } + direct := reflect.Indirect(value) + if direct.Kind() != reflect.Slice { + return fmt.Errorf("must pass a slice to Select destination") + } + var ( + base = direct.Type().Elem() + rows, err = ch.Query(ctx, query, args...) + ) + if err != nil { + return err + } + defer rows.Close() + for rows.Next() { + elem := reflect.New(base) + if err := rows.ScanStruct(elem.Interface()); err != nil { + return err + } + direct.Set(reflect.Append(direct, elem.Elem())) + } + if err := rows.Close(); err != nil { + return err + } + return rows.Err() +} + +func scan(block *proto.Block, row int, dest ...interface{}) error { + columns := block.Columns + if len(columns) != len(dest) { + return &OpError{ + Op: "Scan", + Err: fmt.Errorf("expected %d destination arguments in Scan, not %d", len(columns), len(dest)), + } + } + for i, d := range dest { + if err := columns[i].ScanRow(d, row-1); err != nil { + return &OpError{ + Err: err, + ColumnName: block.ColumnsNames()[i], + } + } + } + return nil +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/v2/struct_map.go b/vendor/github.com/ClickHouse/clickhouse-go/v2/struct_map.go new file mode 100644 index 00000000..cf3335d7 --- /dev/null +++ b/vendor/github.com/ClickHouse/clickhouse-go/v2/struct_map.go @@ -0,0 +1,111 @@ +// Licensed to ClickHouse, Inc. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. ClickHouse, Inc. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package clickhouse + +import ( + "fmt" + "reflect" +) + +type structMap struct { + cache map[reflect.Type]map[string][]int +} + +func (m *structMap) Map(op string, columns []string, s interface{}, ptr bool) ([]interface{}, error) { + var ( + v = reflect.ValueOf(s) + t = reflect.TypeOf(s) + ) + if v.Kind() != reflect.Ptr { + return nil, &OpError{ + Op: op, + Err: fmt.Errorf("must pass a pointer, not a value, to %s destination", op), + } + } + if v.IsNil() { + return nil, &OpError{ + Op: op, + Err: fmt.Errorf("nil pointer passed to %s destination", op), + } + } + if v = reflect.Indirect(v); t.Kind() == reflect.Ptr { + t = t.Elem() + } + if v.Kind() != reflect.Struct { + return nil, &OpError{ + Op: op, + Err: fmt.Errorf("%s expects a struct dest", op), + } + } + var ( + index map[string][]int + values = make([]interface{}, 0, len(columns)) + ) + + switch idx, found := m.cache[t]; { + case found: + index = idx + default: + index = structIdx(t) + m.cache[t] = index + } + for _, name := range columns { + idx, found := index[name] + if !found { + return nil, &OpError{ + Op: op, + Err: fmt.Errorf("missing destination name %q in %T", name, s), + } + } + switch field := v.FieldByIndex(idx); { + case ptr: + values = append(values, field.Addr().Interface()) + default: + values = append(values, field.Interface()) + } + } + return values, nil +} + +func structIdx(t reflect.Type) map[string][]int { + fields := make(map[string][]int) + for i := 0; i < t.NumField(); i++ { + var ( + f = t.Field(i) + name = f.Name + ) + if tn := f.Tag.Get("ch"); len(tn) != 0 { + name = tn + } + switch { + case name == "-", len(f.PkgPath) != 0 && !f.Anonymous: + continue + } + switch { + case f.Anonymous: + if f.Type.Kind() != reflect.Ptr { + for k, idx := range structIdx(f.Type) { + fields[k] = append(f.Index, idx...) + } + } + default: + fields[name] = f.Index + } + } + return fields +} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/word_matcher.go b/vendor/github.com/ClickHouse/clickhouse-go/word_matcher.go deleted file mode 100644 index 7cd9dcd7..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/word_matcher.go +++ /dev/null @@ -1,31 +0,0 @@ -package clickhouse - -import ( - "strings" - "unicode" -) - -// wordMatcher is a simple automata to match a single word (case insensitive) -type wordMatcher struct { - word []rune - position uint8 -} - -// newMatcher returns matcher for word needle -func newMatcher(needle string) *wordMatcher { - return &wordMatcher{word: []rune(strings.ToUpper(needle)), - position: 0} -} - -func (m *wordMatcher) matchRune(r rune) bool { - if m.word[m.position] == unicode.ToUpper(r) { - if m.position == uint8(len(m.word)-1) { - m.position = 0 - return true - } - m.position++ - } else { - m.position = 0 - } - return false -} diff --git a/vendor/github.com/ClickHouse/clickhouse-go/write_column.go b/vendor/github.com/ClickHouse/clickhouse-go/write_column.go deleted file mode 100644 index eb4f0fe3..00000000 --- a/vendor/github.com/ClickHouse/clickhouse-go/write_column.go +++ /dev/null @@ -1,66 +0,0 @@ -package clickhouse - -import ( - "database/sql" - "database/sql/driver" - "time" - - "github.com/ClickHouse/clickhouse-go/lib/data" -) - -// Interface for Clickhouse driver -type Clickhouse interface { - Block() (*data.Block, error) - Prepare(query string) (driver.Stmt, error) - Begin() (driver.Tx, error) - Commit() error - Rollback() error - Close() error - WriteBlock(block *data.Block) error -} - -// Interface for Block allowing writes to individual columns -type ColumnWriter interface { - WriteDate(c int, v time.Time) error - WriteDateNullable(c int, v *time.Time) error - WriteDateTime(c int, v time.Time) error - WriteDateTimeNullable(c int, v *time.Time) error - WriteUInt8(c int, v uint8) error - WriteUInt8Nullable(c int, v *uint8) error - WriteUInt16(c int, v uint16) error - WriteUInt16Nullable(c int, v *uint16) error - WriteUInt32(c int, v uint32) error - WriteUInt32Nullable(c int, v *uint32) error - WriteUInt64(c int, v uint64) error - WriteUInt64Nullable(c int, v *uint64) error - WriteFloat32(c int, v float32) error - WriteFloat32Nullable(c int, v *float32) error - WriteFloat64(c int, v float64) error - WriteFloat64Nullable(c int, v *float64) error - WriteBytes(c int, v []byte) error - WriteArray(c int, v interface{}) error - WriteBytesNullable(c int, v *[]byte) error - WriteArrayNullable(c int, v *interface{}) error - WriteString(c int, v string) error - WriteStringNullable(c int, v *string) error - WriteFixedString(c int, v []byte) error - WriteFixedStringNullable(c int, v *[]byte) error -} - -func OpenDirect(dsn string) (Clickhouse, error) { - return open(dsn) -} - -func (ch *clickhouse) Block() (*data.Block, error) { - if ch.block == nil { - return nil, sql.ErrTxDone - } - return ch.block, nil -} - -func (ch *clickhouse) WriteBlock(block *data.Block) error { - if block == nil { - return sql.ErrTxDone - } - return ch.writeBlock(block, "") -} diff --git a/vendor/github.com/cloudflare/golz4/.gitignore b/vendor/github.com/cloudflare/golz4/.gitignore deleted file mode 100644 index 00268614..00000000 --- a/vendor/github.com/cloudflare/golz4/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe diff --git a/vendor/github.com/cloudflare/golz4/LICENSE b/vendor/github.com/cloudflare/golz4/LICENSE deleted file mode 100644 index 1579e81a..00000000 --- a/vendor/github.com/cloudflare/golz4/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013 CloudFlare, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - -* Neither the name of the CloudFlare, Inc. nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/cloudflare/golz4/Makefile b/vendor/github.com/cloudflare/golz4/Makefile deleted file mode 100644 index 2296d80e..00000000 --- a/vendor/github.com/cloudflare/golz4/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -GCFLAGS := -LDFLAGS := - -.PHONY: install -install: - @go install -v . - -.PHONY: test -test: - @go test -gcflags='$(GCFLAGS)' -ldflags='$(LDFLAGS)' . - -.PHONY: bench -bench: - @go test -gcflags='$(GCFLAGS)' -ldflags='$(LDFLAGS)' -bench . diff --git a/vendor/github.com/cloudflare/golz4/README.md b/vendor/github.com/cloudflare/golz4/README.md deleted file mode 100644 index e1bdb26e..00000000 --- a/vendor/github.com/cloudflare/golz4/README.md +++ /dev/null @@ -1,4 +0,0 @@ -golz4 -===== - -Golang interface to LZ4 compression diff --git a/vendor/github.com/cloudflare/golz4/doc.go b/vendor/github.com/cloudflare/golz4/doc.go deleted file mode 100644 index 4876be87..00000000 --- a/vendor/github.com/cloudflare/golz4/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package lz4 implements compression using lz4.c and lz4hc.c -// -// Copyright (c) 2013 CloudFlare, Inc. -package lz4 diff --git a/vendor/github.com/cloudflare/golz4/lz4.go b/vendor/github.com/cloudflare/golz4/lz4.go deleted file mode 100644 index f9abcb2d..00000000 --- a/vendor/github.com/cloudflare/golz4/lz4.go +++ /dev/null @@ -1,55 +0,0 @@ -package lz4 - -// #cgo CFLAGS: -O3 -// #include "src/lz4.h" -// #include "src/lz4.c" -import "C" - -import ( - "errors" - "fmt" - "unsafe" -) - -// p gets a char pointer to the first byte of a []byte slice -func p(in []byte) *C.char { - if len(in) == 0 { - return (*C.char)(unsafe.Pointer(nil)) - } - return (*C.char)(unsafe.Pointer(&in[0])) -} - -// clen gets the length of a []byte slice as a char * -func clen(s []byte) C.int { - return C.int(len(s)) -} - -// Uncompress with a known output size. len(out) should be equal to -// the length of the uncompressed out. -func Uncompress(in, out []byte) (error) { - if int(C.LZ4_decompress_safe(p(in), p(out), clen(in), clen(out))) < 0 { - return errors.New("Malformed compression stream") - } - - return nil -} - -// CompressBound calculates the size of the output buffer needed by -// Compress. This is based on the following macro: -// -// #define LZ4_COMPRESSBOUND(isize) -// ((unsigned int)(isize) > (unsigned int)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16) -func CompressBound(in []byte) int { - return len(in) + ((len(in) / 255) + 16) -} - -// Compress compresses in and puts the content in out. len(out) -// should have enough space for the compressed data (use CompressBound -// to calculate). Returns the number of bytes in the out slice. -func Compress(in, out []byte) (outSize int, err error) { - outSize = int(C.LZ4_compress_limitedOutput(p(in), p(out), clen(in), clen(out))) - if outSize == 0 { - err = fmt.Errorf("insufficient space for compression") - } - return -} diff --git a/vendor/github.com/cloudflare/golz4/lz4_hc.go b/vendor/github.com/cloudflare/golz4/lz4_hc.go deleted file mode 100644 index 9779352c..00000000 --- a/vendor/github.com/cloudflare/golz4/lz4_hc.go +++ /dev/null @@ -1,38 +0,0 @@ -package lz4 - -// #cgo CFLAGS: -O3 -// #include "src/lz4hc.h" -// #include "src/lz4hc.c" -import "C" - -import ( - "fmt" -) - -// CompressHC compresses in and puts the content in out. len(out) -// should have enough space for the compressed data (use CompressBound -// to calculate). Returns the number of bytes in the out slice. Determines -// the compression level automatically. -func CompressHC(in, out []byte) (int, error) { - // 0 automatically sets the compression level. - return CompressHCLevel(in, out, 0) -} - -// CompressHCLevel compresses in at the given compression level and puts the -// content in out. len(out) should have enough space for the compressed data -// (use CompressBound to calculate). Returns the number of bytes in the out -// slice. To automatically choose the compression level, use 0. Otherwise, use -// any value in the inclusive range 1 (worst) through 16 (best). Most -// applications will prefer CompressHC. -func CompressHCLevel(in, out []byte, level int) (outSize int, err error) { - // LZ4HC does not handle empty buffers. Pass through to Compress. - if len(in) == 0 || len(out) == 0 { - return Compress(in, out) - } - - outSize = int(C.LZ4_compressHC2_limitedOutput(p(in), p(out), clen(in), clen(out), C.int(level))) - if outSize == 0 { - err = fmt.Errorf("insufficient space for compression") - } - return -} diff --git a/vendor/github.com/cloudflare/golz4/sample.txt b/vendor/github.com/cloudflare/golz4/sample.txt deleted file mode 100644 index 3bb27fb7..00000000 --- a/vendor/github.com/cloudflare/golz4/sample.txt +++ /dev/null @@ -1,143 +0,0 @@ -CANTO I - - -IN the midway of this our mortal life, -I found me in a gloomy wood, astray -Gone from the path direct: and e'en to tell -It were no easy task, how savage wild -That forest, how robust and rough its growth, -Which to remember only, my dismay -Renews, in bitterness not far from death. -Yet to discourse of what there good befell, -All else will I relate discover'd there. -How first I enter'd it I scarce can say, -Such sleepy dullness in that instant weigh'd -My senses down, when the true path I left, -But when a mountain's foot I reach'd, where clos'd -The valley, that had pierc'd my heart with dread, -I look'd aloft, and saw his shoulders broad -Already vested with that planet's beam, -Who leads all wanderers safe through every way. - -Then was a little respite to the fear, -That in my heart's recesses deep had lain, -All of that night, so pitifully pass'd: -And as a man, with difficult short breath, -Forespent with toiling, 'scap'd from sea to shore, -Turns to the perilous wide waste, and stands -At gaze; e'en so my spirit, that yet fail'd -Struggling with terror, turn'd to view the straits, -That none hath pass'd and liv'd. My weary frame -After short pause recomforted, again -I journey'd on over that lonely steep, - -The hinder foot still firmer. Scarce the ascent -Began, when, lo! a panther, nimble, light, -And cover'd with a speckled skin, appear'd, -Nor, when it saw me, vanish'd, rather strove -To check my onward going; that ofttimes -With purpose to retrace my steps I turn'd. - -The hour was morning's prime, and on his way -Aloft the sun ascended with those stars, -That with him rose, when Love divine first mov'd -Those its fair works: so that with joyous hope -All things conspir'd to fill me, the gay skin -Of that swift animal, the matin dawn -And the sweet season. Soon that joy was chas'd, -And by new dread succeeded, when in view -A lion came, 'gainst me, as it appear'd, - -With his head held aloft and hunger-mad, -That e'en the air was fear-struck. A she-wolf -Was at his heels, who in her leanness seem'd -Full of all wants, and many a land hath made -Disconsolate ere now. She with such fear -O'erwhelmed me, at the sight of her appall'd, -That of the height all hope I lost. As one, -Who with his gain elated, sees the time -When all unwares is gone, he inwardly -Mourns with heart-griping anguish; such was I, -Haunted by that fell beast, never at peace, -Who coming o'er against me, by degrees -Impell'd me where the sun in silence rests. - -While to the lower space with backward step -I fell, my ken discern'd the form one of one, -Whose voice seem'd faint through long disuse of speech. -When him in that great desert I espied, -"Have mercy on me!" cried I out aloud, -"Spirit! or living man! what e'er thou be!" - -He answer'd: "Now not man, man once I was, -And born of Lombard parents, Mantuana both -By country, when the power of Julius yet -Was scarcely firm. At Rome my life was past -Beneath the mild Augustus, in the time -Of fabled deities and false. A bard -Was I, and made Anchises' upright son -The subject of my song, who came from Troy, -When the flames prey'd on Ilium's haughty towers. -But thou, say wherefore to such perils past -Return'st thou? wherefore not this pleasant mount -Ascendest, cause and source of all delight?" -"And art thou then that Virgil, that well-spring, -From which such copious floods of eloquence -Have issued?" I with front abash'd replied. -"Glory and light of all the tuneful train! -May it avail me that I long with zeal -Have sought thy volume, and with love immense -Have conn'd it o'er. My master thou and guide! -Thou he from whom alone I have deriv'd -That style, which for its beauty into fame -Exalts me. See the beast, from whom I fled. -O save me from her, thou illustrious sage!" - -"For every vein and pulse throughout my frame -She hath made tremble." He, soon as he saw -That I was weeping, answer'd, "Thou must needs -Another way pursue, if thou wouldst 'scape -From out that savage wilderness. This beast, -At whom thou criest, her way will suffer none -To pass, and no less hindrance makes than death: -So bad and so accursed in her kind, -That never sated is her ravenous will, -Still after food more craving than before. -To many an animal in wedlock vile -She fastens, and shall yet to many more, -Until that greyhound come, who shall destroy -Her with sharp pain. He will not life support -By earth nor its base metals, but by love, -Wisdom, and virtue, and his land shall be -The land 'twixt either Feltro. In his might -Shall safety to Italia's plains arise, -For whose fair realm, Camilla, virgin pure, -Nisus, Euryalus, and Turnus fell. -He with incessant chase through every town -Shall worry, until he to hell at length -Restore her, thence by envy first let loose. -I for thy profit pond'ring now devise, -That thou mayst follow me, and I thy guide -Will lead thee hence through an eternal space, -Where thou shalt hear despairing shrieks, and see -Spirits of old tormented, who invoke -A second death; and those next view, who dwell -Content in fire, for that they hope to come, -Whene'er the time may be, among the blest, -Into whose regions if thou then desire -T' ascend, a spirit worthier then I -Must lead thee, in whose charge, when I depart, -Thou shalt be left: for that Almighty King, -Who reigns above, a rebel to his law, -Adjudges me, and therefore hath decreed, -That to his city none through me should come. -He in all parts hath sway; there rules, there holds -His citadel and throne. O happy those, -Whom there he chooses!" I to him in few: -"Bard! by that God, whom thou didst not adore, -I do beseech thee (that this ill and worse -I may escape) to lead me, where thou saidst, -That I Saint Peter's gate may view, and those -Who as thou tell'st, are in such dismal plight." - -Onward he mov'd, I close his steps pursu'd. diff --git a/vendor/github.com/paulmach/orb/CHANGELOG.md b/vendor/github.com/paulmach/orb/CHANGELOG.md new file mode 100644 index 00000000..5691ca1d --- /dev/null +++ b/vendor/github.com/paulmach/orb/CHANGELOG.md @@ -0,0 +1,117 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [v0.7.1](https://github.com/paulmach/orb/compare/v0.7.0...v0.7.1) - 2022-05-16 + +No changes + +The v0.7.0 tag was updated since it initially pointed to the wrong commit. This is causing caching issues. + +## [v0.7.0](https://github.com/paulmach/orb/compare/v0.6.0...v0.7.0) - 2022-05-10 + +This tag is broken, please use v0.7.1 instead. + +### Breaking Changes + +- tilecover now returns an error (vs. panicing) on non-closed 2d geometry by [@paulmach](https://github.com/paulmach) in https://github.com/paulmach/orb/pull/87 + + This changes the signature of many of the methods in the [maptile/tilecover](https://github.com/paulmach/orb/tree/master/maptile/tilecover) package. + To emulate the old behavior replace: + + tiles := tilecover.Geometry(poly, zoom) + + with + + tiles, err := tilecover.Geometry(poly, zoom) + if err != nil { + panic(err) + } + +## [v0.6.0](https://github.com/paulmach/orb/compare/v0.5.0...v0.6.0) - 2022-05-04 + +### Added + +- geo: add correctly spelled LengthHaversine by [@paulmach](https://github.com/paulmach) in https://github.com/paulmach/orb/pull/97 +- geojson: add support for "external" json encoders/decoders by [@paulmach](https://github.com/paulmach) in https://github.com/paulmach/orb/pull/98 +- Add ewkb encoding/decoding support by [@paulmach](https://github.com/paulmach) in https://github.com/paulmach/orb/pull/88 + +## [v0.5.0](https://github.com/paulmach/orb/compare/v0.4.0...v0.5.0) - 2022-04-06 + +### Added + +- encoding/mvt: stable marshalling by [@travisgrigsby](https://github.com/travisgrigsby) in https://github.com/paulmach/orb/pull/93 +- encoding/mvt: support mvt marshal for GeometryCollection by [@dadadamarine](https://github.com/dadadamarine) in https://github.com/paulmach/orb/pull/89 + +### Fixed + +- quadtree: fix cleanup of nodes during removal by [@paulmach](https://github.com/paulmach) in https://github.com/paulmach/orb/pull/94 + +### Other + +- encoding/wkt: various code improvements by [@paulmach](https://github.com/paulmach) in https://github.com/paulmach/orb/pull/95 +- update protoscan to 0.2.1 by [@paulmach](https://github.com/paulmach) in https://github.com/paulmach/orb/pull/83 + +## [v0.4.0](https://github.com/paulmach/orb/compare/v0.3.0...v0.4.0) - 2021-11-11 + +### Added + +- geo: Add functions to calculate points based on distance and bearing by [@thzinc](https://github.com/thzinc) in https://github.com/paulmach/orb/pull/76 + +### Fixed + +- encoding/mvt: avoid reflect nil value by [@nicklasaven](https://github.com/nicklasaven) in https://github.com/paulmach/orb/pull/78 + +## [v0.3.0](https://github.com/paulmach/orb/compare/v0.2.2...v0.3.0) - 2021-10-16 + +### Changed + +- quadtree: sort KNearest results closest first by [@paulmach](https://github.com/paulmach) in https://github.com/paulmach/orb/pull/75 +- ring: require >=4 points to return true when calling Closed() by [@missinglink](https://github.com/missinglink) in https://github.com/paulmach/orb/pull/70 + +### Fixed + +- encoding/mvt: verify tile coord does not overflow for z > 20 by [@paulmach](https://github.com/paulmach) in https://github.com/paulmach/orb/pull/74 +- quadtree: Address panic-ing quadtree.Matching(…) method when finding no closest node by [@willsalz](https://github.com/willsalz) in https://github.com/paulmach/orb/pull/73 + +## [v0.2.2](https://github.com/paulmach/orb/compare/v0.2.1...v0.2.2) - 2021-06-05 + +### Fixed + +- Dependency resolution problems in some cases, issue https://github.com/paulmach/orb/issues/65, pr https://github.com/paulmach/orb/pull/66 + +## [v0.2.1](https://github.com/paulmach/orb/compare/v0.2.0...v0.2.1) - 2021-01-16 + +### Changed + +- encoding/mvt: upgrade protoscan v0.1 -> v0.2 [`ad31566`](https://github.com/paulmach/orb/commit/ad31566942027c1cd30dd341f35123fb54676599) +- encoding/mvt: remove github.com/pkg/errors as a dependency [`d2e235`](https://github.com/paulmach/orb/commit/d2e23529a295a0d973cc787ad2742cb6ccbd5306) + +## v0.2.0 - 2021-01-16 + +### Breaking Changes + +- Foreign Members in Feature Collections + + Extra attributes in a feature collection object will now be put into `featureCollection.ExtraMembers`. + Similarly, stuff in `ExtraMembers will be marshalled into the feature collection base. + The break happens if you were decoding these foreign members using something like + + ```go + type MyFeatureCollection struct { + geojson.FeatureCollection + Title string `json:"title"` + } + ``` + + **The above will no longer work** in this release and it never supported marshalling. See https://github.com/paulmach/orb/pull/56 for more details. + +- Features with nil/missing geometry will no longer return an errors + + Previously missing or invalid geometry in a feature collection would return a `ErrInvalidGeometry` error. + However missing geometry is compliant with [section 3.2](https://tools.ietf.org/html/rfc7946#section-3.2) of the spec. + See https://github.com/paulmach/orb/issues/38 and https://github.com/paulmach/orb/pull/58 for more details. + +### Changed + +- encoding/mvt: faster unmarshalling for Mapbox Vector Tiles (MVT) see https://github.com/paulmach/orb/pull/57 diff --git a/vendor/github.com/paulmach/orb/LICENSE.md b/vendor/github.com/paulmach/orb/LICENSE.md new file mode 100644 index 00000000..526962ad --- /dev/null +++ b/vendor/github.com/paulmach/orb/LICENSE.md @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2017 Paul Mach + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/paulmach/orb/README.md b/vendor/github.com/paulmach/orb/README.md new file mode 100644 index 00000000..8d0e5150 --- /dev/null +++ b/vendor/github.com/paulmach/orb/README.md @@ -0,0 +1,179 @@ +# orb [![CI](https://github.com/paulmach/orb/workflows/CI/badge.svg)](https://github.com/paulmach/orb/actions?query=workflow%3ACI+event%3Apush) [![codecov](https://codecov.io/gh/paulmach/orb/branch/master/graph/badge.svg?token=NuuTjLVpKW)](https://codecov.io/gh/paulmach/orb) [![Go Report Card](https://goreportcard.com/badge/github.com/paulmach/orb)](https://goreportcard.com/report/github.com/paulmach/orb) [![Go Reference](https://pkg.go.dev/badge/github.com/paulmach/orb.svg)](https://pkg.go.dev/github.com/paulmach/orb) + +Package `orb` defines a set of types for working with 2d geo and planar/projected geometric data in Golang. +There are a set of sub-packages that use these types to do interesting things. +They each provider their own README with extra info. + +## Interesting features + +- **Simple types** - allow for natural operations using the `make`, `append`, `len`, `[s:e]` builtins. +- **GeoJSON** - support as part of the [`geojson`](geojson) sub-package. +- **Mapbox Vector Tile** - encoding and decoding as part of the [`encoding/mvt`](encoding/mvt) sub-package. +- **Direct to type from DB query results** - by scanning WKB data directly into types. +- **Rich set of sub-packages** - including [`clipping`](clip), [`simplifing`](simplify), [`quadtree`](quadtree) and more. + +## Type definitions + +```go +type Point [2]float64 +type MultiPoint []Point + +type LineString []Point +type MultiLineString []LineString + +type Ring LineString +type Polygon []Ring +type MultiPolygon []Polygon + +type Collection []Geometry + +type Bound struct { Min, Max Point } +``` + +Defining the types as slices allows them to be accessed in an idiomatic way +using Go's built-in functions such at `make`, `append`, `len` +and with slice notation like `[s:e]`. For example: + +```go +ls := make(orb.LineString, 0, 100) +ls = append(ls, orb.Point{1, 1}) +point := ls[0] +``` + +### Shared `Geometry` interface + +All of the base types implement the `orb.Geometry` interface defined as: + +```go +type Geometry interface { + GeoJSONType() string + Dimensions() int // e.g. 0d, 1d, 2d + Bound() Bound +} +``` + +This interface is accepted by functions in the sub-packages which then act on the +base types correctly. For example: + +```go +l := clip.Geometry(bound, geom) +``` + +will use the appropriate clipping algorithm depending on if the input is 1d or 2d, +e.g. a `orb.LineString` or a `orb.Polygon`. + +Only a few methods are defined directly on these type, for example `Clone`, `Equal`, `GeoJSONType`. +Other operation that depend on geo vs. planar contexts are defined in the respective sub-package. +For example: + +- Computing the geo distance between two point: + + ```go + p1 := orb.Point{-72.796408, -45.407131} + p2 := orb.Point{-72.688541, -45.384987} + + geo.Distance(p1, p2) + ``` + +- Compute the planar area and centroid of a polygon: + + ```go + poly := orb.Polygon{...} + centroid, area := planar.CentroidArea(poly) + ``` + +## GeoJSON + +The [geojson](geojson) sub-package implements Marshalling and Unmarshalling of GeoJSON data. +Features are defined as: + +```go +type Feature struct { + ID interface{} `json:"id,omitempty"` + Type string `json:"type"` + Geometry orb.Geometry `json:"geometry"` + Properties Properties `json:"properties"` +} +``` + +Defining the geometry as an `orb.Geometry` interface along with sub-package functions +accepting geometries allows them to work together to create easy to follow code. +For example, clipping all the geometries in a collection: + +```go +fc, err := geojson.UnmarshalFeatureCollection(data) +for _, f := range fc { + f.Geometry = clip.Geometry(bound, f.Geometry) +} +``` + +The library supports third party "encoding/json" replacements +such [github.com/json-iterator/go](https://github.com/json-iterator/go). +See the [geojson](geojson) readme for more details. + +## Mapbox Vector Tiles + +The [encoding/mvt](encoding/mvt) sub-package implements Marshalling and +Unmarshalling [MVT](https://www.mapbox.com/vector-tiles/) data. +This package uses sets of `geojson.FeatureCollection` to define the layers, +keyed by the layer name. For example: + +```go +collections := map[string]*geojson.FeatureCollection{} + +// Convert to a layers object and project to tile coordinates. +layers := mvt.NewLayers(collections) +layers.ProjectToTile(maptile.New(x, y, z)) + +// In order to be used as source for MapboxGL geometries need to be clipped +// to max allowed extent. (uncomment next line) +// layers.Clip(mvt.MapboxGLDefaultExtentBound) + +// Simplify the geometry now that it's in tile coordinate space. +layers.Simplify(simplify.DouglasPeucker(1.0)) + +// Depending on use-case remove empty geometry, those too small to be +// represented in this tile space. +// In this case lines shorter than 1, and areas smaller than 2. +layers.RemoveEmpty(1.0, 2.0) + +// encoding using the Mapbox Vector Tile protobuf encoding. +data, err := layers.Marshal() // this data is NOT gzipped. + +// Sometimes MVT data is stored and transfered gzip compressed. In that case: +data, err := layers.MarshalGzipped() +``` + +## Decoding WKB/EWKB from a database query + +Geometries are usually returned from databases in WKB or EWKB format. The [encoding/ewkb](encoding/ewkb) +sub-package offers helpers to "scan" the data into the base types directly. +For example: + +```go +db.Exec( + "INSERT INTO postgis_table (point_column) VALUES (ST_GeomFromEWKB(?))", + ewkb.Value(orb.Point{1, 2}, 4326), +) + +row := db.QueryRow("SELECT ST_AsBinary(point_column) FROM postgis_table") + +var p orb.Point +err := row.Scan(ewkb.Scanner(&p)) +``` + +For more information see the readme in the [encoding/ewkb](encoding/ewkb) package. + +## List of sub-package utilities + +- [`clip`](clip) - clipping geometry to a bounding box +- [`encoding/mvt`](encoding/mvt) - encoded and decoding from [Mapbox Vector Tiles](https://www.mapbox.com/vector-tiles/) +- [`encoding/wkb`](encoding/wkb) - well-known binary as well as helpers to decode from the database queries +- [`encoding/ewkb`](encoding/ewkb) - extended well-known binary format that includes the SRID +- [`encoding/wkt`](encoding/wkt) - well-known text encoding +- [`geojson`](geojson) - working with geojson and the types in this package +- [`maptile`](maptile) - working with mercator map tiles and quadkeys +- [`project`](project) - project geometries between geo and planar contexts +- [`quadtree`](quadtree) - quadtree implementation using the types in this package +- [`resample`](resample) - resample points in a line string geometry +- [`simplify`](simplify) - linear geometry simplifications like Douglas-Peucker diff --git a/vendor/github.com/paulmach/orb/bound.go b/vendor/github.com/paulmach/orb/bound.go new file mode 100644 index 00000000..a0726d64 --- /dev/null +++ b/vendor/github.com/paulmach/orb/bound.go @@ -0,0 +1,172 @@ +package orb + +import ( + "math" +) + +var emptyBound = Bound{Min: Point{1, 1}, Max: Point{-1, -1}} + +// A Bound represents a closed box or rectangle. +// To create a bound with two points you can do something like: +// orb.MultiPoint{p1, p2}.Bound() +type Bound struct { + Min, Max Point +} + +// GeoJSONType returns the GeoJSON type for the object. +func (b Bound) GeoJSONType() string { + return "Polygon" +} + +// Dimensions returns 2 because a Bound is a 2d object. +func (b Bound) Dimensions() int { + return 2 +} + +// ToPolygon converts the bound into a Polygon object. +func (b Bound) ToPolygon() Polygon { + return Polygon{b.ToRing()} +} + +// ToRing converts the bound into a loop defined +// by the boundary of the box. +func (b Bound) ToRing() Ring { + return Ring{ + b.Min, + Point{b.Max[0], b.Min[1]}, + b.Max, + Point{b.Min[0], b.Max[1]}, + b.Min, + } +} + +// Extend grows the bound to include the new point. +func (b Bound) Extend(point Point) Bound { + // already included, no big deal + if b.Contains(point) { + return b + } + + return Bound{ + Min: Point{ + math.Min(b.Min[0], point[0]), + math.Min(b.Min[1], point[1]), + }, + Max: Point{ + math.Max(b.Max[0], point[0]), + math.Max(b.Max[1], point[1]), + }, + } +} + +// Union extends this bound to contain the union of this and the given bound. +func (b Bound) Union(other Bound) Bound { + if other.IsEmpty() { + return b + } + + b = b.Extend(other.Min) + b = b.Extend(other.Max) + b = b.Extend(other.LeftTop()) + b = b.Extend(other.RightBottom()) + + return b +} + +// Contains determines if the point is within the bound. +// Points on the boundary are considered within. +func (b Bound) Contains(point Point) bool { + if point[1] < b.Min[1] || b.Max[1] < point[1] { + return false + } + + if point[0] < b.Min[0] || b.Max[0] < point[0] { + return false + } + + return true +} + +// Intersects determines if two bounds intersect. +// Returns true if they are touching. +func (b Bound) Intersects(bound Bound) bool { + if (b.Max[0] < bound.Min[0]) || + (b.Min[0] > bound.Max[0]) || + (b.Max[1] < bound.Min[1]) || + (b.Min[1] > bound.Max[1]) { + return false + } + + return true +} + +// Pad extends the bound in all directions by the given value. +func (b Bound) Pad(d float64) Bound { + b.Min[0] -= d + b.Min[1] -= d + + b.Max[0] += d + b.Max[1] += d + + return b +} + +// Center returns the center of the bounds by "averaging" the x and y coords. +func (b Bound) Center() Point { + return Point{ + (b.Min[0] + b.Max[0]) / 2.0, + (b.Min[1] + b.Max[1]) / 2.0, + } +} + +// Top returns the top of the bound. +func (b Bound) Top() float64 { + return b.Max[1] +} + +// Bottom returns the bottom of the bound. +func (b Bound) Bottom() float64 { + return b.Min[1] +} + +// Right returns the right of the bound. +func (b Bound) Right() float64 { + return b.Max[0] +} + +// Left returns the left of the bound. +func (b Bound) Left() float64 { + return b.Min[0] +} + +// LeftTop returns the upper left point of the bound. +func (b Bound) LeftTop() Point { + return Point{b.Left(), b.Top()} +} + +// RightBottom return the lower right point of the bound. +func (b Bound) RightBottom() Point { + return Point{b.Right(), b.Bottom()} +} + +// IsEmpty returns true if it contains zero area or if +// it's in some malformed negative state where the left point is larger than the right. +// This can be caused by padding too much negative. +func (b Bound) IsEmpty() bool { + return b.Min[0] > b.Max[0] || b.Min[1] > b.Max[1] +} + +// IsZero return true if the bound just includes just null island. +func (b Bound) IsZero() bool { + return b.Max == Point{} && b.Min == Point{} +} + +// Bound returns the the same bound. +func (b Bound) Bound() Bound { + return b +} + +// Equal returns if two bounds are equal. +func (b Bound) Equal(c Bound) bool { + return b.Min == c.Min && b.Max == c.Max +} diff --git a/vendor/github.com/paulmach/orb/clone.go b/vendor/github.com/paulmach/orb/clone.go new file mode 100644 index 00000000..ac757b72 --- /dev/null +++ b/vendor/github.com/paulmach/orb/clone.go @@ -0,0 +1,56 @@ +package orb + +import ( + "fmt" +) + +// Clone will make a deep copy of the geometry. +func Clone(g Geometry) Geometry { + if g == nil { + return nil + } + + switch g := g.(type) { + case Point: + return g + case MultiPoint: + if g == nil { + return nil + } + return g.Clone() + case LineString: + if g == nil { + return nil + } + return g.Clone() + case MultiLineString: + if g == nil { + return nil + } + return g.Clone() + case Ring: + if g == nil { + return nil + } + return g.Clone() + case Polygon: + if g == nil { + return nil + } + return g.Clone() + case MultiPolygon: + if g == nil { + return nil + } + return g.Clone() + case Collection: + if g == nil { + return nil + } + return g.Clone() + case Bound: + return g + } + + panic(fmt.Sprintf("geometry type not supported: %T", g)) +} diff --git a/vendor/github.com/paulmach/orb/codecov.yml b/vendor/github.com/paulmach/orb/codecov.yml new file mode 100644 index 00000000..8bf5754f --- /dev/null +++ b/vendor/github.com/paulmach/orb/codecov.yml @@ -0,0 +1,10 @@ +coverage: + status: + project: off + patch: off + + precision: 2 + round: down + range: "70...90" + +comment: false diff --git a/vendor/github.com/paulmach/orb/define.go b/vendor/github.com/paulmach/orb/define.go new file mode 100644 index 00000000..a0b08f3a --- /dev/null +++ b/vendor/github.com/paulmach/orb/define.go @@ -0,0 +1,44 @@ +package orb + +// EarthRadius is the radius of the earth in meters. It is used in geo distance calculations. +// To keep things consistent, this value matches WGS84 Web Mercator (EPSG:3857). +const EarthRadius = 6378137.0 // meters + +// DefaultRoundingFactor is the default rounding factor used by the Round func. +var DefaultRoundingFactor = 1e6 // 6 decimal places + +// Orientation defines the order of the points in a polygon +// or closed ring. +type Orientation int8 + +// Constants to define orientation. +// They follow the right hand rule for orientation. +const ( + // CCW stands for Counter Clock Wise + CCW Orientation = 1 + + // CW stands for Clock Wise + CW Orientation = -1 +) + +// A DistanceFunc is a function that computes the distance between two points. +type DistanceFunc func(Point, Point) float64 + +// A Projection a function that moves a point from one space to another. +type Projection func(Point) Point + +// Pointer is something that can be represented by a point. +type Pointer interface { + Point() Point +} + +// A Simplifier is something that can simplify geometry. +type Simplifier interface { + Simplify(g Geometry) Geometry + LineString(ls LineString) LineString + MultiLineString(mls MultiLineString) MultiLineString + Ring(r Ring) Ring + Polygon(p Polygon) Polygon + MultiPolygon(mp MultiPolygon) MultiPolygon + Collection(c Collection) Collection +} diff --git a/vendor/github.com/paulmach/orb/equal.go b/vendor/github.com/paulmach/orb/equal.go new file mode 100644 index 00000000..7cc87dd5 --- /dev/null +++ b/vendor/github.com/paulmach/orb/equal.go @@ -0,0 +1,51 @@ +package orb + +import ( + "fmt" +) + +// Equal returns if the two geometrires are equal. +func Equal(g1, g2 Geometry) bool { + if g1 == nil || g2 == nil { + return g1 == g2 + } + + if g1.GeoJSONType() != g2.GeoJSONType() { + return false + } + + switch g1 := g1.(type) { + case Point: + return g1.Equal(g2.(Point)) + case MultiPoint: + return g1.Equal(g2.(MultiPoint)) + case LineString: + return g1.Equal(g2.(LineString)) + case MultiLineString: + return g1.Equal(g2.(MultiLineString)) + case Ring: + g2, ok := g2.(Ring) + if !ok { + return false + } + return g1.Equal(g2) + case Polygon: + g2, ok := g2.(Polygon) + if !ok { + return false + } + return g1.Equal(g2) + case MultiPolygon: + return g1.Equal(g2.(MultiPolygon)) + case Collection: + return g1.Equal(g2.(Collection)) + case Bound: + g2, ok := g2.(Bound) + if !ok { + return false + } + return g1.Equal(g2) + } + + panic(fmt.Sprintf("geometry type not supported: %T", g1)) +} diff --git a/vendor/github.com/paulmach/orb/geometry.go b/vendor/github.com/paulmach/orb/geometry.go new file mode 100644 index 00000000..a15e36b7 --- /dev/null +++ b/vendor/github.com/paulmach/orb/geometry.go @@ -0,0 +1,146 @@ +package orb + +// Geometry is an interface that represents the shared attributes +// of a geometry. +type Geometry interface { + GeoJSONType() string + Dimensions() int // e.g. 0d, 1d, 2d + Bound() Bound + + // requiring because sub package type switch over all possible types. + private() +} + +// compile time checks +var ( + _ Geometry = Point{} + _ Geometry = MultiPoint{} + _ Geometry = LineString{} + _ Geometry = MultiLineString{} + _ Geometry = Ring{} + _ Geometry = Polygon{} + _ Geometry = MultiPolygon{} + _ Geometry = Bound{} + + _ Geometry = Collection{} +) + +func (p Point) private() {} +func (mp MultiPoint) private() {} +func (ls LineString) private() {} +func (mls MultiLineString) private() {} +func (r Ring) private() {} +func (p Polygon) private() {} +func (mp MultiPolygon) private() {} +func (b Bound) private() {} +func (c Collection) private() {} + +// AllGeometries lists all possible types and values that a geometry +// interface can be. It should be used only for testing to verify +// functions that accept a Geometry will work in all cases. +var AllGeometries = []Geometry{ + nil, + Point{}, + MultiPoint{}, + LineString{}, + MultiLineString{}, + Ring{}, + Polygon{}, + MultiPolygon{}, + Bound{}, + Collection{}, + + // nil values + MultiPoint(nil), + LineString(nil), + MultiLineString(nil), + Ring(nil), + Polygon(nil), + MultiPolygon(nil), + Collection(nil), + + // Collection of Collection + Collection{Collection{Point{}}}, +} + +// A Collection is a collection of geometries that is also a Geometry. +type Collection []Geometry + +// GeoJSONType returns the geometry collection type. +func (c Collection) GeoJSONType() string { + return "GeometryCollection" +} + +// Dimensions returns the max of the dimensions of the collection. +func (c Collection) Dimensions() int { + max := -1 + for _, g := range c { + if d := g.Dimensions(); d > max { + max = d + } + } + + return max +} + +// Bound returns the bounding box of all the Geometries combined. +func (c Collection) Bound() Bound { + if len(c) == 0 { + return emptyBound + } + + var b Bound + start := -1 + + for i, g := range c { + if g != nil { + start = i + b = g.Bound() + break + } + } + + if start == -1 { + return emptyBound + } + + for i := start + 1; i < len(c); i++ { + if c[i] == nil { + continue + } + + b = b.Union(c[i].Bound()) + } + + return b +} + +// Equal compares two collections. Returns true if lengths are the same +// and all the sub geometries are the same and in the same order. +func (c Collection) Equal(collection Collection) bool { + if len(c) != len(collection) { + return false + } + + for i, g := range c { + if !Equal(g, collection[i]) { + return false + } + } + + return true +} + +// Clone returns a deep copy of the collection. +func (c Collection) Clone() Collection { + if c == nil { + return nil + } + + nc := make(Collection, len(c)) + for i, g := range c { + nc[i] = Clone(g) + } + + return nc +} diff --git a/vendor/github.com/paulmach/orb/line_string.go b/vendor/github.com/paulmach/orb/line_string.go new file mode 100644 index 00000000..6f489392 --- /dev/null +++ b/vendor/github.com/paulmach/orb/line_string.go @@ -0,0 +1,40 @@ +package orb + +// LineString represents a set of points to be thought of as a polyline. +type LineString []Point + +// GeoJSONType returns the GeoJSON type for the object. +func (ls LineString) GeoJSONType() string { + return "LineString" +} + +// Dimensions returns 1 because a LineString is a 1d object. +func (ls LineString) Dimensions() int { + return 1 +} + +// Reverse will reverse the line string. +// This is done inplace, ie. it modifies the original data. +func (ls LineString) Reverse() { + l := len(ls) - 1 + for i := 0; i <= l/2; i++ { + ls[i], ls[l-i] = ls[l-i], ls[i] + } +} + +// Bound returns a rect around the line string. Uses rectangular coordinates. +func (ls LineString) Bound() Bound { + return MultiPoint(ls).Bound() +} + +// Equal compares two line strings. Returns true if lengths are the same +// and all points are Equal. +func (ls LineString) Equal(lineString LineString) bool { + return MultiPoint(ls).Equal(MultiPoint(lineString)) +} + +// Clone returns a new copy of the line string. +func (ls LineString) Clone() LineString { + ps := MultiPoint(ls) + return LineString(ps.Clone()) +} diff --git a/vendor/github.com/paulmach/orb/multi_line_string.go b/vendor/github.com/paulmach/orb/multi_line_string.go new file mode 100644 index 00000000..2b67f20c --- /dev/null +++ b/vendor/github.com/paulmach/orb/multi_line_string.go @@ -0,0 +1,58 @@ +package orb + +// MultiLineString is a set of polylines. +type MultiLineString []LineString + +// GeoJSONType returns the GeoJSON type for the object. +func (mls MultiLineString) GeoJSONType() string { + return "MultiLineString" +} + +// Dimensions returns 1 because a MultiLineString is a 2d object. +func (mls MultiLineString) Dimensions() int { + return 1 +} + +// Bound returns a bound around all the line strings. +func (mls MultiLineString) Bound() Bound { + if len(mls) == 0 { + return emptyBound + } + + bound := mls[0].Bound() + for i := 1; i < len(mls); i++ { + bound = bound.Union(mls[i].Bound()) + } + + return bound +} + +// Equal compares two multi line strings. Returns true if lengths are the same +// and all points are Equal. +func (mls MultiLineString) Equal(multiLineString MultiLineString) bool { + if len(mls) != len(multiLineString) { + return false + } + + for i, ls := range mls { + if !ls.Equal(multiLineString[i]) { + return false + } + } + + return true +} + +// Clone returns a new deep copy of the multi line string. +func (mls MultiLineString) Clone() MultiLineString { + if mls == nil { + return nil + } + + nmls := make(MultiLineString, 0, len(mls)) + for _, ls := range mls { + nmls = append(nmls, ls.Clone()) + } + + return nmls +} diff --git a/vendor/github.com/paulmach/orb/multi_point.go b/vendor/github.com/paulmach/orb/multi_point.go new file mode 100644 index 00000000..cee955c1 --- /dev/null +++ b/vendor/github.com/paulmach/orb/multi_point.go @@ -0,0 +1,56 @@ +package orb + +// A MultiPoint represents a set of points in the 2D Eucledian or Cartesian plane. +type MultiPoint []Point + +// GeoJSONType returns the GeoJSON type for the object. +func (mp MultiPoint) GeoJSONType() string { + return "MultiPoint" +} + +// Dimensions returns 0 because a MultiPoint is a 0d object. +func (mp MultiPoint) Dimensions() int { + return 0 +} + +// Clone returns a new copy of the points. +func (mp MultiPoint) Clone() MultiPoint { + if mp == nil { + return nil + } + + points := make([]Point, len(mp)) + copy(points, mp) + + return MultiPoint(points) +} + +// Bound returns a bound around the points. Uses rectangular coordinates. +func (mp MultiPoint) Bound() Bound { + if len(mp) == 0 { + return emptyBound + } + + b := Bound{mp[0], mp[0]} + for _, p := range mp { + b = b.Extend(p) + } + + return b +} + +// Equal compares two MultiPoint objects. Returns true if lengths are the same +// and all points are Equal, and in the same order. +func (mp MultiPoint) Equal(multiPoint MultiPoint) bool { + if len(mp) != len(multiPoint) { + return false + } + + for i := range mp { + if !mp[i].Equal(multiPoint[i]) { + return false + } + } + + return true +} diff --git a/vendor/github.com/paulmach/orb/multi_polygon.go b/vendor/github.com/paulmach/orb/multi_polygon.go new file mode 100644 index 00000000..938a9a9e --- /dev/null +++ b/vendor/github.com/paulmach/orb/multi_polygon.go @@ -0,0 +1,56 @@ +package orb + +// MultiPolygon is a set of polygons. +type MultiPolygon []Polygon + +// GeoJSONType returns the GeoJSON type for the object. +func (mp MultiPolygon) GeoJSONType() string { + return "MultiPolygon" +} + +// Dimensions returns 2 because a MultiPolygon is a 2d object. +func (mp MultiPolygon) Dimensions() int { + return 2 +} + +// Bound returns a bound around the multi-polygon. +func (mp MultiPolygon) Bound() Bound { + if len(mp) == 0 { + return emptyBound + } + bound := mp[0].Bound() + for i := 1; i < len(mp); i++ { + bound = bound.Union(mp[i].Bound()) + } + + return bound +} + +// Equal compares two multi-polygons. +func (mp MultiPolygon) Equal(multiPolygon MultiPolygon) bool { + if len(mp) != len(multiPolygon) { + return false + } + + for i, p := range mp { + if !p.Equal(multiPolygon[i]) { + return false + } + } + + return true +} + +// Clone returns a new deep copy of the multi-polygon. +func (mp MultiPolygon) Clone() MultiPolygon { + if mp == nil { + return nil + } + + nmp := make(MultiPolygon, 0, len(mp)) + for _, p := range mp { + nmp = append(nmp, p.Clone()) + } + + return nmp +} diff --git a/vendor/github.com/paulmach/orb/point.go b/vendor/github.com/paulmach/orb/point.go new file mode 100644 index 00000000..c459c35d --- /dev/null +++ b/vendor/github.com/paulmach/orb/point.go @@ -0,0 +1,51 @@ +package orb + +// A Point is a Lon/Lat 2d point. +type Point [2]float64 + +var _ Pointer = Point{} + +// GeoJSONType returns the GeoJSON type for the object. +func (p Point) GeoJSONType() string { + return "Point" +} + +// Dimensions returns 0 because a point is a 0d object. +func (p Point) Dimensions() int { + return 0 +} + +// Bound returns a single point bound of the point. +func (p Point) Bound() Bound { + return Bound{p, p} +} + +// Point returns itself so it implements the Pointer interface. +func (p Point) Point() Point { + return p +} + +// Y returns the vertical coordinate of the point. +func (p Point) Y() float64 { + return p[1] +} + +// X returns the horizontal coordinate of the point. +func (p Point) X() float64 { + return p[0] +} + +// Lat returns the vertical, latitude coordinate of the point. +func (p Point) Lat() float64 { + return p[1] +} + +// Lon returns the horizontal, longitude coordinate of the point. +func (p Point) Lon() float64 { + return p[0] +} + +// Equal checks if the point represents the same point or vector. +func (p Point) Equal(point Point) bool { + return p[0] == point[0] && p[1] == point[1] +} diff --git a/vendor/github.com/paulmach/orb/polygon.go b/vendor/github.com/paulmach/orb/polygon.go new file mode 100644 index 00000000..b3e7d291 --- /dev/null +++ b/vendor/github.com/paulmach/orb/polygon.go @@ -0,0 +1,55 @@ +package orb + +// Polygon is a closed area. The first LineString is the outer ring. +// The others are the holes. Each LineString is expected to be closed +// ie. the first point matches the last. +type Polygon []Ring + +// GeoJSONType returns the GeoJSON type for the object. +func (p Polygon) GeoJSONType() string { + return "Polygon" +} + +// Dimensions returns 2 because a Polygon is a 2d object. +func (p Polygon) Dimensions() int { + return 2 +} + +// Bound returns a bound around the polygon. +func (p Polygon) Bound() Bound { + if len(p) == 0 { + return emptyBound + } + return p[0].Bound() +} + +// Equal compares two polygons. Returns true if lengths are the same +// and all points are Equal. +func (p Polygon) Equal(polygon Polygon) bool { + if len(p) != len(polygon) { + return false + } + + for i := range p { + if !p[i].Equal(polygon[i]) { + return false + } + } + + return true +} + +// Clone returns a new deep copy of the polygon. +// All of the rings are also cloned. +func (p Polygon) Clone() Polygon { + if p == nil { + return p + } + + np := make(Polygon, 0, len(p)) + for _, r := range p { + np = append(np, r.Clone()) + } + + return np +} diff --git a/vendor/github.com/paulmach/orb/ring.go b/vendor/github.com/paulmach/orb/ring.go new file mode 100644 index 00000000..5fe88aca --- /dev/null +++ b/vendor/github.com/paulmach/orb/ring.go @@ -0,0 +1,75 @@ +package orb + +// Ring represents a set of ring on the earth. +type Ring LineString + +// GeoJSONType returns the GeoJSON type for the object. +func (r Ring) GeoJSONType() string { + return "Polygon" +} + +// Dimensions returns 2 because a Ring is a 2d object. +func (r Ring) Dimensions() int { + return 2 +} + +// Closed will return true if the ring is a real ring. +// ie. 4+ points and the first and last points match. +// NOTE: this will not check for self-intersection. +func (r Ring) Closed() bool { + return (len(r) >= 4) && (r[0] == r[len(r)-1]) +} + +// Reverse changes the direction of the ring. +// This is done inplace, ie. it modifies the original data. +func (r Ring) Reverse() { + LineString(r).Reverse() +} + +// Bound returns a rect around the ring. Uses rectangular coordinates. +func (r Ring) Bound() Bound { + return MultiPoint(r).Bound() +} + +// Orientation returns 1 if the the ring is in couter-clockwise order, +// return -1 if the ring is the clockwise order and 0 if the ring is +// degenerate and had no area. +func (r Ring) Orientation() Orientation { + area := 0.0 + + // This is a fast planar area computation, which is okay for this use. + // implicitly move everything to near the origin to help with roundoff + offsetX := r[0][0] + offsetY := r[0][1] + for i := 1; i < len(r)-1; i++ { + area += (r[i][0]-offsetX)*(r[i+1][1]-offsetY) - + (r[i+1][0]-offsetX)*(r[i][1]-offsetY) + } + + if area > 0 { + return CCW + } + + if area < 0 { + return CW + } + + // degenerate case, no area + return 0 +} + +// Equal compares two rings. Returns true if lengths are the same +// and all points are Equal. +func (r Ring) Equal(ring Ring) bool { + return MultiPoint(r).Equal(MultiPoint(ring)) +} + +// Clone returns a new copy of the ring. +func (r Ring) Clone() Ring { + if r == nil { + return nil + } + + ps := MultiPoint(r) + return Ring(ps.Clone()) +} diff --git a/vendor/github.com/paulmach/orb/round.go b/vendor/github.com/paulmach/orb/round.go new file mode 100644 index 00000000..b6c77993 --- /dev/null +++ b/vendor/github.com/paulmach/orb/round.go @@ -0,0 +1,100 @@ +package orb + +import ( + "fmt" + "math" +) + +// Round will round all the coordinates of the geometry to the given factor. +// The default is 6 decimal places. +func Round(g Geometry, factor ...int) Geometry { + if g == nil { + return nil + } + + f := float64(DefaultRoundingFactor) + if len(factor) > 0 { + f = float64(factor[0]) + } + + switch g := g.(type) { + case Point: + return Point{ + math.Round(g[0]*f) / f, + math.Round(g[1]*f) / f, + } + case MultiPoint: + if g == nil { + return nil + } + roundPoints([]Point(g), f) + return g + case LineString: + if g == nil { + return nil + } + roundPoints([]Point(g), f) + return g + case MultiLineString: + if g == nil { + return nil + } + for _, ls := range g { + roundPoints([]Point(ls), f) + } + return g + case Ring: + if g == nil { + return nil + } + roundPoints([]Point(g), f) + return g + case Polygon: + if g == nil { + return nil + } + for _, r := range g { + roundPoints([]Point(r), f) + } + return g + case MultiPolygon: + if g == nil { + return nil + } + for _, p := range g { + for _, r := range p { + roundPoints([]Point(r), f) + } + } + return g + case Collection: + if g == nil { + return nil + } + + for i := range g { + g[i] = Round(g[i], int(f)) + } + return g + case Bound: + return Bound{ + Min: Point{ + math.Round(g.Min[0]*f) / f, + math.Round(g.Min[1]*f) / f, + }, + Max: Point{ + math.Round(g.Max[0]*f) / f, + math.Round(g.Max[1]*f) / f, + }, + } + } + + panic(fmt.Sprintf("geometry type not supported: %T", g)) +} + +func roundPoints(ps []Point, f float64) { + for i := range ps { + ps[i][0] = math.Round(ps[i][0]*f) / f + ps[i][1] = math.Round(ps[i][1]*f) / f + } +} diff --git a/vendor/github.com/pierrec/lz4/v4/internal/lz4block/blocks.go b/vendor/github.com/pierrec/lz4/v4/internal/lz4block/blocks.go index 84b89833..138083d9 100644 --- a/vendor/github.com/pierrec/lz4/v4/internal/lz4block/blocks.go +++ b/vendor/github.com/pierrec/lz4/v4/internal/lz4block/blocks.go @@ -8,7 +8,7 @@ const ( Block256Kb Block1Mb Block4Mb - Block8Mb = 2 * Block4Mb + Block8Mb = 2 * Block4Mb ) var ( diff --git a/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_amd64.s b/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_amd64.s index d86e981f..d47d6880 100644 --- a/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_amd64.s +++ b/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_amd64.s @@ -58,6 +58,7 @@ loop: // CX = lit_len MOVQ DX, CX SHRQ $4, CX + JZ finish_lit_copy // if lit_len != 0xF CMPQ CX, $0xF @@ -125,9 +126,6 @@ loop: JMP loop lit_len_loop_pre: - // if lit_len > 0 - CMPQ CX, $0 - JEQ offset CMPQ CX, $0xF JNE copy_literal @@ -157,24 +155,28 @@ copy_literal: CMPQ BX, R8 JA err_short_buf - // whats a good cut off to call memmove? - CMPQ CX, $16 + // Copy matches of <=48 bytes through the XMM registers. + CMPQ CX, $48 JGT memmove_lit - // if len(dst[di:]) < 16 + // if len(dst[di:]) < 48 MOVQ R8, AX SUBQ DI, AX - CMPQ AX, $16 + CMPQ AX, $48 JLT memmove_lit - // if len(src[si:]) < 16 - MOVQ R9, AX - SUBQ SI, AX - CMPQ AX, $16 + // if len(src[si:]) < 48 + MOVQ R9, BX + SUBQ SI, BX + CMPQ BX, $48 JLT memmove_lit MOVOU (SI), X0 + MOVOU 16(SI), X1 + MOVOU 32(SI), X2 MOVOU X0, (DI) + MOVOU X1, 16(DI) + MOVOU X2, 32(DI) ADDQ CX, SI ADDQ CX, DI diff --git a/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_arm64.s b/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_arm64.s index cb44977a..cf2761ce 100644 --- a/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_arm64.s +++ b/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_arm64.s @@ -8,23 +8,25 @@ #include "textflag.h" // Register allocation. -#define dst R0 -#define dstorig R1 -#define src R2 -#define dstend R3 -#define srcend R4 -#define match R5 // Match address. -#define dict R6 -#define dictlen R7 -#define dictend R8 -#define token R9 -#define len R10 // Literal and match lengths. -#define lenRem R11 -#define offset R12 // Match offset. -#define tmp1 R13 -#define tmp2 R14 -#define tmp3 R15 -#define tmp4 R16 +#define dst R0 +#define dstorig R1 +#define src R2 +#define dstend R3 +#define dstend16 R4 // dstend - 16 +#define srcend R5 +#define srcend16 R6 // srcend - 16 +#define match R7 // Match address. +#define dict R8 +#define dictlen R9 +#define dictend R10 +#define token R11 +#define len R12 // Literal and match lengths. +#define lenRem R13 +#define offset R14 // Match offset. +#define tmp1 R15 +#define tmp2 R16 +#define tmp3 R17 +#define tmp4 R19 // func decodeBlock(dst, src, dict []byte) int TEXT ·decodeBlock(SB), NOFRAME+NOSPLIT, $0-80 @@ -36,6 +38,12 @@ TEXT ·decodeBlock(SB), NOFRAME+NOSPLIT, $0-80 CBZ srcend, shortSrc ADD src, srcend + // dstend16 = max(dstend-16, 0) and similarly for srcend16. + SUBS $16, dstend, dstend16 + CSEL LO, ZR, dstend16, dstend16 + SUBS $16, srcend, srcend16 + CSEL LO, ZR, srcend16, srcend16 + LDP dict_base+48(FP), (dict, dictlen) ADD dict, dictlen, dictend @@ -71,27 +79,31 @@ readLitlenDone: // Copy literal. SUBS $16, len BLO copyLiteralShort - AND $15, len, lenRem copyLiteralLoop: - SUBS $16, len LDP.P 16(src), (tmp1, tmp2) STP.P (tmp1, tmp2), 16(dst) + SUBS $16, len BPL copyLiteralLoop - // lenRem = len%16 is the remaining number of bytes we need to copy. - // Since len was >= 16, we can do this in one load and one store, - // overlapping with the last load and store, without worrying about - // writing out of bounds. - ADD lenRem, src - ADD lenRem, dst - LDP -16(src), (tmp1, tmp2) - STP (tmp1, tmp2), -16(dst) + // Copy (final part of) literal of length 0-15. + // If we have >=16 bytes left in src and dst, just copy 16 bytes. +copyLiteralShort: + CMP dstend16, dst + CCMP LO, src, srcend16, $0b0010 // 0010 = preserve carry (LO). + BHS copyLiteralShortEnd + + AND $15, len + + LDP (src), (tmp1, tmp2) + ADD len, src + STP (tmp1, tmp2), (dst) + ADD len, dst B copyLiteralDone - // Copy literal of length 0-15. -copyLiteralShort: + // Safe but slow copy near the end of src, dst. +copyLiteralShortEnd: TBZ $3, len, 3(PC) MOVD.P 8(src), tmp1 MOVD.P tmp1, 8(dst) @@ -159,7 +171,7 @@ copyDict: CCMP NE, dictend, match, $0b0100 // 0100 sets the Z (EQ) flag. BNE copyDict - CBZ len, copyMatchDone + CBZ len, copyMatchDone // If the match extends beyond the dictionary, the rest is at dstorig. MOVD dstorig, match diff --git a/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_other.go b/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_other.go index 2ecce682..35420300 100644 --- a/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_other.go +++ b/vendor/github.com/pierrec/lz4/v4/internal/lz4block/decode_other.go @@ -1,3 +1,4 @@ +//go:build (!amd64 && !arm && !arm64) || appengine || !gc || noasm // +build !amd64,!arm,!arm64 appengine !gc noasm package lz4block @@ -10,9 +11,13 @@ func decodeBlock(dst, src, dict []byte) (ret int) { // Restrict capacities so we don't read or write out of bounds. dst = dst[:len(dst):len(dst)] src = src[:len(src):len(src)] - dictLen := uint(len(dict)) const hasError = -2 + + if len(src) == 0 { + return hasError + } + defer func() { if recover() != nil { ret = hasError @@ -20,7 +25,7 @@ func decodeBlock(dst, src, dict []byte) (ret int) { }() var si, di uint - for { + for si < uint(len(src)) { // Literals and match lengths (token). b := uint(src[si]) si++ @@ -74,7 +79,7 @@ func decodeBlock(dst, src, dict []byte) (ret int) { } } if si == uint(len(src)) { - return int(di) + break } else if si > uint(len(src)) { return hasError } @@ -102,35 +107,17 @@ func decodeBlock(dst, src, dict []byte) (ret int) { // Copy the match. if di < offset { - // The match is beyond our block, meaning in the dictionary - if offset-di > mLen { - // The match is entirely contained in the dictionary. Just copy! - copy(dst[di:di+mLen], dict[dictLen+di-offset:dictLen+di-offset+mLen]) - di = di + mLen - } else { - // The match stretches over the dictionary and our block - copySize := offset - di - restSize := mLen - copySize - - copy(dst[di:di+copySize], dict[dictLen-copySize:]) - di = di + copySize - - if di < restSize { - // Overlap - we want to copy more than what we have available, - // so copy byte per byte. - copyFrom := 0 - endOfMatch := di + restSize - for di < endOfMatch { - dst[di] = dst[copyFrom] - di = di + 1 - copyFrom = copyFrom + 1 - } - } else { - copy(dst[di:di+restSize], dst[0:restSize]) - di = di + restSize - } + // The match is beyond our block, meaning the first part + // is in the dictionary. + fromDict := dict[uint(len(dict))+di-offset:] + n := uint(copy(dst[di:di+mLen], fromDict)) + di += n + if mLen -= n; mLen == 0 { + continue } - continue + // We copied n = offset-di bytes from the dictionary, + // then set di = di+n = offset, so the following code + // copies from dst[di-offset:] = dst[0:]. } expanded := dst[di-offset:] @@ -145,6 +132,8 @@ func decodeBlock(dst, src, dict []byte) (ret int) { } di += uint(copy(dst[di:di+mLen], expanded[:mLen])) } + + return int(di) } func u16(p []byte) uint { return uint(binary.LittleEndian.Uint16(p)) } diff --git a/vendor/github.com/pierrec/lz4/v4/writer.go b/vendor/github.com/pierrec/lz4/v4/writer.go index 05a6aa14..56bd37ba 100644 --- a/vendor/github.com/pierrec/lz4/v4/writer.go +++ b/vendor/github.com/pierrec/lz4/v4/writer.go @@ -49,12 +49,12 @@ func (w *Writer) Apply(options ...Option) (err error) { default: return lz4errors.ErrOptionClosedOrError } + w.Reset(w.src) for _, o := range options { if err = o(w); err != nil { return } } - w.Reset(w.src) return } @@ -65,10 +65,8 @@ func (w *Writer) isNotConcurrent() bool { // init sets up the Writer when in newState. It does not change the Writer state. func (w *Writer) init() error { w.frame.InitW(w.src, w.num, w.legacy) - if true || !w.isNotConcurrent() { - size := w.frame.Descriptor.Flags.BlockSizeIndex() - w.data = size.Get() - } + size := w.frame.Descriptor.Flags.BlockSizeIndex() + w.data = size.Get() w.idx = 0 return w.frame.Descriptor.Write(w.frame, w.src) } diff --git a/vendor/github.com/shopspring/decimal/.gitignore b/vendor/github.com/shopspring/decimal/.gitignore new file mode 100644 index 00000000..ff36b987 --- /dev/null +++ b/vendor/github.com/shopspring/decimal/.gitignore @@ -0,0 +1,9 @@ +.git +*.swp + +# IntelliJ +.idea/ +*.iml + +# VS code +*.code-workspace diff --git a/vendor/github.com/shopspring/decimal/.travis.yml b/vendor/github.com/shopspring/decimal/.travis.yml new file mode 100644 index 00000000..6326d40f --- /dev/null +++ b/vendor/github.com/shopspring/decimal/.travis.yml @@ -0,0 +1,19 @@ +language: go + +arch: + - amd64 + - ppc64le + +go: + - 1.7.x + - 1.14.x + - 1.15.x + - 1.16.x + - 1.17.x + - tip + +install: + - go build . + +script: + - go test -v diff --git a/vendor/github.com/shopspring/decimal/CHANGELOG.md b/vendor/github.com/shopspring/decimal/CHANGELOG.md new file mode 100644 index 00000000..aea61154 --- /dev/null +++ b/vendor/github.com/shopspring/decimal/CHANGELOG.md @@ -0,0 +1,49 @@ +## Decimal v1.3.1 + +#### ENHANCEMENTS +- Reduce memory allocation in case of initialization from big.Int [#252](https://github.com/shopspring/decimal/pull/252) + +#### BUGFIXES +- Fix binary marshalling of decimal zero value [#253](https://github.com/shopspring/decimal/pull/253) + +## Decimal v1.3.0 + +#### FEATURES +- Add NewFromFormattedString initializer [#184](https://github.com/shopspring/decimal/pull/184) +- Add NewNullDecimal initializer [#234](https://github.com/shopspring/decimal/pull/234) +- Add implementation of natural exponent function (Taylor, Hull-Abraham) [#229](https://github.com/shopspring/decimal/pull/229) +- Add RoundUp, RoundDown, RoundCeil, RoundFloor methods [#196](https://github.com/shopspring/decimal/pull/196) [#202](https://github.com/shopspring/decimal/pull/202) [#220](https://github.com/shopspring/decimal/pull/220) +- Add XML support for NullDecimal [#192](https://github.com/shopspring/decimal/pull/192) +- Add IsInteger method [#179](https://github.com/shopspring/decimal/pull/179) +- Add Copy helper method [#123](https://github.com/shopspring/decimal/pull/123) +- Add InexactFloat64 helper method [#205](https://github.com/shopspring/decimal/pull/205) +- Add CoefficientInt64 helper method [#244](https://github.com/shopspring/decimal/pull/244) + +#### ENHANCEMENTS +- Performance optimization of NewFromString init method [#198](https://github.com/shopspring/decimal/pull/198) +- Performance optimization of Abs and Round methods [#240](https://github.com/shopspring/decimal/pull/240) +- Additional tests (CI) for ppc64le architecture [#188](https://github.com/shopspring/decimal/pull/188) + +#### BUGFIXES +- Fix rounding in FormatFloat fallback path (roundShortest method, fix taken from Go main repository) [#161](https://github.com/shopspring/decimal/pull/161) +- Add slice range checks to UnmarshalBinary method [#232](https://github.com/shopspring/decimal/pull/232) + +## Decimal v1.2.0 + +#### BREAKING +- Drop support for Go version older than 1.7 [#172](https://github.com/shopspring/decimal/pull/172) + +#### FEATURES +- Add NewFromInt and NewFromInt32 initializers [#72](https://github.com/shopspring/decimal/pull/72) +- Add support for Go modules [#157](https://github.com/shopspring/decimal/pull/157) +- Add BigInt, BigFloat helper methods [#171](https://github.com/shopspring/decimal/pull/171) + +#### ENHANCEMENTS +- Memory usage optimization [#160](https://github.com/shopspring/decimal/pull/160) +- Updated travis CI golang versions [#156](https://github.com/shopspring/decimal/pull/156) +- Update documentation [#173](https://github.com/shopspring/decimal/pull/173) +- Improve code quality [#174](https://github.com/shopspring/decimal/pull/174) + +#### BUGFIXES +- Revert remove insignificant digits [#159](https://github.com/shopspring/decimal/pull/159) +- Remove 15 interval for RoundCash [#166](https://github.com/shopspring/decimal/pull/166) diff --git a/vendor/github.com/shopspring/decimal/LICENSE b/vendor/github.com/shopspring/decimal/LICENSE new file mode 100644 index 00000000..ad2148aa --- /dev/null +++ b/vendor/github.com/shopspring/decimal/LICENSE @@ -0,0 +1,45 @@ +The MIT License (MIT) + +Copyright (c) 2015 Spring, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +- Based on https://github.com/oguzbilgic/fpd, which has the following license: +""" +The MIT License (MIT) + +Copyright (c) 2013 Oguz Bilgic + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +""" diff --git a/vendor/github.com/shopspring/decimal/README.md b/vendor/github.com/shopspring/decimal/README.md new file mode 100644 index 00000000..2e35df06 --- /dev/null +++ b/vendor/github.com/shopspring/decimal/README.md @@ -0,0 +1,130 @@ +# decimal + +[![Build Status](https://app.travis-ci.com/shopspring/decimal.svg?branch=master)](https://app.travis-ci.com/shopspring/decimal) [![GoDoc](https://godoc.org/github.com/shopspring/decimal?status.svg)](https://godoc.org/github.com/shopspring/decimal) [![Go Report Card](https://goreportcard.com/badge/github.com/shopspring/decimal)](https://goreportcard.com/report/github.com/shopspring/decimal) + +Arbitrary-precision fixed-point decimal numbers in go. + +_Note:_ Decimal library can "only" represent numbers with a maximum of 2^31 digits after the decimal point. + +## Features + + * The zero-value is 0, and is safe to use without initialization + * Addition, subtraction, multiplication with no loss of precision + * Division with specified precision + * Database/sql serialization/deserialization + * JSON and XML serialization/deserialization + +## Install + +Run `go get github.com/shopspring/decimal` + +## Requirements + +Decimal library requires Go version `>=1.7` + +## Usage + +```go +package main + +import ( + "fmt" + "github.com/shopspring/decimal" +) + +func main() { + price, err := decimal.NewFromString("136.02") + if err != nil { + panic(err) + } + + quantity := decimal.NewFromInt(3) + + fee, _ := decimal.NewFromString(".035") + taxRate, _ := decimal.NewFromString(".08875") + + subtotal := price.Mul(quantity) + + preTax := subtotal.Mul(fee.Add(decimal.NewFromFloat(1))) + + total := preTax.Mul(taxRate.Add(decimal.NewFromFloat(1))) + + fmt.Println("Subtotal:", subtotal) // Subtotal: 408.06 + fmt.Println("Pre-tax:", preTax) // Pre-tax: 422.3421 + fmt.Println("Taxes:", total.Sub(preTax)) // Taxes: 37.482861375 + fmt.Println("Total:", total) // Total: 459.824961375 + fmt.Println("Tax rate:", total.Sub(preTax).Div(preTax)) // Tax rate: 0.08875 +} +``` + +## Documentation + +http://godoc.org/github.com/shopspring/decimal + +## Production Usage + +* [Spring](https://shopspring.com/), since August 14, 2014. +* If you are using this in production, please let us know! + +## FAQ + +#### Why don't you just use float64? + +Because float64 (or any binary floating point type, actually) can't represent +numbers such as `0.1` exactly. + +Consider this code: http://play.golang.org/p/TQBd4yJe6B You might expect that +it prints out `10`, but it actually prints `9.999999999999831`. Over time, +these small errors can really add up! + +#### Why don't you just use big.Rat? + +big.Rat is fine for representing rational numbers, but Decimal is better for +representing money. Why? Here's a (contrived) example: + +Let's say you use big.Rat, and you have two numbers, x and y, both +representing 1/3, and you have `z = 1 - x - y = 1/3`. If you print each one +out, the string output has to stop somewhere (let's say it stops at 3 decimal +digits, for simplicity), so you'll get 0.333, 0.333, and 0.333. But where did +the other 0.001 go? + +Here's the above example as code: http://play.golang.org/p/lCZZs0w9KE + +With Decimal, the strings being printed out represent the number exactly. So, +if you have `x = y = 1/3` (with precision 3), they will actually be equal to +0.333, and when you do `z = 1 - x - y`, `z` will be equal to .334. No money is +unaccounted for! + +You still have to be careful. If you want to split a number `N` 3 ways, you +can't just send `N/3` to three different people. You have to pick one to send +`N - (2/3*N)` to. That person will receive the fraction of a penny remainder. + +But, it is much easier to be careful with Decimal than with big.Rat. + +#### Why isn't the API similar to big.Int's? + +big.Int's API is built to reduce the number of memory allocations for maximal +performance. This makes sense for its use-case, but the trade-off is that the +API is awkward and easy to misuse. + +For example, to add two big.Ints, you do: `z := new(big.Int).Add(x, y)`. A +developer unfamiliar with this API might try to do `z := a.Add(a, b)`. This +modifies `a` and sets `z` as an alias for `a`, which they might not expect. It +also modifies any other aliases to `a`. + +Here's an example of the subtle bugs you can introduce with big.Int's API: +https://play.golang.org/p/x2R_78pa8r + +In contrast, it's difficult to make such mistakes with decimal. Decimals +behave like other go numbers types: even though `a = b` will not deep copy +`b` into `a`, it is impossible to modify a Decimal, since all Decimal methods +return new Decimals and do not modify the originals. The downside is that +this causes extra allocations, so Decimal is less performant. My assumption +is that if you're using Decimals, you probably care more about correctness +than performance. + +## License + +The MIT License (MIT) + +This is a heavily modified fork of [fpd.Decimal](https://github.com/oguzbilgic/fpd), which was also released under the MIT License. diff --git a/vendor/github.com/shopspring/decimal/decimal-go.go b/vendor/github.com/shopspring/decimal/decimal-go.go new file mode 100644 index 00000000..9958d690 --- /dev/null +++ b/vendor/github.com/shopspring/decimal/decimal-go.go @@ -0,0 +1,415 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Multiprecision decimal numbers. +// For floating-point formatting only; not general purpose. +// Only operations are assign and (binary) left/right shift. +// Can do binary floating point in multiprecision decimal precisely +// because 2 divides 10; cannot do decimal floating point +// in multiprecision binary precisely. + +package decimal + +type decimal struct { + d [800]byte // digits, big-endian representation + nd int // number of digits used + dp int // decimal point + neg bool // negative flag + trunc bool // discarded nonzero digits beyond d[:nd] +} + +func (a *decimal) String() string { + n := 10 + a.nd + if a.dp > 0 { + n += a.dp + } + if a.dp < 0 { + n += -a.dp + } + + buf := make([]byte, n) + w := 0 + switch { + case a.nd == 0: + return "0" + + case a.dp <= 0: + // zeros fill space between decimal point and digits + buf[w] = '0' + w++ + buf[w] = '.' + w++ + w += digitZero(buf[w : w+-a.dp]) + w += copy(buf[w:], a.d[0:a.nd]) + + case a.dp < a.nd: + // decimal point in middle of digits + w += copy(buf[w:], a.d[0:a.dp]) + buf[w] = '.' + w++ + w += copy(buf[w:], a.d[a.dp:a.nd]) + + default: + // zeros fill space between digits and decimal point + w += copy(buf[w:], a.d[0:a.nd]) + w += digitZero(buf[w : w+a.dp-a.nd]) + } + return string(buf[0:w]) +} + +func digitZero(dst []byte) int { + for i := range dst { + dst[i] = '0' + } + return len(dst) +} + +// trim trailing zeros from number. +// (They are meaningless; the decimal point is tracked +// independent of the number of digits.) +func trim(a *decimal) { + for a.nd > 0 && a.d[a.nd-1] == '0' { + a.nd-- + } + if a.nd == 0 { + a.dp = 0 + } +} + +// Assign v to a. +func (a *decimal) Assign(v uint64) { + var buf [24]byte + + // Write reversed decimal in buf. + n := 0 + for v > 0 { + v1 := v / 10 + v -= 10 * v1 + buf[n] = byte(v + '0') + n++ + v = v1 + } + + // Reverse again to produce forward decimal in a.d. + a.nd = 0 + for n--; n >= 0; n-- { + a.d[a.nd] = buf[n] + a.nd++ + } + a.dp = a.nd + trim(a) +} + +// Maximum shift that we can do in one pass without overflow. +// A uint has 32 or 64 bits, and we have to be able to accommodate 9<> 63) +const maxShift = uintSize - 4 + +// Binary shift right (/ 2) by k bits. k <= maxShift to avoid overflow. +func rightShift(a *decimal, k uint) { + r := 0 // read pointer + w := 0 // write pointer + + // Pick up enough leading digits to cover first shift. + var n uint + for ; n>>k == 0; r++ { + if r >= a.nd { + if n == 0 { + // a == 0; shouldn't get here, but handle anyway. + a.nd = 0 + return + } + for n>>k == 0 { + n = n * 10 + r++ + } + break + } + c := uint(a.d[r]) + n = n*10 + c - '0' + } + a.dp -= r - 1 + + var mask uint = (1 << k) - 1 + + // Pick up a digit, put down a digit. + for ; r < a.nd; r++ { + c := uint(a.d[r]) + dig := n >> k + n &= mask + a.d[w] = byte(dig + '0') + w++ + n = n*10 + c - '0' + } + + // Put down extra digits. + for n > 0 { + dig := n >> k + n &= mask + if w < len(a.d) { + a.d[w] = byte(dig + '0') + w++ + } else if dig > 0 { + a.trunc = true + } + n = n * 10 + } + + a.nd = w + trim(a) +} + +// Cheat sheet for left shift: table indexed by shift count giving +// number of new digits that will be introduced by that shift. +// +// For example, leftcheats[4] = {2, "625"}. That means that +// if we are shifting by 4 (multiplying by 16), it will add 2 digits +// when the string prefix is "625" through "999", and one fewer digit +// if the string prefix is "000" through "624". +// +// Credit for this trick goes to Ken. + +type leftCheat struct { + delta int // number of new digits + cutoff string // minus one digit if original < a. +} + +var leftcheats = []leftCheat{ + // Leading digits of 1/2^i = 5^i. + // 5^23 is not an exact 64-bit floating point number, + // so have to use bc for the math. + // Go up to 60 to be large enough for 32bit and 64bit platforms. + /* + seq 60 | sed 's/^/5^/' | bc | + awk 'BEGIN{ print "\t{ 0, \"\" }," } + { + log2 = log(2)/log(10) + printf("\t{ %d, \"%s\" },\t// * %d\n", + int(log2*NR+1), $0, 2**NR) + }' + */ + {0, ""}, + {1, "5"}, // * 2 + {1, "25"}, // * 4 + {1, "125"}, // * 8 + {2, "625"}, // * 16 + {2, "3125"}, // * 32 + {2, "15625"}, // * 64 + {3, "78125"}, // * 128 + {3, "390625"}, // * 256 + {3, "1953125"}, // * 512 + {4, "9765625"}, // * 1024 + {4, "48828125"}, // * 2048 + {4, "244140625"}, // * 4096 + {4, "1220703125"}, // * 8192 + {5, "6103515625"}, // * 16384 + {5, "30517578125"}, // * 32768 + {5, "152587890625"}, // * 65536 + {6, "762939453125"}, // * 131072 + {6, "3814697265625"}, // * 262144 + {6, "19073486328125"}, // * 524288 + {7, "95367431640625"}, // * 1048576 + {7, "476837158203125"}, // * 2097152 + {7, "2384185791015625"}, // * 4194304 + {7, "11920928955078125"}, // * 8388608 + {8, "59604644775390625"}, // * 16777216 + {8, "298023223876953125"}, // * 33554432 + {8, "1490116119384765625"}, // * 67108864 + {9, "7450580596923828125"}, // * 134217728 + {9, "37252902984619140625"}, // * 268435456 + {9, "186264514923095703125"}, // * 536870912 + {10, "931322574615478515625"}, // * 1073741824 + {10, "4656612873077392578125"}, // * 2147483648 + {10, "23283064365386962890625"}, // * 4294967296 + {10, "116415321826934814453125"}, // * 8589934592 + {11, "582076609134674072265625"}, // * 17179869184 + {11, "2910383045673370361328125"}, // * 34359738368 + {11, "14551915228366851806640625"}, // * 68719476736 + {12, "72759576141834259033203125"}, // * 137438953472 + {12, "363797880709171295166015625"}, // * 274877906944 + {12, "1818989403545856475830078125"}, // * 549755813888 + {13, "9094947017729282379150390625"}, // * 1099511627776 + {13, "45474735088646411895751953125"}, // * 2199023255552 + {13, "227373675443232059478759765625"}, // * 4398046511104 + {13, "1136868377216160297393798828125"}, // * 8796093022208 + {14, "5684341886080801486968994140625"}, // * 17592186044416 + {14, "28421709430404007434844970703125"}, // * 35184372088832 + {14, "142108547152020037174224853515625"}, // * 70368744177664 + {15, "710542735760100185871124267578125"}, // * 140737488355328 + {15, "3552713678800500929355621337890625"}, // * 281474976710656 + {15, "17763568394002504646778106689453125"}, // * 562949953421312 + {16, "88817841970012523233890533447265625"}, // * 1125899906842624 + {16, "444089209850062616169452667236328125"}, // * 2251799813685248 + {16, "2220446049250313080847263336181640625"}, // * 4503599627370496 + {16, "11102230246251565404236316680908203125"}, // * 9007199254740992 + {17, "55511151231257827021181583404541015625"}, // * 18014398509481984 + {17, "277555756156289135105907917022705078125"}, // * 36028797018963968 + {17, "1387778780781445675529539585113525390625"}, // * 72057594037927936 + {18, "6938893903907228377647697925567626953125"}, // * 144115188075855872 + {18, "34694469519536141888238489627838134765625"}, // * 288230376151711744 + {18, "173472347597680709441192448139190673828125"}, // * 576460752303423488 + {19, "867361737988403547205962240695953369140625"}, // * 1152921504606846976 +} + +// Is the leading prefix of b lexicographically less than s? +func prefixIsLessThan(b []byte, s string) bool { + for i := 0; i < len(s); i++ { + if i >= len(b) { + return true + } + if b[i] != s[i] { + return b[i] < s[i] + } + } + return false +} + +// Binary shift left (* 2) by k bits. k <= maxShift to avoid overflow. +func leftShift(a *decimal, k uint) { + delta := leftcheats[k].delta + if prefixIsLessThan(a.d[0:a.nd], leftcheats[k].cutoff) { + delta-- + } + + r := a.nd // read index + w := a.nd + delta // write index + + // Pick up a digit, put down a digit. + var n uint + for r--; r >= 0; r-- { + n += (uint(a.d[r]) - '0') << k + quo := n / 10 + rem := n - 10*quo + w-- + if w < len(a.d) { + a.d[w] = byte(rem + '0') + } else if rem != 0 { + a.trunc = true + } + n = quo + } + + // Put down extra digits. + for n > 0 { + quo := n / 10 + rem := n - 10*quo + w-- + if w < len(a.d) { + a.d[w] = byte(rem + '0') + } else if rem != 0 { + a.trunc = true + } + n = quo + } + + a.nd += delta + if a.nd >= len(a.d) { + a.nd = len(a.d) + } + a.dp += delta + trim(a) +} + +// Binary shift left (k > 0) or right (k < 0). +func (a *decimal) Shift(k int) { + switch { + case a.nd == 0: + // nothing to do: a == 0 + case k > 0: + for k > maxShift { + leftShift(a, maxShift) + k -= maxShift + } + leftShift(a, uint(k)) + case k < 0: + for k < -maxShift { + rightShift(a, maxShift) + k += maxShift + } + rightShift(a, uint(-k)) + } +} + +// If we chop a at nd digits, should we round up? +func shouldRoundUp(a *decimal, nd int) bool { + if nd < 0 || nd >= a.nd { + return false + } + if a.d[nd] == '5' && nd+1 == a.nd { // exactly halfway - round to even + // if we truncated, a little higher than what's recorded - always round up + if a.trunc { + return true + } + return nd > 0 && (a.d[nd-1]-'0')%2 != 0 + } + // not halfway - digit tells all + return a.d[nd] >= '5' +} + +// Round a to nd digits (or fewer). +// If nd is zero, it means we're rounding +// just to the left of the digits, as in +// 0.09 -> 0.1. +func (a *decimal) Round(nd int) { + if nd < 0 || nd >= a.nd { + return + } + if shouldRoundUp(a, nd) { + a.RoundUp(nd) + } else { + a.RoundDown(nd) + } +} + +// Round a down to nd digits (or fewer). +func (a *decimal) RoundDown(nd int) { + if nd < 0 || nd >= a.nd { + return + } + a.nd = nd + trim(a) +} + +// Round a up to nd digits (or fewer). +func (a *decimal) RoundUp(nd int) { + if nd < 0 || nd >= a.nd { + return + } + + // round up + for i := nd - 1; i >= 0; i-- { + c := a.d[i] + if c < '9' { // can stop after this digit + a.d[i]++ + a.nd = i + 1 + return + } + } + + // Number is all 9s. + // Change to single 1 with adjusted decimal point. + a.d[0] = '1' + a.nd = 1 + a.dp++ +} + +// Extract integer part, rounded appropriately. +// No guarantees about overflow. +func (a *decimal) RoundedInteger() uint64 { + if a.dp > 20 { + return 0xFFFFFFFFFFFFFFFF + } + var i int + n := uint64(0) + for i = 0; i < a.dp && i < a.nd; i++ { + n = n*10 + uint64(a.d[i]-'0') + } + for ; i < a.dp; i++ { + n *= 10 + } + if shouldRoundUp(a, a.dp) { + n++ + } + return n +} diff --git a/vendor/github.com/shopspring/decimal/decimal.go b/vendor/github.com/shopspring/decimal/decimal.go new file mode 100644 index 00000000..84405ec1 --- /dev/null +++ b/vendor/github.com/shopspring/decimal/decimal.go @@ -0,0 +1,1904 @@ +// Package decimal implements an arbitrary precision fixed-point decimal. +// +// The zero-value of a Decimal is 0, as you would expect. +// +// The best way to create a new Decimal is to use decimal.NewFromString, ex: +// +// n, err := decimal.NewFromString("-123.4567") +// n.String() // output: "-123.4567" +// +// To use Decimal as part of a struct: +// +// type Struct struct { +// Number Decimal +// } +// +// Note: This can "only" represent numbers with a maximum of 2^31 digits after the decimal point. +package decimal + +import ( + "database/sql/driver" + "encoding/binary" + "fmt" + "math" + "math/big" + "regexp" + "strconv" + "strings" +) + +// DivisionPrecision is the number of decimal places in the result when it +// doesn't divide exactly. +// +// Example: +// +// d1 := decimal.NewFromFloat(2).Div(decimal.NewFromFloat(3)) +// d1.String() // output: "0.6666666666666667" +// d2 := decimal.NewFromFloat(2).Div(decimal.NewFromFloat(30000)) +// d2.String() // output: "0.0000666666666667" +// d3 := decimal.NewFromFloat(20000).Div(decimal.NewFromFloat(3)) +// d3.String() // output: "6666.6666666666666667" +// decimal.DivisionPrecision = 3 +// d4 := decimal.NewFromFloat(2).Div(decimal.NewFromFloat(3)) +// d4.String() // output: "0.667" +// +var DivisionPrecision = 16 + +// MarshalJSONWithoutQuotes should be set to true if you want the decimal to +// be JSON marshaled as a number, instead of as a string. +// WARNING: this is dangerous for decimals with many digits, since many JSON +// unmarshallers (ex: Javascript's) will unmarshal JSON numbers to IEEE 754 +// double-precision floating point numbers, which means you can potentially +// silently lose precision. +var MarshalJSONWithoutQuotes = false + +// ExpMaxIterations specifies the maximum number of iterations needed to calculate +// precise natural exponent value using ExpHullAbrham method. +var ExpMaxIterations = 1000 + +// Zero constant, to make computations faster. +// Zero should never be compared with == or != directly, please use decimal.Equal or decimal.Cmp instead. +var Zero = New(0, 1) + +var zeroInt = big.NewInt(0) +var oneInt = big.NewInt(1) +var twoInt = big.NewInt(2) +var fourInt = big.NewInt(4) +var fiveInt = big.NewInt(5) +var tenInt = big.NewInt(10) +var twentyInt = big.NewInt(20) + +var factorials = []Decimal{New(1, 0)} + +// Decimal represents a fixed-point decimal. It is immutable. +// number = value * 10 ^ exp +type Decimal struct { + value *big.Int + + // NOTE(vadim): this must be an int32, because we cast it to float64 during + // calculations. If exp is 64 bit, we might lose precision. + // If we cared about being able to represent every possible decimal, we + // could make exp a *big.Int but it would hurt performance and numbers + // like that are unrealistic. + exp int32 +} + +// New returns a new fixed-point decimal, value * 10 ^ exp. +func New(value int64, exp int32) Decimal { + return Decimal{ + value: big.NewInt(value), + exp: exp, + } +} + +// NewFromInt converts a int64 to Decimal. +// +// Example: +// +// NewFromInt(123).String() // output: "123" +// NewFromInt(-10).String() // output: "-10" +func NewFromInt(value int64) Decimal { + return Decimal{ + value: big.NewInt(value), + exp: 0, + } +} + +// NewFromInt32 converts a int32 to Decimal. +// +// Example: +// +// NewFromInt(123).String() // output: "123" +// NewFromInt(-10).String() // output: "-10" +func NewFromInt32(value int32) Decimal { + return Decimal{ + value: big.NewInt(int64(value)), + exp: 0, + } +} + +// NewFromBigInt returns a new Decimal from a big.Int, value * 10 ^ exp +func NewFromBigInt(value *big.Int, exp int32) Decimal { + return Decimal{ + value: new(big.Int).Set(value), + exp: exp, + } +} + +// NewFromString returns a new Decimal from a string representation. +// Trailing zeroes are not trimmed. +// +// Example: +// +// d, err := NewFromString("-123.45") +// d2, err := NewFromString(".0001") +// d3, err := NewFromString("1.47000") +// +func NewFromString(value string) (Decimal, error) { + originalInput := value + var intString string + var exp int64 + + // Check if number is using scientific notation + eIndex := strings.IndexAny(value, "Ee") + if eIndex != -1 { + expInt, err := strconv.ParseInt(value[eIndex+1:], 10, 32) + if err != nil { + if e, ok := err.(*strconv.NumError); ok && e.Err == strconv.ErrRange { + return Decimal{}, fmt.Errorf("can't convert %s to decimal: fractional part too long", value) + } + return Decimal{}, fmt.Errorf("can't convert %s to decimal: exponent is not numeric", value) + } + value = value[:eIndex] + exp = expInt + } + + pIndex := -1 + vLen := len(value) + for i := 0; i < vLen; i++ { + if value[i] == '.' { + if pIndex > -1 { + return Decimal{}, fmt.Errorf("can't convert %s to decimal: too many .s", value) + } + pIndex = i + } + } + + if pIndex == -1 { + // There is no decimal point, we can just parse the original string as + // an int + intString = value + } else { + if pIndex+1 < vLen { + intString = value[:pIndex] + value[pIndex+1:] + } else { + intString = value[:pIndex] + } + expInt := -len(value[pIndex+1:]) + exp += int64(expInt) + } + + var dValue *big.Int + // strconv.ParseInt is faster than new(big.Int).SetString so this is just a shortcut for strings we know won't overflow + if len(intString) <= 18 { + parsed64, err := strconv.ParseInt(intString, 10, 64) + if err != nil { + return Decimal{}, fmt.Errorf("can't convert %s to decimal", value) + } + dValue = big.NewInt(parsed64) + } else { + dValue = new(big.Int) + _, ok := dValue.SetString(intString, 10) + if !ok { + return Decimal{}, fmt.Errorf("can't convert %s to decimal", value) + } + } + + if exp < math.MinInt32 || exp > math.MaxInt32 { + // NOTE(vadim): I doubt a string could realistically be this long + return Decimal{}, fmt.Errorf("can't convert %s to decimal: fractional part too long", originalInput) + } + + return Decimal{ + value: dValue, + exp: int32(exp), + }, nil +} + +// NewFromFormattedString returns a new Decimal from a formatted string representation. +// The second argument - replRegexp, is a regular expression that is used to find characters that should be +// removed from given decimal string representation. All matched characters will be replaced with an empty string. +// +// Example: +// +// r := regexp.MustCompile("[$,]") +// d1, err := NewFromFormattedString("$5,125.99", r) +// +// r2 := regexp.MustCompile("[_]") +// d2, err := NewFromFormattedString("1_000_000", r2) +// +// r3 := regexp.MustCompile("[USD\\s]") +// d3, err := NewFromFormattedString("5000 USD", r3) +// +func NewFromFormattedString(value string, replRegexp *regexp.Regexp) (Decimal, error) { + parsedValue := replRegexp.ReplaceAllString(value, "") + d, err := NewFromString(parsedValue) + if err != nil { + return Decimal{}, err + } + return d, nil +} + +// RequireFromString returns a new Decimal from a string representation +// or panics if NewFromString would have returned an error. +// +// Example: +// +// d := RequireFromString("-123.45") +// d2 := RequireFromString(".0001") +// +func RequireFromString(value string) Decimal { + dec, err := NewFromString(value) + if err != nil { + panic(err) + } + return dec +} + +// NewFromFloat converts a float64 to Decimal. +// +// The converted number will contain the number of significant digits that can be +// represented in a float with reliable roundtrip. +// This is typically 15 digits, but may be more in some cases. +// See https://www.exploringbinary.com/decimal-precision-of-binary-floating-point-numbers/ for more information. +// +// For slightly faster conversion, use NewFromFloatWithExponent where you can specify the precision in absolute terms. +// +// NOTE: this will panic on NaN, +/-inf +func NewFromFloat(value float64) Decimal { + if value == 0 { + return New(0, 0) + } + return newFromFloat(value, math.Float64bits(value), &float64info) +} + +// NewFromFloat32 converts a float32 to Decimal. +// +// The converted number will contain the number of significant digits that can be +// represented in a float with reliable roundtrip. +// This is typically 6-8 digits depending on the input. +// See https://www.exploringbinary.com/decimal-precision-of-binary-floating-point-numbers/ for more information. +// +// For slightly faster conversion, use NewFromFloatWithExponent where you can specify the precision in absolute terms. +// +// NOTE: this will panic on NaN, +/-inf +func NewFromFloat32(value float32) Decimal { + if value == 0 { + return New(0, 0) + } + // XOR is workaround for https://github.com/golang/go/issues/26285 + a := math.Float32bits(value) ^ 0x80808080 + return newFromFloat(float64(value), uint64(a)^0x80808080, &float32info) +} + +func newFromFloat(val float64, bits uint64, flt *floatInfo) Decimal { + if math.IsNaN(val) || math.IsInf(val, 0) { + panic(fmt.Sprintf("Cannot create a Decimal from %v", val)) + } + exp := int(bits>>flt.mantbits) & (1<>(flt.expbits+flt.mantbits) != 0 + + roundShortest(&d, mant, exp, flt) + // If less than 19 digits, we can do calculation in an int64. + if d.nd < 19 { + tmp := int64(0) + m := int64(1) + for i := d.nd - 1; i >= 0; i-- { + tmp += m * int64(d.d[i]-'0') + m *= 10 + } + if d.neg { + tmp *= -1 + } + return Decimal{value: big.NewInt(tmp), exp: int32(d.dp) - int32(d.nd)} + } + dValue := new(big.Int) + dValue, ok := dValue.SetString(string(d.d[:d.nd]), 10) + if ok { + return Decimal{value: dValue, exp: int32(d.dp) - int32(d.nd)} + } + + return NewFromFloatWithExponent(val, int32(d.dp)-int32(d.nd)) +} + +// NewFromFloatWithExponent converts a float64 to Decimal, with an arbitrary +// number of fractional digits. +// +// Example: +// +// NewFromFloatWithExponent(123.456, -2).String() // output: "123.46" +// +func NewFromFloatWithExponent(value float64, exp int32) Decimal { + if math.IsNaN(value) || math.IsInf(value, 0) { + panic(fmt.Sprintf("Cannot create a Decimal from %v", value)) + } + + bits := math.Float64bits(value) + mant := bits & (1<<52 - 1) + exp2 := int32((bits >> 52) & (1<<11 - 1)) + sign := bits >> 63 + + if exp2 == 0 { + // specials + if mant == 0 { + return Decimal{} + } + // subnormal + exp2++ + } else { + // normal + mant |= 1 << 52 + } + + exp2 -= 1023 + 52 + + // normalizing base-2 values + for mant&1 == 0 { + mant = mant >> 1 + exp2++ + } + + // maximum number of fractional base-10 digits to represent 2^N exactly cannot be more than -N if N<0 + if exp < 0 && exp < exp2 { + if exp2 < 0 { + exp = exp2 + } else { + exp = 0 + } + } + + // representing 10^M * 2^N as 5^M * 2^(M+N) + exp2 -= exp + + temp := big.NewInt(1) + dMant := big.NewInt(int64(mant)) + + // applying 5^M + if exp > 0 { + temp = temp.SetInt64(int64(exp)) + temp = temp.Exp(fiveInt, temp, nil) + } else if exp < 0 { + temp = temp.SetInt64(-int64(exp)) + temp = temp.Exp(fiveInt, temp, nil) + dMant = dMant.Mul(dMant, temp) + temp = temp.SetUint64(1) + } + + // applying 2^(M+N) + if exp2 > 0 { + dMant = dMant.Lsh(dMant, uint(exp2)) + } else if exp2 < 0 { + temp = temp.Lsh(temp, uint(-exp2)) + } + + // rounding and downscaling + if exp > 0 || exp2 < 0 { + halfDown := new(big.Int).Rsh(temp, 1) + dMant = dMant.Add(dMant, halfDown) + dMant = dMant.Quo(dMant, temp) + } + + if sign == 1 { + dMant = dMant.Neg(dMant) + } + + return Decimal{ + value: dMant, + exp: exp, + } +} + +// Copy returns a copy of decimal with the same value and exponent, but a different pointer to value. +func (d Decimal) Copy() Decimal { + d.ensureInitialized() + return Decimal{ + value: &(*d.value), + exp: d.exp, + } +} + +// rescale returns a rescaled version of the decimal. Returned +// decimal may be less precise if the given exponent is bigger +// than the initial exponent of the Decimal. +// NOTE: this will truncate, NOT round +// +// Example: +// +// d := New(12345, -4) +// d2 := d.rescale(-1) +// d3 := d2.rescale(-4) +// println(d1) +// println(d2) +// println(d3) +// +// Output: +// +// 1.2345 +// 1.2 +// 1.2000 +// +func (d Decimal) rescale(exp int32) Decimal { + d.ensureInitialized() + + if d.exp == exp { + return Decimal{ + new(big.Int).Set(d.value), + d.exp, + } + } + + // NOTE(vadim): must convert exps to float64 before - to prevent overflow + diff := math.Abs(float64(exp) - float64(d.exp)) + value := new(big.Int).Set(d.value) + + expScale := new(big.Int).Exp(tenInt, big.NewInt(int64(diff)), nil) + if exp > d.exp { + value = value.Quo(value, expScale) + } else if exp < d.exp { + value = value.Mul(value, expScale) + } + + return Decimal{ + value: value, + exp: exp, + } +} + +// Abs returns the absolute value of the decimal. +func (d Decimal) Abs() Decimal { + if !d.IsNegative() { + return d + } + d.ensureInitialized() + d2Value := new(big.Int).Abs(d.value) + return Decimal{ + value: d2Value, + exp: d.exp, + } +} + +// Add returns d + d2. +func (d Decimal) Add(d2 Decimal) Decimal { + rd, rd2 := RescalePair(d, d2) + + d3Value := new(big.Int).Add(rd.value, rd2.value) + return Decimal{ + value: d3Value, + exp: rd.exp, + } +} + +// Sub returns d - d2. +func (d Decimal) Sub(d2 Decimal) Decimal { + rd, rd2 := RescalePair(d, d2) + + d3Value := new(big.Int).Sub(rd.value, rd2.value) + return Decimal{ + value: d3Value, + exp: rd.exp, + } +} + +// Neg returns -d. +func (d Decimal) Neg() Decimal { + d.ensureInitialized() + val := new(big.Int).Neg(d.value) + return Decimal{ + value: val, + exp: d.exp, + } +} + +// Mul returns d * d2. +func (d Decimal) Mul(d2 Decimal) Decimal { + d.ensureInitialized() + d2.ensureInitialized() + + expInt64 := int64(d.exp) + int64(d2.exp) + if expInt64 > math.MaxInt32 || expInt64 < math.MinInt32 { + // NOTE(vadim): better to panic than give incorrect results, as + // Decimals are usually used for money + panic(fmt.Sprintf("exponent %v overflows an int32!", expInt64)) + } + + d3Value := new(big.Int).Mul(d.value, d2.value) + return Decimal{ + value: d3Value, + exp: int32(expInt64), + } +} + +// Shift shifts the decimal in base 10. +// It shifts left when shift is positive and right if shift is negative. +// In simpler terms, the given value for shift is added to the exponent +// of the decimal. +func (d Decimal) Shift(shift int32) Decimal { + d.ensureInitialized() + return Decimal{ + value: new(big.Int).Set(d.value), + exp: d.exp + shift, + } +} + +// Div returns d / d2. If it doesn't divide exactly, the result will have +// DivisionPrecision digits after the decimal point. +func (d Decimal) Div(d2 Decimal) Decimal { + return d.DivRound(d2, int32(DivisionPrecision)) +} + +// QuoRem does divsion with remainder +// d.QuoRem(d2,precision) returns quotient q and remainder r such that +// d = d2 * q + r, q an integer multiple of 10^(-precision) +// 0 <= r < abs(d2) * 10 ^(-precision) if d>=0 +// 0 >= r > -abs(d2) * 10 ^(-precision) if d<0 +// Note that precision<0 is allowed as input. +func (d Decimal) QuoRem(d2 Decimal, precision int32) (Decimal, Decimal) { + d.ensureInitialized() + d2.ensureInitialized() + if d2.value.Sign() == 0 { + panic("decimal division by 0") + } + scale := -precision + e := int64(d.exp - d2.exp - scale) + if e > math.MaxInt32 || e < math.MinInt32 { + panic("overflow in decimal QuoRem") + } + var aa, bb, expo big.Int + var scalerest int32 + // d = a 10^ea + // d2 = b 10^eb + if e < 0 { + aa = *d.value + expo.SetInt64(-e) + bb.Exp(tenInt, &expo, nil) + bb.Mul(d2.value, &bb) + scalerest = d.exp + // now aa = a + // bb = b 10^(scale + eb - ea) + } else { + expo.SetInt64(e) + aa.Exp(tenInt, &expo, nil) + aa.Mul(d.value, &aa) + bb = *d2.value + scalerest = scale + d2.exp + // now aa = a ^ (ea - eb - scale) + // bb = b + } + var q, r big.Int + q.QuoRem(&aa, &bb, &r) + dq := Decimal{value: &q, exp: scale} + dr := Decimal{value: &r, exp: scalerest} + return dq, dr +} + +// DivRound divides and rounds to a given precision +// i.e. to an integer multiple of 10^(-precision) +// for a positive quotient digit 5 is rounded up, away from 0 +// if the quotient is negative then digit 5 is rounded down, away from 0 +// Note that precision<0 is allowed as input. +func (d Decimal) DivRound(d2 Decimal, precision int32) Decimal { + // QuoRem already checks initialization + q, r := d.QuoRem(d2, precision) + // the actual rounding decision is based on comparing r*10^precision and d2/2 + // instead compare 2 r 10 ^precision and d2 + var rv2 big.Int + rv2.Abs(r.value) + rv2.Lsh(&rv2, 1) + // now rv2 = abs(r.value) * 2 + r2 := Decimal{value: &rv2, exp: r.exp + precision} + // r2 is now 2 * r * 10 ^ precision + var c = r2.Cmp(d2.Abs()) + + if c < 0 { + return q + } + + if d.value.Sign()*d2.value.Sign() < 0 { + return q.Sub(New(1, -precision)) + } + + return q.Add(New(1, -precision)) +} + +// Mod returns d % d2. +func (d Decimal) Mod(d2 Decimal) Decimal { + quo := d.Div(d2).Truncate(0) + return d.Sub(d2.Mul(quo)) +} + +// Pow returns d to the power d2 +func (d Decimal) Pow(d2 Decimal) Decimal { + var temp Decimal + if d2.IntPart() == 0 { + return NewFromFloat(1) + } + temp = d.Pow(d2.Div(NewFromFloat(2))) + if d2.IntPart()%2 == 0 { + return temp.Mul(temp) + } + if d2.IntPart() > 0 { + return temp.Mul(temp).Mul(d) + } + return temp.Mul(temp).Div(d) +} + +// ExpHullAbrham calculates the natural exponent of decimal (e to the power of d) using Hull-Abraham algorithm. +// OverallPrecision argument specifies the overall precision of the result (integer part + decimal part). +// +// ExpHullAbrham is faster than ExpTaylor for small precision values, but it is much slower for large precision values. +// +// Example: +// +// NewFromFloat(26.1).ExpHullAbrham(2).String() // output: "220000000000" +// NewFromFloat(26.1).ExpHullAbrham(20).String() // output: "216314672147.05767284" +// +func (d Decimal) ExpHullAbrham(overallPrecision uint32) (Decimal, error) { + // Algorithm based on Variable precision exponential function. + // ACM Transactions on Mathematical Software by T. E. Hull & A. Abrham. + if d.IsZero() { + return Decimal{oneInt, 0}, nil + } + + currentPrecision := overallPrecision + + // Algorithm does not work if currentPrecision * 23 < |x|. + // Precision is automatically increased in such cases, so the value can be calculated precisely. + // If newly calculated precision is higher than ExpMaxIterations the currentPrecision will not be changed. + f := d.Abs().InexactFloat64() + if ncp := f / 23; ncp > float64(currentPrecision) && ncp < float64(ExpMaxIterations) { + currentPrecision = uint32(math.Ceil(ncp)) + } + + // fail if abs(d) beyond an over/underflow threshold + overflowThreshold := New(23*int64(currentPrecision), 0) + if d.Abs().Cmp(overflowThreshold) > 0 { + return Decimal{}, fmt.Errorf("over/underflow threshold, exp(x) cannot be calculated precisely") + } + + // Return 1 if abs(d) small enough; this also avoids later over/underflow + overflowThreshold2 := New(9, -int32(currentPrecision)-1) + if d.Abs().Cmp(overflowThreshold2) <= 0 { + return Decimal{oneInt, d.exp}, nil + } + + // t is the smallest integer >= 0 such that the corresponding abs(d/k) < 1 + t := d.exp + int32(d.NumDigits()) // Add d.NumDigits because the paper assumes that d.value [0.1, 1) + + if t < 0 { + t = 0 + } + + k := New(1, t) // reduction factor + r := Decimal{new(big.Int).Set(d.value), d.exp - t} // reduced argument + p := int32(currentPrecision) + t + 2 // precision for calculating the sum + + // Determine n, the number of therms for calculating sum + // use first Newton step (1.435p - 1.182) / log10(p/abs(r)) + // for solving appropriate equation, along with directed + // roundings and simple rational bound for log10(p/abs(r)) + rf := r.Abs().InexactFloat64() + pf := float64(p) + nf := math.Ceil((1.453*pf - 1.182) / math.Log10(pf/rf)) + if nf > float64(ExpMaxIterations) || math.IsNaN(nf) { + return Decimal{}, fmt.Errorf("exact value cannot be calculated in <=ExpMaxIterations iterations") + } + n := int64(nf) + + tmp := New(0, 0) + sum := New(1, 0) + one := New(1, 0) + for i := n - 1; i > 0; i-- { + tmp.value.SetInt64(i) + sum = sum.Mul(r.DivRound(tmp, p)) + sum = sum.Add(one) + } + + ki := k.IntPart() + res := New(1, 0) + for i := ki; i > 0; i-- { + res = res.Mul(sum) + } + + resNumDigits := int32(res.NumDigits()) + + var roundDigits int32 + if resNumDigits > abs(res.exp) { + roundDigits = int32(currentPrecision) - resNumDigits - res.exp + } else { + roundDigits = int32(currentPrecision) + } + + res = res.Round(roundDigits) + + return res, nil +} + +// ExpTaylor calculates the natural exponent of decimal (e to the power of d) using Taylor series expansion. +// Precision argument specifies how precise the result must be (number of digits after decimal point). +// Negative precision is allowed. +// +// ExpTaylor is much faster for large precision values than ExpHullAbrham. +// +// Example: +// +// d, err := NewFromFloat(26.1).ExpTaylor(2).String() +// d.String() // output: "216314672147.06" +// +// NewFromFloat(26.1).ExpTaylor(20).String() +// d.String() // output: "216314672147.05767284062928674083" +// +// NewFromFloat(26.1).ExpTaylor(-10).String() +// d.String() // output: "220000000000" +// +func (d Decimal) ExpTaylor(precision int32) (Decimal, error) { + // Note(mwoss): Implementation can be optimized by exclusively using big.Int API only + if d.IsZero() { + return Decimal{oneInt, 0}.Round(precision), nil + } + + var epsilon Decimal + var divPrecision int32 + if precision < 0 { + epsilon = New(1, -1) + divPrecision = 8 + } else { + epsilon = New(1, -precision-1) + divPrecision = precision + 1 + } + + decAbs := d.Abs() + pow := d.Abs() + factorial := New(1, 0) + + result := New(1, 0) + + for i := int64(1); ; { + step := pow.DivRound(factorial, divPrecision) + result = result.Add(step) + + // Stop Taylor series when current step is smaller than epsilon + if step.Cmp(epsilon) < 0 { + break + } + + pow = pow.Mul(decAbs) + + i++ + + // Calculate next factorial number or retrieve cached value + if len(factorials) >= int(i) && !factorials[i-1].IsZero() { + factorial = factorials[i-1] + } else { + // To avoid any race conditions, firstly the zero value is appended to a slice to create + // a spot for newly calculated factorial. After that, the zero value is replaced by calculated + // factorial using the index notation. + factorial = factorials[i-2].Mul(New(i, 0)) + factorials = append(factorials, Zero) + factorials[i-1] = factorial + } + } + + if d.Sign() < 0 { + result = New(1, 0).DivRound(result, precision+1) + } + + result = result.Round(precision) + return result, nil +} + +// NumDigits returns the number of digits of the decimal coefficient (d.Value) +// Note: Current implementation is extremely slow for large decimals and/or decimals with large fractional part +func (d Decimal) NumDigits() int { + // Note(mwoss): It can be optimized, unnecessary cast of big.Int to string + if d.IsNegative() { + return len(d.value.String()) - 1 + } + return len(d.value.String()) +} + +// IsInteger returns true when decimal can be represented as an integer value, otherwise, it returns false. +func (d Decimal) IsInteger() bool { + // The most typical case, all decimal with exponent higher or equal 0 can be represented as integer + if d.exp >= 0 { + return true + } + // When the exponent is negative we have to check every number after the decimal place + // If all of them are zeroes, we are sure that given decimal can be represented as an integer + var r big.Int + q := new(big.Int).Set(d.value) + for z := abs(d.exp); z > 0; z-- { + q.QuoRem(q, tenInt, &r) + if r.Cmp(zeroInt) != 0 { + return false + } + } + return true +} + +// Abs calculates absolute value of any int32. Used for calculating absolute value of decimal's exponent. +func abs(n int32) int32 { + if n < 0 { + return -n + } + return n +} + +// Cmp compares the numbers represented by d and d2 and returns: +// +// -1 if d < d2 +// 0 if d == d2 +// +1 if d > d2 +// +func (d Decimal) Cmp(d2 Decimal) int { + d.ensureInitialized() + d2.ensureInitialized() + + if d.exp == d2.exp { + return d.value.Cmp(d2.value) + } + + rd, rd2 := RescalePair(d, d2) + + return rd.value.Cmp(rd2.value) +} + +// Equal returns whether the numbers represented by d and d2 are equal. +func (d Decimal) Equal(d2 Decimal) bool { + return d.Cmp(d2) == 0 +} + +// Equals is deprecated, please use Equal method instead +func (d Decimal) Equals(d2 Decimal) bool { + return d.Equal(d2) +} + +// GreaterThan (GT) returns true when d is greater than d2. +func (d Decimal) GreaterThan(d2 Decimal) bool { + return d.Cmp(d2) == 1 +} + +// GreaterThanOrEqual (GTE) returns true when d is greater than or equal to d2. +func (d Decimal) GreaterThanOrEqual(d2 Decimal) bool { + cmp := d.Cmp(d2) + return cmp == 1 || cmp == 0 +} + +// LessThan (LT) returns true when d is less than d2. +func (d Decimal) LessThan(d2 Decimal) bool { + return d.Cmp(d2) == -1 +} + +// LessThanOrEqual (LTE) returns true when d is less than or equal to d2. +func (d Decimal) LessThanOrEqual(d2 Decimal) bool { + cmp := d.Cmp(d2) + return cmp == -1 || cmp == 0 +} + +// Sign returns: +// +// -1 if d < 0 +// 0 if d == 0 +// +1 if d > 0 +// +func (d Decimal) Sign() int { + if d.value == nil { + return 0 + } + return d.value.Sign() +} + +// IsPositive return +// +// true if d > 0 +// false if d == 0 +// false if d < 0 +func (d Decimal) IsPositive() bool { + return d.Sign() == 1 +} + +// IsNegative return +// +// true if d < 0 +// false if d == 0 +// false if d > 0 +func (d Decimal) IsNegative() bool { + return d.Sign() == -1 +} + +// IsZero return +// +// true if d == 0 +// false if d > 0 +// false if d < 0 +func (d Decimal) IsZero() bool { + return d.Sign() == 0 +} + +// Exponent returns the exponent, or scale component of the decimal. +func (d Decimal) Exponent() int32 { + return d.exp +} + +// Coefficient returns the coefficient of the decimal. It is scaled by 10^Exponent() +func (d Decimal) Coefficient() *big.Int { + d.ensureInitialized() + // we copy the coefficient so that mutating the result does not mutate the Decimal. + return new(big.Int).Set(d.value) +} + +// CoefficientInt64 returns the coefficient of the decimal as int64. It is scaled by 10^Exponent() +// If coefficient cannot be represented in an int64, the result will be undefined. +func (d Decimal) CoefficientInt64() int64 { + d.ensureInitialized() + return d.value.Int64() +} + +// IntPart returns the integer component of the decimal. +func (d Decimal) IntPart() int64 { + scaledD := d.rescale(0) + return scaledD.value.Int64() +} + +// BigInt returns integer component of the decimal as a BigInt. +func (d Decimal) BigInt() *big.Int { + scaledD := d.rescale(0) + i := &big.Int{} + i.SetString(scaledD.String(), 10) + return i +} + +// BigFloat returns decimal as BigFloat. +// Be aware that casting decimal to BigFloat might cause a loss of precision. +func (d Decimal) BigFloat() *big.Float { + f := &big.Float{} + f.SetString(d.String()) + return f +} + +// Rat returns a rational number representation of the decimal. +func (d Decimal) Rat() *big.Rat { + d.ensureInitialized() + if d.exp <= 0 { + // NOTE(vadim): must negate after casting to prevent int32 overflow + denom := new(big.Int).Exp(tenInt, big.NewInt(-int64(d.exp)), nil) + return new(big.Rat).SetFrac(d.value, denom) + } + + mul := new(big.Int).Exp(tenInt, big.NewInt(int64(d.exp)), nil) + num := new(big.Int).Mul(d.value, mul) + return new(big.Rat).SetFrac(num, oneInt) +} + +// Float64 returns the nearest float64 value for d and a bool indicating +// whether f represents d exactly. +// For more details, see the documentation for big.Rat.Float64 +func (d Decimal) Float64() (f float64, exact bool) { + return d.Rat().Float64() +} + +// InexactFloat64 returns the nearest float64 value for d. +// It doesn't indicate if the returned value represents d exactly. +func (d Decimal) InexactFloat64() float64 { + f, _ := d.Float64() + return f +} + +// String returns the string representation of the decimal +// with the fixed point. +// +// Example: +// +// d := New(-12345, -3) +// println(d.String()) +// +// Output: +// +// -12.345 +// +func (d Decimal) String() string { + return d.string(true) +} + +// StringFixed returns a rounded fixed-point string with places digits after +// the decimal point. +// +// Example: +// +// NewFromFloat(0).StringFixed(2) // output: "0.00" +// NewFromFloat(0).StringFixed(0) // output: "0" +// NewFromFloat(5.45).StringFixed(0) // output: "5" +// NewFromFloat(5.45).StringFixed(1) // output: "5.5" +// NewFromFloat(5.45).StringFixed(2) // output: "5.45" +// NewFromFloat(5.45).StringFixed(3) // output: "5.450" +// NewFromFloat(545).StringFixed(-1) // output: "550" +// +func (d Decimal) StringFixed(places int32) string { + rounded := d.Round(places) + return rounded.string(false) +} + +// StringFixedBank returns a banker rounded fixed-point string with places digits +// after the decimal point. +// +// Example: +// +// NewFromFloat(0).StringFixedBank(2) // output: "0.00" +// NewFromFloat(0).StringFixedBank(0) // output: "0" +// NewFromFloat(5.45).StringFixedBank(0) // output: "5" +// NewFromFloat(5.45).StringFixedBank(1) // output: "5.4" +// NewFromFloat(5.45).StringFixedBank(2) // output: "5.45" +// NewFromFloat(5.45).StringFixedBank(3) // output: "5.450" +// NewFromFloat(545).StringFixedBank(-1) // output: "540" +// +func (d Decimal) StringFixedBank(places int32) string { + rounded := d.RoundBank(places) + return rounded.string(false) +} + +// StringFixedCash returns a Swedish/Cash rounded fixed-point string. For +// more details see the documentation at function RoundCash. +func (d Decimal) StringFixedCash(interval uint8) string { + rounded := d.RoundCash(interval) + return rounded.string(false) +} + +// Round rounds the decimal to places decimal places. +// If places < 0, it will round the integer part to the nearest 10^(-places). +// +// Example: +// +// NewFromFloat(5.45).Round(1).String() // output: "5.5" +// NewFromFloat(545).Round(-1).String() // output: "550" +// +func (d Decimal) Round(places int32) Decimal { + if d.exp == -places { + return d + } + // truncate to places + 1 + ret := d.rescale(-places - 1) + + // add sign(d) * 0.5 + if ret.value.Sign() < 0 { + ret.value.Sub(ret.value, fiveInt) + } else { + ret.value.Add(ret.value, fiveInt) + } + + // floor for positive numbers, ceil for negative numbers + _, m := ret.value.DivMod(ret.value, tenInt, new(big.Int)) + ret.exp++ + if ret.value.Sign() < 0 && m.Cmp(zeroInt) != 0 { + ret.value.Add(ret.value, oneInt) + } + + return ret +} + +// RoundCeil rounds the decimal towards +infinity. +// +// Example: +// +// NewFromFloat(545).RoundCeil(-2).String() // output: "600" +// NewFromFloat(500).RoundCeil(-2).String() // output: "500" +// NewFromFloat(1.1001).RoundCeil(2).String() // output: "1.11" +// NewFromFloat(-1.454).RoundCeil(1).String() // output: "-1.5" +// +func (d Decimal) RoundCeil(places int32) Decimal { + if d.exp >= -places { + return d + } + + rescaled := d.rescale(-places) + if d.Equal(rescaled) { + return d + } + + if d.value.Sign() > 0 { + rescaled.value.Add(rescaled.value, oneInt) + } + + return rescaled +} + +// RoundFloor rounds the decimal towards -infinity. +// +// Example: +// +// NewFromFloat(545).RoundFloor(-2).String() // output: "500" +// NewFromFloat(-500).RoundFloor(-2).String() // output: "-500" +// NewFromFloat(1.1001).RoundFloor(2).String() // output: "1.1" +// NewFromFloat(-1.454).RoundFloor(1).String() // output: "-1.4" +// +func (d Decimal) RoundFloor(places int32) Decimal { + if d.exp >= -places { + return d + } + + rescaled := d.rescale(-places) + if d.Equal(rescaled) { + return d + } + + if d.value.Sign() < 0 { + rescaled.value.Sub(rescaled.value, oneInt) + } + + return rescaled +} + +// RoundUp rounds the decimal away from zero. +// +// Example: +// +// NewFromFloat(545).RoundUp(-2).String() // output: "600" +// NewFromFloat(500).RoundUp(-2).String() // output: "500" +// NewFromFloat(1.1001).RoundUp(2).String() // output: "1.11" +// NewFromFloat(-1.454).RoundUp(1).String() // output: "-1.4" +// +func (d Decimal) RoundUp(places int32) Decimal { + if d.exp >= -places { + return d + } + + rescaled := d.rescale(-places) + if d.Equal(rescaled) { + return d + } + + if d.value.Sign() > 0 { + rescaled.value.Add(rescaled.value, oneInt) + } else if d.value.Sign() < 0 { + rescaled.value.Sub(rescaled.value, oneInt) + } + + return rescaled +} + +// RoundDown rounds the decimal towards zero. +// +// Example: +// +// NewFromFloat(545).RoundDown(-2).String() // output: "500" +// NewFromFloat(-500).RoundDown(-2).String() // output: "-500" +// NewFromFloat(1.1001).RoundDown(2).String() // output: "1.1" +// NewFromFloat(-1.454).RoundDown(1).String() // output: "-1.5" +// +func (d Decimal) RoundDown(places int32) Decimal { + if d.exp >= -places { + return d + } + + rescaled := d.rescale(-places) + if d.Equal(rescaled) { + return d + } + return rescaled +} + +// RoundBank rounds the decimal to places decimal places. +// If the final digit to round is equidistant from the nearest two integers the +// rounded value is taken as the even number +// +// If places < 0, it will round the integer part to the nearest 10^(-places). +// +// Examples: +// +// NewFromFloat(5.45).RoundBank(1).String() // output: "5.4" +// NewFromFloat(545).RoundBank(-1).String() // output: "540" +// NewFromFloat(5.46).RoundBank(1).String() // output: "5.5" +// NewFromFloat(546).RoundBank(-1).String() // output: "550" +// NewFromFloat(5.55).RoundBank(1).String() // output: "5.6" +// NewFromFloat(555).RoundBank(-1).String() // output: "560" +// +func (d Decimal) RoundBank(places int32) Decimal { + + round := d.Round(places) + remainder := d.Sub(round).Abs() + + half := New(5, -places-1) + if remainder.Cmp(half) == 0 && round.value.Bit(0) != 0 { + if round.value.Sign() < 0 { + round.value.Add(round.value, oneInt) + } else { + round.value.Sub(round.value, oneInt) + } + } + + return round +} + +// RoundCash aka Cash/Penny/öre rounding rounds decimal to a specific +// interval. The amount payable for a cash transaction is rounded to the nearest +// multiple of the minimum currency unit available. The following intervals are +// available: 5, 10, 25, 50 and 100; any other number throws a panic. +// 5: 5 cent rounding 3.43 => 3.45 +// 10: 10 cent rounding 3.45 => 3.50 (5 gets rounded up) +// 25: 25 cent rounding 3.41 => 3.50 +// 50: 50 cent rounding 3.75 => 4.00 +// 100: 100 cent rounding 3.50 => 4.00 +// For more details: https://en.wikipedia.org/wiki/Cash_rounding +func (d Decimal) RoundCash(interval uint8) Decimal { + var iVal *big.Int + switch interval { + case 5: + iVal = twentyInt + case 10: + iVal = tenInt + case 25: + iVal = fourInt + case 50: + iVal = twoInt + case 100: + iVal = oneInt + default: + panic(fmt.Sprintf("Decimal does not support this Cash rounding interval `%d`. Supported: 5, 10, 25, 50, 100", interval)) + } + dVal := Decimal{ + value: iVal, + } + + // TODO: optimize those calculations to reduce the high allocations (~29 allocs). + return d.Mul(dVal).Round(0).Div(dVal).Truncate(2) +} + +// Floor returns the nearest integer value less than or equal to d. +func (d Decimal) Floor() Decimal { + d.ensureInitialized() + + if d.exp >= 0 { + return d + } + + exp := big.NewInt(10) + + // NOTE(vadim): must negate after casting to prevent int32 overflow + exp.Exp(exp, big.NewInt(-int64(d.exp)), nil) + + z := new(big.Int).Div(d.value, exp) + return Decimal{value: z, exp: 0} +} + +// Ceil returns the nearest integer value greater than or equal to d. +func (d Decimal) Ceil() Decimal { + d.ensureInitialized() + + if d.exp >= 0 { + return d + } + + exp := big.NewInt(10) + + // NOTE(vadim): must negate after casting to prevent int32 overflow + exp.Exp(exp, big.NewInt(-int64(d.exp)), nil) + + z, m := new(big.Int).DivMod(d.value, exp, new(big.Int)) + if m.Cmp(zeroInt) != 0 { + z.Add(z, oneInt) + } + return Decimal{value: z, exp: 0} +} + +// Truncate truncates off digits from the number, without rounding. +// +// NOTE: precision is the last digit that will not be truncated (must be >= 0). +// +// Example: +// +// decimal.NewFromString("123.456").Truncate(2).String() // "123.45" +// +func (d Decimal) Truncate(precision int32) Decimal { + d.ensureInitialized() + if precision >= 0 && -precision > d.exp { + return d.rescale(-precision) + } + return d +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (d *Decimal) UnmarshalJSON(decimalBytes []byte) error { + if string(decimalBytes) == "null" { + return nil + } + + str, err := unquoteIfQuoted(decimalBytes) + if err != nil { + return fmt.Errorf("error decoding string '%s': %s", decimalBytes, err) + } + + decimal, err := NewFromString(str) + *d = decimal + if err != nil { + return fmt.Errorf("error decoding string '%s': %s", str, err) + } + return nil +} + +// MarshalJSON implements the json.Marshaler interface. +func (d Decimal) MarshalJSON() ([]byte, error) { + var str string + if MarshalJSONWithoutQuotes { + str = d.String() + } else { + str = "\"" + d.String() + "\"" + } + return []byte(str), nil +} + +// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. As a string representation +// is already used when encoding to text, this method stores that string as []byte +func (d *Decimal) UnmarshalBinary(data []byte) error { + // Verify we have at least 4 bytes for the exponent. The GOB encoded value + // may be empty. + if len(data) < 4 { + return fmt.Errorf("error decoding binary %v: expected at least 4 bytes, got %d", data, len(data)) + } + + // Extract the exponent + d.exp = int32(binary.BigEndian.Uint32(data[:4])) + + // Extract the value + d.value = new(big.Int) + if err := d.value.GobDecode(data[4:]); err != nil { + return fmt.Errorf("error decoding binary %v: %s", data, err) + } + + return nil +} + +// MarshalBinary implements the encoding.BinaryMarshaler interface. +func (d Decimal) MarshalBinary() (data []byte, err error) { + // Write the exponent first since it's a fixed size + v1 := make([]byte, 4) + binary.BigEndian.PutUint32(v1, uint32(d.exp)) + + // Add the value + var v2 []byte + if v2, err = d.value.GobEncode(); err != nil { + return + } + + // Return the byte array + data = append(v1, v2...) + return +} + +// Scan implements the sql.Scanner interface for database deserialization. +func (d *Decimal) Scan(value interface{}) error { + // first try to see if the data is stored in database as a Numeric datatype + switch v := value.(type) { + + case float32: + *d = NewFromFloat(float64(v)) + return nil + + case float64: + // numeric in sqlite3 sends us float64 + *d = NewFromFloat(v) + return nil + + case int64: + // at least in sqlite3 when the value is 0 in db, the data is sent + // to us as an int64 instead of a float64 ... + *d = New(v, 0) + return nil + + default: + // default is trying to interpret value stored as string + str, err := unquoteIfQuoted(v) + if err != nil { + return err + } + *d, err = NewFromString(str) + return err + } +} + +// Value implements the driver.Valuer interface for database serialization. +func (d Decimal) Value() (driver.Value, error) { + return d.String(), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface for XML +// deserialization. +func (d *Decimal) UnmarshalText(text []byte) error { + str := string(text) + + dec, err := NewFromString(str) + *d = dec + if err != nil { + return fmt.Errorf("error decoding string '%s': %s", str, err) + } + + return nil +} + +// MarshalText implements the encoding.TextMarshaler interface for XML +// serialization. +func (d Decimal) MarshalText() (text []byte, err error) { + return []byte(d.String()), nil +} + +// GobEncode implements the gob.GobEncoder interface for gob serialization. +func (d Decimal) GobEncode() ([]byte, error) { + return d.MarshalBinary() +} + +// GobDecode implements the gob.GobDecoder interface for gob serialization. +func (d *Decimal) GobDecode(data []byte) error { + return d.UnmarshalBinary(data) +} + +// StringScaled first scales the decimal then calls .String() on it. +// NOTE: buggy, unintuitive, and DEPRECATED! Use StringFixed instead. +func (d Decimal) StringScaled(exp int32) string { + return d.rescale(exp).String() +} + +func (d Decimal) string(trimTrailingZeros bool) string { + if d.exp >= 0 { + return d.rescale(0).value.String() + } + + abs := new(big.Int).Abs(d.value) + str := abs.String() + + var intPart, fractionalPart string + + // NOTE(vadim): this cast to int will cause bugs if d.exp == INT_MIN + // and you are on a 32-bit machine. Won't fix this super-edge case. + dExpInt := int(d.exp) + if len(str) > -dExpInt { + intPart = str[:len(str)+dExpInt] + fractionalPart = str[len(str)+dExpInt:] + } else { + intPart = "0" + + num0s := -dExpInt - len(str) + fractionalPart = strings.Repeat("0", num0s) + str + } + + if trimTrailingZeros { + i := len(fractionalPart) - 1 + for ; i >= 0; i-- { + if fractionalPart[i] != '0' { + break + } + } + fractionalPart = fractionalPart[:i+1] + } + + number := intPart + if len(fractionalPart) > 0 { + number += "." + fractionalPart + } + + if d.value.Sign() < 0 { + return "-" + number + } + + return number +} + +func (d *Decimal) ensureInitialized() { + if d.value == nil { + d.value = new(big.Int) + } +} + +// Min returns the smallest Decimal that was passed in the arguments. +// +// To call this function with an array, you must do: +// +// Min(arr[0], arr[1:]...) +// +// This makes it harder to accidentally call Min with 0 arguments. +func Min(first Decimal, rest ...Decimal) Decimal { + ans := first + for _, item := range rest { + if item.Cmp(ans) < 0 { + ans = item + } + } + return ans +} + +// Max returns the largest Decimal that was passed in the arguments. +// +// To call this function with an array, you must do: +// +// Max(arr[0], arr[1:]...) +// +// This makes it harder to accidentally call Max with 0 arguments. +func Max(first Decimal, rest ...Decimal) Decimal { + ans := first + for _, item := range rest { + if item.Cmp(ans) > 0 { + ans = item + } + } + return ans +} + +// Sum returns the combined total of the provided first and rest Decimals +func Sum(first Decimal, rest ...Decimal) Decimal { + total := first + for _, item := range rest { + total = total.Add(item) + } + + return total +} + +// Avg returns the average value of the provided first and rest Decimals +func Avg(first Decimal, rest ...Decimal) Decimal { + count := New(int64(len(rest)+1), 0) + sum := Sum(first, rest...) + return sum.Div(count) +} + +// RescalePair rescales two decimals to common exponential value (minimal exp of both decimals) +func RescalePair(d1 Decimal, d2 Decimal) (Decimal, Decimal) { + d1.ensureInitialized() + d2.ensureInitialized() + + if d1.exp == d2.exp { + return d1, d2 + } + + baseScale := min(d1.exp, d2.exp) + if baseScale != d1.exp { + return d1.rescale(baseScale), d2 + } + return d1, d2.rescale(baseScale) +} + +func min(x, y int32) int32 { + if x >= y { + return y + } + return x +} + +func unquoteIfQuoted(value interface{}) (string, error) { + var bytes []byte + + switch v := value.(type) { + case string: + bytes = []byte(v) + case []byte: + bytes = v + default: + return "", fmt.Errorf("could not convert value '%+v' to byte array of type '%T'", + value, value) + } + + // If the amount is quoted, strip the quotes + if len(bytes) > 2 && bytes[0] == '"' && bytes[len(bytes)-1] == '"' { + bytes = bytes[1 : len(bytes)-1] + } + return string(bytes), nil +} + +// NullDecimal represents a nullable decimal with compatibility for +// scanning null values from the database. +type NullDecimal struct { + Decimal Decimal + Valid bool +} + +func NewNullDecimal(d Decimal) NullDecimal { + return NullDecimal{ + Decimal: d, + Valid: true, + } +} + +// Scan implements the sql.Scanner interface for database deserialization. +func (d *NullDecimal) Scan(value interface{}) error { + if value == nil { + d.Valid = false + return nil + } + d.Valid = true + return d.Decimal.Scan(value) +} + +// Value implements the driver.Valuer interface for database serialization. +func (d NullDecimal) Value() (driver.Value, error) { + if !d.Valid { + return nil, nil + } + return d.Decimal.Value() +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (d *NullDecimal) UnmarshalJSON(decimalBytes []byte) error { + if string(decimalBytes) == "null" { + d.Valid = false + return nil + } + d.Valid = true + return d.Decimal.UnmarshalJSON(decimalBytes) +} + +// MarshalJSON implements the json.Marshaler interface. +func (d NullDecimal) MarshalJSON() ([]byte, error) { + if !d.Valid { + return []byte("null"), nil + } + return d.Decimal.MarshalJSON() +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface for XML +// deserialization +func (d *NullDecimal) UnmarshalText(text []byte) error { + str := string(text) + + // check for empty XML or XML without body e.g., + if str == "" { + d.Valid = false + return nil + } + if err := d.Decimal.UnmarshalText(text); err != nil { + d.Valid = false + return err + } + d.Valid = true + return nil +} + +// MarshalText implements the encoding.TextMarshaler interface for XML +// serialization. +func (d NullDecimal) MarshalText() (text []byte, err error) { + if !d.Valid { + return []byte{}, nil + } + return d.Decimal.MarshalText() +} + +// Trig functions + +// Atan returns the arctangent, in radians, of x. +func (d Decimal) Atan() Decimal { + if d.Equal(NewFromFloat(0.0)) { + return d + } + if d.GreaterThan(NewFromFloat(0.0)) { + return d.satan() + } + return d.Neg().satan().Neg() +} + +func (d Decimal) xatan() Decimal { + P0 := NewFromFloat(-8.750608600031904122785e-01) + P1 := NewFromFloat(-1.615753718733365076637e+01) + P2 := NewFromFloat(-7.500855792314704667340e+01) + P3 := NewFromFloat(-1.228866684490136173410e+02) + P4 := NewFromFloat(-6.485021904942025371773e+01) + Q0 := NewFromFloat(2.485846490142306297962e+01) + Q1 := NewFromFloat(1.650270098316988542046e+02) + Q2 := NewFromFloat(4.328810604912902668951e+02) + Q3 := NewFromFloat(4.853903996359136964868e+02) + Q4 := NewFromFloat(1.945506571482613964425e+02) + z := d.Mul(d) + b1 := P0.Mul(z).Add(P1).Mul(z).Add(P2).Mul(z).Add(P3).Mul(z).Add(P4).Mul(z) + b2 := z.Add(Q0).Mul(z).Add(Q1).Mul(z).Add(Q2).Mul(z).Add(Q3).Mul(z).Add(Q4) + z = b1.Div(b2) + z = d.Mul(z).Add(d) + return z +} + +// satan reduces its argument (known to be positive) +// to the range [0, 0.66] and calls xatan. +func (d Decimal) satan() Decimal { + Morebits := NewFromFloat(6.123233995736765886130e-17) // pi/2 = PIO2 + Morebits + Tan3pio8 := NewFromFloat(2.41421356237309504880) // tan(3*pi/8) + pi := NewFromFloat(3.14159265358979323846264338327950288419716939937510582097494459) + + if d.LessThanOrEqual(NewFromFloat(0.66)) { + return d.xatan() + } + if d.GreaterThan(Tan3pio8) { + return pi.Div(NewFromFloat(2.0)).Sub(NewFromFloat(1.0).Div(d).xatan()).Add(Morebits) + } + return pi.Div(NewFromFloat(4.0)).Add((d.Sub(NewFromFloat(1.0)).Div(d.Add(NewFromFloat(1.0)))).xatan()).Add(NewFromFloat(0.5).Mul(Morebits)) +} + +// sin coefficients +var _sin = [...]Decimal{ + NewFromFloat(1.58962301576546568060e-10), // 0x3de5d8fd1fd19ccd + NewFromFloat(-2.50507477628578072866e-8), // 0xbe5ae5e5a9291f5d + NewFromFloat(2.75573136213857245213e-6), // 0x3ec71de3567d48a1 + NewFromFloat(-1.98412698295895385996e-4), // 0xbf2a01a019bfdf03 + NewFromFloat(8.33333333332211858878e-3), // 0x3f8111111110f7d0 + NewFromFloat(-1.66666666666666307295e-1), // 0xbfc5555555555548 +} + +// Sin returns the sine of the radian argument x. +func (d Decimal) Sin() Decimal { + PI4A := NewFromFloat(7.85398125648498535156e-1) // 0x3fe921fb40000000, Pi/4 split into three parts + PI4B := NewFromFloat(3.77489470793079817668e-8) // 0x3e64442d00000000, + PI4C := NewFromFloat(2.69515142907905952645e-15) // 0x3ce8469898cc5170, + M4PI := NewFromFloat(1.273239544735162542821171882678754627704620361328125) // 4/pi + + if d.Equal(NewFromFloat(0.0)) { + return d + } + // make argument positive but save the sign + sign := false + if d.LessThan(NewFromFloat(0.0)) { + d = d.Neg() + sign = true + } + + j := d.Mul(M4PI).IntPart() // integer part of x/(Pi/4), as integer for tests on the phase angle + y := NewFromFloat(float64(j)) // integer part of x/(Pi/4), as float + + // map zeros to origin + if j&1 == 1 { + j++ + y = y.Add(NewFromFloat(1.0)) + } + j &= 7 // octant modulo 2Pi radians (360 degrees) + // reflect in x axis + if j > 3 { + sign = !sign + j -= 4 + } + z := d.Sub(y.Mul(PI4A)).Sub(y.Mul(PI4B)).Sub(y.Mul(PI4C)) // Extended precision modular arithmetic + zz := z.Mul(z) + + if j == 1 || j == 2 { + w := zz.Mul(zz).Mul(_cos[0].Mul(zz).Add(_cos[1]).Mul(zz).Add(_cos[2]).Mul(zz).Add(_cos[3]).Mul(zz).Add(_cos[4]).Mul(zz).Add(_cos[5])) + y = NewFromFloat(1.0).Sub(NewFromFloat(0.5).Mul(zz)).Add(w) + } else { + y = z.Add(z.Mul(zz).Mul(_sin[0].Mul(zz).Add(_sin[1]).Mul(zz).Add(_sin[2]).Mul(zz).Add(_sin[3]).Mul(zz).Add(_sin[4]).Mul(zz).Add(_sin[5]))) + } + if sign { + y = y.Neg() + } + return y +} + +// cos coefficients +var _cos = [...]Decimal{ + NewFromFloat(-1.13585365213876817300e-11), // 0xbda8fa49a0861a9b + NewFromFloat(2.08757008419747316778e-9), // 0x3e21ee9d7b4e3f05 + NewFromFloat(-2.75573141792967388112e-7), // 0xbe927e4f7eac4bc6 + NewFromFloat(2.48015872888517045348e-5), // 0x3efa01a019c844f5 + NewFromFloat(-1.38888888888730564116e-3), // 0xbf56c16c16c14f91 + NewFromFloat(4.16666666666665929218e-2), // 0x3fa555555555554b +} + +// Cos returns the cosine of the radian argument x. +func (d Decimal) Cos() Decimal { + + PI4A := NewFromFloat(7.85398125648498535156e-1) // 0x3fe921fb40000000, Pi/4 split into three parts + PI4B := NewFromFloat(3.77489470793079817668e-8) // 0x3e64442d00000000, + PI4C := NewFromFloat(2.69515142907905952645e-15) // 0x3ce8469898cc5170, + M4PI := NewFromFloat(1.273239544735162542821171882678754627704620361328125) // 4/pi + + // make argument positive + sign := false + if d.LessThan(NewFromFloat(0.0)) { + d = d.Neg() + } + + j := d.Mul(M4PI).IntPart() // integer part of x/(Pi/4), as integer for tests on the phase angle + y := NewFromFloat(float64(j)) // integer part of x/(Pi/4), as float + + // map zeros to origin + if j&1 == 1 { + j++ + y = y.Add(NewFromFloat(1.0)) + } + j &= 7 // octant modulo 2Pi radians (360 degrees) + // reflect in x axis + if j > 3 { + sign = !sign + j -= 4 + } + if j > 1 { + sign = !sign + } + + z := d.Sub(y.Mul(PI4A)).Sub(y.Mul(PI4B)).Sub(y.Mul(PI4C)) // Extended precision modular arithmetic + zz := z.Mul(z) + + if j == 1 || j == 2 { + y = z.Add(z.Mul(zz).Mul(_sin[0].Mul(zz).Add(_sin[1]).Mul(zz).Add(_sin[2]).Mul(zz).Add(_sin[3]).Mul(zz).Add(_sin[4]).Mul(zz).Add(_sin[5]))) + } else { + w := zz.Mul(zz).Mul(_cos[0].Mul(zz).Add(_cos[1]).Mul(zz).Add(_cos[2]).Mul(zz).Add(_cos[3]).Mul(zz).Add(_cos[4]).Mul(zz).Add(_cos[5])) + y = NewFromFloat(1.0).Sub(NewFromFloat(0.5).Mul(zz)).Add(w) + } + if sign { + y = y.Neg() + } + return y +} + +var _tanP = [...]Decimal{ + NewFromFloat(-1.30936939181383777646e+4), // 0xc0c992d8d24f3f38 + NewFromFloat(1.15351664838587416140e+6), // 0x413199eca5fc9ddd + NewFromFloat(-1.79565251976484877988e+7), // 0xc1711fead3299176 +} +var _tanQ = [...]Decimal{ + NewFromFloat(1.00000000000000000000e+0), + NewFromFloat(1.36812963470692954678e+4), //0x40cab8a5eeb36572 + NewFromFloat(-1.32089234440210967447e+6), //0xc13427bc582abc96 + NewFromFloat(2.50083801823357915839e+7), //0x4177d98fc2ead8ef + NewFromFloat(-5.38695755929454629881e+7), //0xc189afe03cbe5a31 +} + +// Tan returns the tangent of the radian argument x. +func (d Decimal) Tan() Decimal { + + PI4A := NewFromFloat(7.85398125648498535156e-1) // 0x3fe921fb40000000, Pi/4 split into three parts + PI4B := NewFromFloat(3.77489470793079817668e-8) // 0x3e64442d00000000, + PI4C := NewFromFloat(2.69515142907905952645e-15) // 0x3ce8469898cc5170, + M4PI := NewFromFloat(1.273239544735162542821171882678754627704620361328125) // 4/pi + + if d.Equal(NewFromFloat(0.0)) { + return d + } + + // make argument positive but save the sign + sign := false + if d.LessThan(NewFromFloat(0.0)) { + d = d.Neg() + sign = true + } + + j := d.Mul(M4PI).IntPart() // integer part of x/(Pi/4), as integer for tests on the phase angle + y := NewFromFloat(float64(j)) // integer part of x/(Pi/4), as float + + // map zeros to origin + if j&1 == 1 { + j++ + y = y.Add(NewFromFloat(1.0)) + } + + z := d.Sub(y.Mul(PI4A)).Sub(y.Mul(PI4B)).Sub(y.Mul(PI4C)) // Extended precision modular arithmetic + zz := z.Mul(z) + + if zz.GreaterThan(NewFromFloat(1e-14)) { + w := zz.Mul(_tanP[0].Mul(zz).Add(_tanP[1]).Mul(zz).Add(_tanP[2])) + x := zz.Add(_tanQ[1]).Mul(zz).Add(_tanQ[2]).Mul(zz).Add(_tanQ[3]).Mul(zz).Add(_tanQ[4]) + y = z.Add(z.Mul(w.Div(x))) + } else { + y = z + } + if j&2 == 2 { + y = NewFromFloat(-1.0).Div(y) + } + if sign { + y = y.Neg() + } + return y +} diff --git a/vendor/github.com/shopspring/decimal/rounding.go b/vendor/github.com/shopspring/decimal/rounding.go new file mode 100644 index 00000000..d4b0cd00 --- /dev/null +++ b/vendor/github.com/shopspring/decimal/rounding.go @@ -0,0 +1,160 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Multiprecision decimal numbers. +// For floating-point formatting only; not general purpose. +// Only operations are assign and (binary) left/right shift. +// Can do binary floating point in multiprecision decimal precisely +// because 2 divides 10; cannot do decimal floating point +// in multiprecision binary precisely. + +package decimal + +type floatInfo struct { + mantbits uint + expbits uint + bias int +} + +var float32info = floatInfo{23, 8, -127} +var float64info = floatInfo{52, 11, -1023} + +// roundShortest rounds d (= mant * 2^exp) to the shortest number of digits +// that will let the original floating point value be precisely reconstructed. +func roundShortest(d *decimal, mant uint64, exp int, flt *floatInfo) { + // If mantissa is zero, the number is zero; stop now. + if mant == 0 { + d.nd = 0 + return + } + + // Compute upper and lower such that any decimal number + // between upper and lower (possibly inclusive) + // will round to the original floating point number. + + // We may see at once that the number is already shortest. + // + // Suppose d is not denormal, so that 2^exp <= d < 10^dp. + // The closest shorter number is at least 10^(dp-nd) away. + // The lower/upper bounds computed below are at distance + // at most 2^(exp-mantbits). + // + // So the number is already shortest if 10^(dp-nd) > 2^(exp-mantbits), + // or equivalently log2(10)*(dp-nd) > exp-mantbits. + // It is true if 332/100*(dp-nd) >= exp-mantbits (log2(10) > 3.32). + minexp := flt.bias + 1 // minimum possible exponent + if exp > minexp && 332*(d.dp-d.nd) >= 100*(exp-int(flt.mantbits)) { + // The number is already shortest. + return + } + + // d = mant << (exp - mantbits) + // Next highest floating point number is mant+1 << exp-mantbits. + // Our upper bound is halfway between, mant*2+1 << exp-mantbits-1. + upper := new(decimal) + upper.Assign(mant*2 + 1) + upper.Shift(exp - int(flt.mantbits) - 1) + + // d = mant << (exp - mantbits) + // Next lowest floating point number is mant-1 << exp-mantbits, + // unless mant-1 drops the significant bit and exp is not the minimum exp, + // in which case the next lowest is mant*2-1 << exp-mantbits-1. + // Either way, call it mantlo << explo-mantbits. + // Our lower bound is halfway between, mantlo*2+1 << explo-mantbits-1. + var mantlo uint64 + var explo int + if mant > 1<= d.nd { + break + } + li := ui - upper.dp + lower.dp + l := byte('0') // lower digit + if li >= 0 && li < lower.nd { + l = lower.d[li] + } + m := byte('0') // middle digit + if mi >= 0 { + m = d.d[mi] + } + u := byte('0') // upper digit + if ui < upper.nd { + u = upper.d[ui] + } + + // Okay to round down (truncate) if lower has a different digit + // or if lower is inclusive and is exactly the result of rounding + // down (i.e., and we have reached the final digit of lower). + okdown := l != m || inclusive && li+1 == lower.nd + + switch { + case upperdelta == 0 && m+1 < u: + // Example: + // m = 12345xxx + // u = 12347xxx + upperdelta = 2 + case upperdelta == 0 && m != u: + // Example: + // m = 12345xxx + // u = 12346xxx + upperdelta = 1 + case upperdelta == 1 && (m != '9' || u != '0'): + // Example: + // m = 1234598x + // u = 1234600x + upperdelta = 2 + } + // Okay to round up if upper has a different digit and either upper + // is inclusive or upper is bigger than the result of rounding up. + okup := upperdelta > 0 && (inclusive || upperdelta > 1 || ui+1 < upper.nd) + + // If it's okay to do either, then round to the nearest one. + // If it's okay to do only one, do it. + switch { + case okdown && okup: + d.Round(mi + 1) + return + case okdown: + d.RoundDown(mi + 1) + return + case okup: + d.RoundUp(mi + 1) + return + } + } +} diff --git a/vendor/go.opentelemetry.io/otel/LICENSE b/vendor/go.opentelemetry.io/otel/LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/go.opentelemetry.io/otel/attribute/doc.go b/vendor/go.opentelemetry.io/otel/attribute/doc.go new file mode 100644 index 00000000..dafe7424 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/attribute/doc.go @@ -0,0 +1,16 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package attribute provides key and value attributes. +package attribute // import "go.opentelemetry.io/otel/attribute" diff --git a/vendor/go.opentelemetry.io/otel/attribute/encoder.go b/vendor/go.opentelemetry.io/otel/attribute/encoder.go new file mode 100644 index 00000000..dae1d8f6 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/attribute/encoder.go @@ -0,0 +1,146 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package attribute // import "go.opentelemetry.io/otel/attribute" + +import ( + "bytes" + "sync" + "sync/atomic" +) + +type ( + // Encoder is a mechanism for serializing an attribute set into a specific + // string representation that supports caching, to avoid repeated + // serialization. An example could be an exporter encoding the attribute + // set into a wire representation. + Encoder interface { + // Encode returns the serialized encoding of the attribute set using + // its Iterator. This result may be cached by a attribute.Set. + Encode(iterator Iterator) string + + // ID returns a value that is unique for each class of attribute + // encoder. Attribute encoders allocate these using `NewEncoderID`. + ID() EncoderID + } + + // EncoderID is used to identify distinct Encoder + // implementations, for caching encoded results. + EncoderID struct { + value uint64 + } + + // defaultAttrEncoder uses a sync.Pool of buffers to reduce the number of + // allocations used in encoding attributes. This implementation encodes a + // comma-separated list of key=value, with '/'-escaping of '=', ',', and + // '\'. + defaultAttrEncoder struct { + // pool is a pool of attribute set builders. The buffers in this pool + // grow to a size that most attribute encodings will not allocate new + // memory. + pool sync.Pool // *bytes.Buffer + } +) + +// escapeChar is used to ensure uniqueness of the attribute encoding where +// keys or values contain either '=' or ','. Since there is no parser needed +// for this encoding and its only requirement is to be unique, this choice is +// arbitrary. Users will see these in some exporters (e.g., stdout), so the +// backslash ('\') is used as a conventional choice. +const escapeChar = '\\' + +var ( + _ Encoder = &defaultAttrEncoder{} + + // encoderIDCounter is for generating IDs for other attribute encoders. + encoderIDCounter uint64 + + defaultEncoderOnce sync.Once + defaultEncoderID = NewEncoderID() + defaultEncoderInstance *defaultAttrEncoder +) + +// NewEncoderID returns a unique attribute encoder ID. It should be called +// once per each type of attribute encoder. Preferably in init() or in var +// definition. +func NewEncoderID() EncoderID { + return EncoderID{value: atomic.AddUint64(&encoderIDCounter, 1)} +} + +// DefaultEncoder returns an attribute encoder that encodes attributes in such +// a way that each escaped attribute's key is followed by an equal sign and +// then by an escaped attribute's value. All key-value pairs are separated by +// a comma. +// +// Escaping is done by prepending a backslash before either a backslash, equal +// sign or a comma. +func DefaultEncoder() Encoder { + defaultEncoderOnce.Do(func() { + defaultEncoderInstance = &defaultAttrEncoder{ + pool: sync.Pool{ + New: func() interface{} { + return &bytes.Buffer{} + }, + }, + } + }) + return defaultEncoderInstance +} + +// Encode is a part of an implementation of the AttributeEncoder interface. +func (d *defaultAttrEncoder) Encode(iter Iterator) string { + buf := d.pool.Get().(*bytes.Buffer) + defer d.pool.Put(buf) + buf.Reset() + + for iter.Next() { + i, keyValue := iter.IndexedAttribute() + if i > 0 { + _, _ = buf.WriteRune(',') + } + copyAndEscape(buf, string(keyValue.Key)) + + _, _ = buf.WriteRune('=') + + if keyValue.Value.Type() == STRING { + copyAndEscape(buf, keyValue.Value.AsString()) + } else { + _, _ = buf.WriteString(keyValue.Value.Emit()) + } + } + return buf.String() +} + +// ID is a part of an implementation of the AttributeEncoder interface. +func (*defaultAttrEncoder) ID() EncoderID { + return defaultEncoderID +} + +// copyAndEscape escapes `=`, `,` and its own escape character (`\`), +// making the default encoding unique. +func copyAndEscape(buf *bytes.Buffer, val string) { + for _, ch := range val { + switch ch { + case '=', ',', escapeChar: + buf.WriteRune(escapeChar) + } + buf.WriteRune(ch) + } +} + +// Valid returns true if this encoder ID was allocated by +// `NewEncoderID`. Invalid encoder IDs will not be cached. +func (id EncoderID) Valid() bool { + return id.value != 0 +} diff --git a/vendor/go.opentelemetry.io/otel/attribute/iterator.go b/vendor/go.opentelemetry.io/otel/attribute/iterator.go new file mode 100644 index 00000000..841b271f --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/attribute/iterator.go @@ -0,0 +1,161 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package attribute // import "go.opentelemetry.io/otel/attribute" + +// Iterator allows iterating over the set of attributes in order, sorted by +// key. +type Iterator struct { + storage *Set + idx int +} + +// MergeIterator supports iterating over two sets of attributes while +// eliminating duplicate values from the combined set. The first iterator +// value takes precedence. +type MergeIterator struct { + one oneIterator + two oneIterator + current KeyValue +} + +type oneIterator struct { + iter Iterator + done bool + attr KeyValue +} + +// Next moves the iterator to the next position. Returns false if there are no +// more attributes. +func (i *Iterator) Next() bool { + i.idx++ + return i.idx < i.Len() +} + +// Label returns current KeyValue. Must be called only after Next returns +// true. +// +// Deprecated: Use Attribute instead. +func (i *Iterator) Label() KeyValue { + return i.Attribute() +} + +// Attribute returns the current KeyValue of the Iterator. It must be called +// only after Next returns true. +func (i *Iterator) Attribute() KeyValue { + kv, _ := i.storage.Get(i.idx) + return kv +} + +// IndexedLabel returns current index and attribute. Must be called only +// after Next returns true. +// +// Deprecated: Use IndexedAttribute instead. +func (i *Iterator) IndexedLabel() (int, KeyValue) { + return i.idx, i.Attribute() +} + +// IndexedAttribute returns current index and attribute. Must be called only +// after Next returns true. +func (i *Iterator) IndexedAttribute() (int, KeyValue) { + return i.idx, i.Attribute() +} + +// Len returns a number of attributes in the iterated set. +func (i *Iterator) Len() int { + return i.storage.Len() +} + +// ToSlice is a convenience function that creates a slice of attributes from +// the passed iterator. The iterator is set up to start from the beginning +// before creating the slice. +func (i *Iterator) ToSlice() []KeyValue { + l := i.Len() + if l == 0 { + return nil + } + i.idx = -1 + slice := make([]KeyValue, 0, l) + for i.Next() { + slice = append(slice, i.Attribute()) + } + return slice +} + +// NewMergeIterator returns a MergeIterator for merging two attribute sets. +// Duplicates are resolved by taking the value from the first set. +func NewMergeIterator(s1, s2 *Set) MergeIterator { + mi := MergeIterator{ + one: makeOne(s1.Iter()), + two: makeOne(s2.Iter()), + } + return mi +} + +func makeOne(iter Iterator) oneIterator { + oi := oneIterator{ + iter: iter, + } + oi.advance() + return oi +} + +func (oi *oneIterator) advance() { + if oi.done = !oi.iter.Next(); !oi.done { + oi.attr = oi.iter.Attribute() + } +} + +// Next returns true if there is another attribute available. +func (m *MergeIterator) Next() bool { + if m.one.done && m.two.done { + return false + } + if m.one.done { + m.current = m.two.attr + m.two.advance() + return true + } + if m.two.done { + m.current = m.one.attr + m.one.advance() + return true + } + if m.one.attr.Key == m.two.attr.Key { + m.current = m.one.attr // first iterator attribute value wins + m.one.advance() + m.two.advance() + return true + } + if m.one.attr.Key < m.two.attr.Key { + m.current = m.one.attr + m.one.advance() + return true + } + m.current = m.two.attr + m.two.advance() + return true +} + +// Label returns the current value after Next() returns true. +// +// Deprecated: Use Attribute instead. +func (m *MergeIterator) Label() KeyValue { + return m.current +} + +// Attribute returns the current value after Next() returns true. +func (m *MergeIterator) Attribute() KeyValue { + return m.current +} diff --git a/vendor/go.opentelemetry.io/otel/attribute/key.go b/vendor/go.opentelemetry.io/otel/attribute/key.go new file mode 100644 index 00000000..0656a04e --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/attribute/key.go @@ -0,0 +1,134 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package attribute // import "go.opentelemetry.io/otel/attribute" + +// Key represents the key part in key-value pairs. It's a string. The +// allowed character set in the key depends on the use of the key. +type Key string + +// Bool creates a KeyValue instance with a BOOL Value. +// +// If creating both a key and value at the same time, use the provided +// convenience function instead -- Bool(name, value). +func (k Key) Bool(v bool) KeyValue { + return KeyValue{ + Key: k, + Value: BoolValue(v), + } +} + +// BoolSlice creates a KeyValue instance with a BOOLSLICE Value. +// +// If creating both a key and value at the same time, use the provided +// convenience function instead -- BoolSlice(name, value). +func (k Key) BoolSlice(v []bool) KeyValue { + return KeyValue{ + Key: k, + Value: BoolSliceValue(v), + } +} + +// Int creates a KeyValue instance with an INT64 Value. +// +// If creating both a key and value at the same time, use the provided +// convenience function instead -- Int(name, value). +func (k Key) Int(v int) KeyValue { + return KeyValue{ + Key: k, + Value: IntValue(v), + } +} + +// IntSlice creates a KeyValue instance with an INT64SLICE Value. +// +// If creating both a key and value at the same time, use the provided +// convenience function instead -- IntSlice(name, value). +func (k Key) IntSlice(v []int) KeyValue { + return KeyValue{ + Key: k, + Value: IntSliceValue(v), + } +} + +// Int64 creates a KeyValue instance with an INT64 Value. +// +// If creating both a key and value at the same time, use the provided +// convenience function instead -- Int64(name, value). +func (k Key) Int64(v int64) KeyValue { + return KeyValue{ + Key: k, + Value: Int64Value(v), + } +} + +// Int64Slice creates a KeyValue instance with an INT64SLICE Value. +// +// If creating both a key and value at the same time, use the provided +// convenience function instead -- Int64Slice(name, value). +func (k Key) Int64Slice(v []int64) KeyValue { + return KeyValue{ + Key: k, + Value: Int64SliceValue(v), + } +} + +// Float64 creates a KeyValue instance with a FLOAT64 Value. +// +// If creating both a key and value at the same time, use the provided +// convenience function instead -- Float64(name, value). +func (k Key) Float64(v float64) KeyValue { + return KeyValue{ + Key: k, + Value: Float64Value(v), + } +} + +// Float64Slice creates a KeyValue instance with a FLOAT64SLICE Value. +// +// If creating both a key and value at the same time, use the provided +// convenience function instead -- Float64(name, value). +func (k Key) Float64Slice(v []float64) KeyValue { + return KeyValue{ + Key: k, + Value: Float64SliceValue(v), + } +} + +// String creates a KeyValue instance with a STRING Value. +// +// If creating both a key and value at the same time, use the provided +// convenience function instead -- String(name, value). +func (k Key) String(v string) KeyValue { + return KeyValue{ + Key: k, + Value: StringValue(v), + } +} + +// StringSlice creates a KeyValue instance with a STRINGSLICE Value. +// +// If creating both a key and value at the same time, use the provided +// convenience function instead -- StringSlice(name, value). +func (k Key) StringSlice(v []string) KeyValue { + return KeyValue{ + Key: k, + Value: StringSliceValue(v), + } +} + +// Defined returns true for non-empty keys. +func (k Key) Defined() bool { + return len(k) != 0 +} diff --git a/vendor/go.opentelemetry.io/otel/attribute/kv.go b/vendor/go.opentelemetry.io/otel/attribute/kv.go new file mode 100644 index 00000000..1ddf3ce0 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/attribute/kv.go @@ -0,0 +1,86 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package attribute // import "go.opentelemetry.io/otel/attribute" + +import ( + "fmt" +) + +// KeyValue holds a key and value pair. +type KeyValue struct { + Key Key + Value Value +} + +// Valid returns if kv is a valid OpenTelemetry attribute. +func (kv KeyValue) Valid() bool { + return kv.Key.Defined() && kv.Value.Type() != INVALID +} + +// Bool creates a KeyValue with a BOOL Value type. +func Bool(k string, v bool) KeyValue { + return Key(k).Bool(v) +} + +// BoolSlice creates a KeyValue with a BOOLSLICE Value type. +func BoolSlice(k string, v []bool) KeyValue { + return Key(k).BoolSlice(v) +} + +// Int creates a KeyValue with an INT64 Value type. +func Int(k string, v int) KeyValue { + return Key(k).Int(v) +} + +// IntSlice creates a KeyValue with an INT64SLICE Value type. +func IntSlice(k string, v []int) KeyValue { + return Key(k).IntSlice(v) +} + +// Int64 creates a KeyValue with an INT64 Value type. +func Int64(k string, v int64) KeyValue { + return Key(k).Int64(v) +} + +// Int64Slice creates a KeyValue with an INT64SLICE Value type. +func Int64Slice(k string, v []int64) KeyValue { + return Key(k).Int64Slice(v) +} + +// Float64 creates a KeyValue with a FLOAT64 Value type. +func Float64(k string, v float64) KeyValue { + return Key(k).Float64(v) +} + +// Float64Slice creates a KeyValue with a FLOAT64SLICE Value type. +func Float64Slice(k string, v []float64) KeyValue { + return Key(k).Float64Slice(v) +} + +// String creates a KeyValue with a STRING Value type. +func String(k, v string) KeyValue { + return Key(k).String(v) +} + +// StringSlice creates a KeyValue with a STRINGSLICE Value type. +func StringSlice(k string, v []string) KeyValue { + return Key(k).StringSlice(v) +} + +// Stringer creates a new key-value pair with a passed name and a string +// value generated by the passed Stringer interface. +func Stringer(k string, v fmt.Stringer) KeyValue { + return Key(k).String(v.String()) +} diff --git a/vendor/go.opentelemetry.io/otel/attribute/set.go b/vendor/go.opentelemetry.io/otel/attribute/set.go new file mode 100644 index 00000000..5c247008 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/attribute/set.go @@ -0,0 +1,424 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package attribute // import "go.opentelemetry.io/otel/attribute" + +import ( + "encoding/json" + "reflect" + "sort" +) + +type ( + // Set is the representation for a distinct attribute set. It manages an + // immutable set of attributes, with an internal cache for storing + // attribute encodings. + // + // This type supports the Equivalent method of comparison using values of + // type Distinct. + Set struct { + equivalent Distinct + } + + // Distinct wraps a variable-size array of KeyValue, constructed with keys + // in sorted order. This can be used as a map key or for equality checking + // between Sets. + Distinct struct { + iface interface{} + } + + // Filter supports removing certain attributes from attribute sets. When + // the filter returns true, the attribute will be kept in the filtered + // attribute set. When the filter returns false, the attribute is excluded + // from the filtered attribute set, and the attribute instead appears in + // the removed list of excluded attributes. + Filter func(KeyValue) bool + + // Sortable implements sort.Interface, used for sorting KeyValue. This is + // an exported type to support a memory optimization. A pointer to one of + // these is needed for the call to sort.Stable(), which the caller may + // provide in order to avoid an allocation. See NewSetWithSortable(). + Sortable []KeyValue +) + +var ( + // keyValueType is used in computeDistinctReflect. + keyValueType = reflect.TypeOf(KeyValue{}) + + // emptySet is returned for empty attribute sets. + emptySet = &Set{ + equivalent: Distinct{ + iface: [0]KeyValue{}, + }, + } +) + +// EmptySet returns a reference to a Set with no elements. +// +// This is a convenience provided for optimized calling utility. +func EmptySet() *Set { + return emptySet +} + +// reflect abbreviates reflect.ValueOf. +func (d Distinct) reflect() reflect.Value { + return reflect.ValueOf(d.iface) +} + +// Valid returns true if this value refers to a valid Set. +func (d Distinct) Valid() bool { + return d.iface != nil +} + +// Len returns the number of attributes in this set. +func (l *Set) Len() int { + if l == nil || !l.equivalent.Valid() { + return 0 + } + return l.equivalent.reflect().Len() +} + +// Get returns the KeyValue at ordered position idx in this set. +func (l *Set) Get(idx int) (KeyValue, bool) { + if l == nil { + return KeyValue{}, false + } + value := l.equivalent.reflect() + + if idx >= 0 && idx < value.Len() { + // Note: The Go compiler successfully avoids an allocation for + // the interface{} conversion here: + return value.Index(idx).Interface().(KeyValue), true + } + + return KeyValue{}, false +} + +// Value returns the value of a specified key in this set. +func (l *Set) Value(k Key) (Value, bool) { + if l == nil { + return Value{}, false + } + rValue := l.equivalent.reflect() + vlen := rValue.Len() + + idx := sort.Search(vlen, func(idx int) bool { + return rValue.Index(idx).Interface().(KeyValue).Key >= k + }) + if idx >= vlen { + return Value{}, false + } + keyValue := rValue.Index(idx).Interface().(KeyValue) + if k == keyValue.Key { + return keyValue.Value, true + } + return Value{}, false +} + +// HasValue tests whether a key is defined in this set. +func (l *Set) HasValue(k Key) bool { + if l == nil { + return false + } + _, ok := l.Value(k) + return ok +} + +// Iter returns an iterator for visiting the attributes in this set. +func (l *Set) Iter() Iterator { + return Iterator{ + storage: l, + idx: -1, + } +} + +// ToSlice returns the set of attributes belonging to this set, sorted, where +// keys appear no more than once. +func (l *Set) ToSlice() []KeyValue { + iter := l.Iter() + return iter.ToSlice() +} + +// Equivalent returns a value that may be used as a map key. The Distinct type +// guarantees that the result will equal the equivalent. Distinct value of any +// attribute set with the same elements as this, where sets are made unique by +// choosing the last value in the input for any given key. +func (l *Set) Equivalent() Distinct { + if l == nil || !l.equivalent.Valid() { + return emptySet.equivalent + } + return l.equivalent +} + +// Equals returns true if the argument set is equivalent to this set. +func (l *Set) Equals(o *Set) bool { + return l.Equivalent() == o.Equivalent() +} + +// Encoded returns the encoded form of this set, according to encoder. +func (l *Set) Encoded(encoder Encoder) string { + if l == nil || encoder == nil { + return "" + } + + return encoder.Encode(l.Iter()) +} + +func empty() Set { + return Set{ + equivalent: emptySet.equivalent, + } +} + +// NewSet returns a new Set. See the documentation for +// NewSetWithSortableFiltered for more details. +// +// Except for empty sets, this method adds an additional allocation compared +// with calls that include a Sortable. +func NewSet(kvs ...KeyValue) Set { + // Check for empty set. + if len(kvs) == 0 { + return empty() + } + s, _ := NewSetWithSortableFiltered(kvs, new(Sortable), nil) + return s +} + +// NewSetWithSortable returns a new Set. See the documentation for +// NewSetWithSortableFiltered for more details. +// +// This call includes a Sortable option as a memory optimization. +func NewSetWithSortable(kvs []KeyValue, tmp *Sortable) Set { + // Check for empty set. + if len(kvs) == 0 { + return empty() + } + s, _ := NewSetWithSortableFiltered(kvs, tmp, nil) + return s +} + +// NewSetWithFiltered returns a new Set. See the documentation for +// NewSetWithSortableFiltered for more details. +// +// This call includes a Filter to include/exclude attribute keys from the +// return value. Excluded keys are returned as a slice of attribute values. +func NewSetWithFiltered(kvs []KeyValue, filter Filter) (Set, []KeyValue) { + // Check for empty set. + if len(kvs) == 0 { + return empty(), nil + } + return NewSetWithSortableFiltered(kvs, new(Sortable), filter) +} + +// NewSetWithSortableFiltered returns a new Set. +// +// Duplicate keys are eliminated by taking the last value. This +// re-orders the input slice so that unique last-values are contiguous +// at the end of the slice. +// +// This ensures the following: +// +// - Last-value-wins semantics +// - Caller sees the reordering, but doesn't lose values +// - Repeated call preserve last-value wins. +// +// Note that methods are defined on Set, although this returns Set. Callers +// can avoid memory allocations by: +// +// - allocating a Sortable for use as a temporary in this method +// - allocating a Set for storing the return value of this constructor. +// +// The result maintains a cache of encoded attributes, by attribute.EncoderID. +// This value should not be copied after its first use. +// +// The second []KeyValue return value is a list of attributes that were +// excluded by the Filter (if non-nil). +func NewSetWithSortableFiltered(kvs []KeyValue, tmp *Sortable, filter Filter) (Set, []KeyValue) { + // Check for empty set. + if len(kvs) == 0 { + return empty(), nil + } + + *tmp = kvs + + // Stable sort so the following de-duplication can implement + // last-value-wins semantics. + sort.Stable(tmp) + + *tmp = nil + + position := len(kvs) - 1 + offset := position - 1 + + // The requirements stated above require that the stable + // result be placed in the end of the input slice, while + // overwritten values are swapped to the beginning. + // + // De-duplicate with last-value-wins semantics. Preserve + // duplicate values at the beginning of the input slice. + for ; offset >= 0; offset-- { + if kvs[offset].Key == kvs[position].Key { + continue + } + position-- + kvs[offset], kvs[position] = kvs[position], kvs[offset] + } + if filter != nil { + return filterSet(kvs[position:], filter) + } + return Set{ + equivalent: computeDistinct(kvs[position:]), + }, nil +} + +// filterSet reorders kvs so that included keys are contiguous at the end of +// the slice, while excluded keys precede the included keys. +func filterSet(kvs []KeyValue, filter Filter) (Set, []KeyValue) { + var excluded []KeyValue + + // Move attributes that do not match the filter so they're adjacent before + // calling computeDistinct(). + distinctPosition := len(kvs) + + // Swap indistinct keys forward and distinct keys toward the + // end of the slice. + offset := len(kvs) - 1 + for ; offset >= 0; offset-- { + if filter(kvs[offset]) { + distinctPosition-- + kvs[offset], kvs[distinctPosition] = kvs[distinctPosition], kvs[offset] + continue + } + } + excluded = kvs[:distinctPosition] + + return Set{ + equivalent: computeDistinct(kvs[distinctPosition:]), + }, excluded +} + +// Filter returns a filtered copy of this Set. See the documentation for +// NewSetWithSortableFiltered for more details. +func (l *Set) Filter(re Filter) (Set, []KeyValue) { + if re == nil { + return Set{ + equivalent: l.equivalent, + }, nil + } + + // Note: This could be refactored to avoid the temporary slice + // allocation, if it proves to be expensive. + return filterSet(l.ToSlice(), re) +} + +// computeDistinct returns a Distinct using either the fixed- or +// reflect-oriented code path, depending on the size of the input. The input +// slice is assumed to already be sorted and de-duplicated. +func computeDistinct(kvs []KeyValue) Distinct { + iface := computeDistinctFixed(kvs) + if iface == nil { + iface = computeDistinctReflect(kvs) + } + return Distinct{ + iface: iface, + } +} + +// computeDistinctFixed computes a Distinct for small slices. It returns nil +// if the input is too large for this code path. +func computeDistinctFixed(kvs []KeyValue) interface{} { + switch len(kvs) { + case 1: + ptr := new([1]KeyValue) + copy((*ptr)[:], kvs) + return *ptr + case 2: + ptr := new([2]KeyValue) + copy((*ptr)[:], kvs) + return *ptr + case 3: + ptr := new([3]KeyValue) + copy((*ptr)[:], kvs) + return *ptr + case 4: + ptr := new([4]KeyValue) + copy((*ptr)[:], kvs) + return *ptr + case 5: + ptr := new([5]KeyValue) + copy((*ptr)[:], kvs) + return *ptr + case 6: + ptr := new([6]KeyValue) + copy((*ptr)[:], kvs) + return *ptr + case 7: + ptr := new([7]KeyValue) + copy((*ptr)[:], kvs) + return *ptr + case 8: + ptr := new([8]KeyValue) + copy((*ptr)[:], kvs) + return *ptr + case 9: + ptr := new([9]KeyValue) + copy((*ptr)[:], kvs) + return *ptr + case 10: + ptr := new([10]KeyValue) + copy((*ptr)[:], kvs) + return *ptr + default: + return nil + } +} + +// computeDistinctReflect computes a Distinct using reflection, works for any +// size input. +func computeDistinctReflect(kvs []KeyValue) interface{} { + at := reflect.New(reflect.ArrayOf(len(kvs), keyValueType)).Elem() + for i, keyValue := range kvs { + *(at.Index(i).Addr().Interface().(*KeyValue)) = keyValue + } + return at.Interface() +} + +// MarshalJSON returns the JSON encoding of the Set. +func (l *Set) MarshalJSON() ([]byte, error) { + return json.Marshal(l.equivalent.iface) +} + +// MarshalLog is the marshaling function used by the logging system to represent this exporter. +func (l Set) MarshalLog() interface{} { + kvs := make(map[string]string) + for _, kv := range l.ToSlice() { + kvs[string(kv.Key)] = kv.Value.Emit() + } + return kvs +} + +// Len implements sort.Interface. +func (l *Sortable) Len() int { + return len(*l) +} + +// Swap implements sort.Interface. +func (l *Sortable) Swap(i, j int) { + (*l)[i], (*l)[j] = (*l)[j], (*l)[i] +} + +// Less implements sort.Interface. +func (l *Sortable) Less(i, j int) bool { + return (*l)[i].Key < (*l)[j].Key +} diff --git a/vendor/go.opentelemetry.io/otel/attribute/type_string.go b/vendor/go.opentelemetry.io/otel/attribute/type_string.go new file mode 100644 index 00000000..e584b247 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/attribute/type_string.go @@ -0,0 +1,31 @@ +// Code generated by "stringer -type=Type"; DO NOT EDIT. + +package attribute + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[INVALID-0] + _ = x[BOOL-1] + _ = x[INT64-2] + _ = x[FLOAT64-3] + _ = x[STRING-4] + _ = x[BOOLSLICE-5] + _ = x[INT64SLICE-6] + _ = x[FLOAT64SLICE-7] + _ = x[STRINGSLICE-8] +} + +const _Type_name = "INVALIDBOOLINT64FLOAT64STRINGBOOLSLICEINT64SLICEFLOAT64SLICESTRINGSLICE" + +var _Type_index = [...]uint8{0, 7, 11, 16, 23, 29, 38, 48, 60, 71} + +func (i Type) String() string { + if i < 0 || i >= Type(len(_Type_index)-1) { + return "Type(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Type_name[_Type_index[i]:_Type_index[i+1]] +} diff --git a/vendor/go.opentelemetry.io/otel/attribute/value.go b/vendor/go.opentelemetry.io/otel/attribute/value.go new file mode 100644 index 00000000..6ec5cb29 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/attribute/value.go @@ -0,0 +1,271 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package attribute // import "go.opentelemetry.io/otel/attribute" + +import ( + "encoding/json" + "fmt" + "strconv" + + "go.opentelemetry.io/otel/internal" +) + +//go:generate stringer -type=Type + +// Type describes the type of the data Value holds. +type Type int + +// Value represents the value part in key-value pairs. +type Value struct { + vtype Type + numeric uint64 + stringly string + slice interface{} +} + +const ( + // INVALID is used for a Value with no value set. + INVALID Type = iota + // BOOL is a boolean Type Value. + BOOL + // INT64 is a 64-bit signed integral Type Value. + INT64 + // FLOAT64 is a 64-bit floating point Type Value. + FLOAT64 + // STRING is a string Type Value. + STRING + // BOOLSLICE is a slice of booleans Type Value. + BOOLSLICE + // INT64SLICE is a slice of 64-bit signed integral numbers Type Value. + INT64SLICE + // FLOAT64SLICE is a slice of 64-bit floating point numbers Type Value. + FLOAT64SLICE + // STRINGSLICE is a slice of strings Type Value. + STRINGSLICE +) + +// BoolValue creates a BOOL Value. +func BoolValue(v bool) Value { + return Value{ + vtype: BOOL, + numeric: internal.BoolToRaw(v), + } +} + +// BoolSliceValue creates a BOOLSLICE Value. +func BoolSliceValue(v []bool) Value { + cp := make([]bool, len(v)) + copy(cp, v) + return Value{ + vtype: BOOLSLICE, + slice: &cp, + } +} + +// IntValue creates an INT64 Value. +func IntValue(v int) Value { + return Int64Value(int64(v)) +} + +// IntSliceValue creates an INTSLICE Value. +func IntSliceValue(v []int) Value { + cp := make([]int64, 0, len(v)) + for _, i := range v { + cp = append(cp, int64(i)) + } + return Value{ + vtype: INT64SLICE, + slice: &cp, + } +} + +// Int64Value creates an INT64 Value. +func Int64Value(v int64) Value { + return Value{ + vtype: INT64, + numeric: internal.Int64ToRaw(v), + } +} + +// Int64SliceValue creates an INT64SLICE Value. +func Int64SliceValue(v []int64) Value { + cp := make([]int64, len(v)) + copy(cp, v) + return Value{ + vtype: INT64SLICE, + slice: &cp, + } +} + +// Float64Value creates a FLOAT64 Value. +func Float64Value(v float64) Value { + return Value{ + vtype: FLOAT64, + numeric: internal.Float64ToRaw(v), + } +} + +// Float64SliceValue creates a FLOAT64SLICE Value. +func Float64SliceValue(v []float64) Value { + cp := make([]float64, len(v)) + copy(cp, v) + return Value{ + vtype: FLOAT64SLICE, + slice: &cp, + } +} + +// StringValue creates a STRING Value. +func StringValue(v string) Value { + return Value{ + vtype: STRING, + stringly: v, + } +} + +// StringSliceValue creates a STRINGSLICE Value. +func StringSliceValue(v []string) Value { + cp := make([]string, len(v)) + copy(cp, v) + return Value{ + vtype: STRINGSLICE, + slice: &cp, + } +} + +// Type returns a type of the Value. +func (v Value) Type() Type { + return v.vtype +} + +// AsBool returns the bool value. Make sure that the Value's type is +// BOOL. +func (v Value) AsBool() bool { + return internal.RawToBool(v.numeric) +} + +// AsBoolSlice returns the []bool value. Make sure that the Value's type is +// BOOLSLICE. +func (v Value) AsBoolSlice() []bool { + if s, ok := v.slice.(*[]bool); ok { + return *s + } + return nil +} + +// AsInt64 returns the int64 value. Make sure that the Value's type is +// INT64. +func (v Value) AsInt64() int64 { + return internal.RawToInt64(v.numeric) +} + +// AsInt64Slice returns the []int64 value. Make sure that the Value's type is +// INT64SLICE. +func (v Value) AsInt64Slice() []int64 { + if s, ok := v.slice.(*[]int64); ok { + return *s + } + return nil +} + +// AsFloat64 returns the float64 value. Make sure that the Value's +// type is FLOAT64. +func (v Value) AsFloat64() float64 { + return internal.RawToFloat64(v.numeric) +} + +// AsFloat64Slice returns the []float64 value. Make sure that the Value's type is +// FLOAT64SLICE. +func (v Value) AsFloat64Slice() []float64 { + if s, ok := v.slice.(*[]float64); ok { + return *s + } + return nil +} + +// AsString returns the string value. Make sure that the Value's type +// is STRING. +func (v Value) AsString() string { + return v.stringly +} + +// AsStringSlice returns the []string value. Make sure that the Value's type is +// STRINGSLICE. +func (v Value) AsStringSlice() []string { + if s, ok := v.slice.(*[]string); ok { + return *s + } + return nil +} + +type unknownValueType struct{} + +// AsInterface returns Value's data as interface{}. +func (v Value) AsInterface() interface{} { + switch v.Type() { + case BOOL: + return v.AsBool() + case BOOLSLICE: + return v.AsBoolSlice() + case INT64: + return v.AsInt64() + case INT64SLICE: + return v.AsInt64Slice() + case FLOAT64: + return v.AsFloat64() + case FLOAT64SLICE: + return v.AsFloat64Slice() + case STRING: + return v.stringly + case STRINGSLICE: + return v.AsStringSlice() + } + return unknownValueType{} +} + +// Emit returns a string representation of Value's data. +func (v Value) Emit() string { + switch v.Type() { + case BOOLSLICE: + return fmt.Sprint(*(v.slice.(*[]bool))) + case BOOL: + return strconv.FormatBool(v.AsBool()) + case INT64SLICE: + return fmt.Sprint(*(v.slice.(*[]int64))) + case INT64: + return strconv.FormatInt(v.AsInt64(), 10) + case FLOAT64SLICE: + return fmt.Sprint(*(v.slice.(*[]float64))) + case FLOAT64: + return fmt.Sprint(v.AsFloat64()) + case STRINGSLICE: + return fmt.Sprint(*(v.slice.(*[]string))) + case STRING: + return v.stringly + default: + return "unknown" + } +} + +// MarshalJSON returns the JSON encoding of the Value. +func (v Value) MarshalJSON() ([]byte, error) { + var jsonVal struct { + Type string + Value interface{} + } + jsonVal.Type = v.Type().String() + jsonVal.Value = v.AsInterface() + return json.Marshal(jsonVal) +} diff --git a/vendor/go.opentelemetry.io/otel/codes/codes.go b/vendor/go.opentelemetry.io/otel/codes/codes.go new file mode 100644 index 00000000..064a9279 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/codes/codes.go @@ -0,0 +1,106 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package codes // import "go.opentelemetry.io/otel/codes" + +import ( + "encoding/json" + "fmt" + "strconv" +) + +const ( + // Unset is the default status code. + Unset Code = 0 + // Error indicates the operation contains an error. + Error Code = 1 + // Ok indicates operation has been validated by an Application developers + // or Operator to have completed successfully, or contain no error. + Ok Code = 2 + + maxCode = 3 +) + +// Code is an 32-bit representation of a status state. +type Code uint32 + +var codeToStr = map[Code]string{ + Unset: "Unset", + Error: "Error", + Ok: "Ok", +} + +var strToCode = map[string]Code{ + `"Unset"`: Unset, + `"Error"`: Error, + `"Ok"`: Ok, +} + +// String returns the Code as a string. +func (c Code) String() string { + return codeToStr[c] +} + +// UnmarshalJSON unmarshals b into the Code. +// +// This is based on the functionality in the gRPC codes package: +// https://github.com/grpc/grpc-go/blob/bb64fee312b46ebee26be43364a7a966033521b1/codes/codes.go#L218-L244 +func (c *Code) UnmarshalJSON(b []byte) error { + // From json.Unmarshaler: By convention, to approximate the behavior of + // Unmarshal itself, Unmarshalers implement UnmarshalJSON([]byte("null")) as + // a no-op. + if string(b) == "null" { + return nil + } + if c == nil { + return fmt.Errorf("nil receiver passed to UnmarshalJSON") + } + + var x interface{} + if err := json.Unmarshal(b, &x); err != nil { + return err + } + switch x.(type) { + case string: + if jc, ok := strToCode[string(b)]; ok { + *c = jc + return nil + } + return fmt.Errorf("invalid code: %q", string(b)) + case float64: + if ci, err := strconv.ParseUint(string(b), 10, 32); err == nil { + if ci >= maxCode { + return fmt.Errorf("invalid code: %q", ci) + } + + *c = Code(ci) + return nil + } + return fmt.Errorf("invalid code: %q", string(b)) + default: + return fmt.Errorf("invalid code: %q", string(b)) + } +} + +// MarshalJSON returns c as the JSON encoding of c. +func (c *Code) MarshalJSON() ([]byte, error) { + if c == nil { + return []byte("null"), nil + } + str, ok := codeToStr[*c] + if !ok { + return nil, fmt.Errorf("invalid code: %d", *c) + } + return []byte(fmt.Sprintf("%q", str)), nil +} diff --git a/vendor/go.opentelemetry.io/otel/codes/doc.go b/vendor/go.opentelemetry.io/otel/codes/doc.go new file mode 100644 index 00000000..df3e0f1b --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/codes/doc.go @@ -0,0 +1,21 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package codes defines the canonical error codes used by OpenTelemetry. + +It conforms to [the OpenTelemetry +specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#statuscanonicalcode). +*/ +package codes // import "go.opentelemetry.io/otel/codes" diff --git a/vendor/go.opentelemetry.io/otel/internal/rawhelpers.go b/vendor/go.opentelemetry.io/otel/internal/rawhelpers.go new file mode 100644 index 00000000..ce7afaa1 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/internal/rawhelpers.go @@ -0,0 +1,55 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal // import "go.opentelemetry.io/otel/internal" + +import ( + "math" + "unsafe" +) + +func BoolToRaw(b bool) uint64 { + if b { + return 1 + } + return 0 +} + +func RawToBool(r uint64) bool { + return r != 0 +} + +func Int64ToRaw(i int64) uint64 { + return uint64(i) +} + +func RawToInt64(r uint64) int64 { + return int64(r) +} + +func Float64ToRaw(f float64) uint64 { + return math.Float64bits(f) +} + +func RawToFloat64(r uint64) float64 { + return math.Float64frombits(r) +} + +func RawPtrToFloat64Ptr(r *uint64) *float64 { + return (*float64)(unsafe.Pointer(r)) +} + +func RawPtrToInt64Ptr(r *uint64) *int64 { + return (*int64)(unsafe.Pointer(r)) +} diff --git a/vendor/go.opentelemetry.io/otel/trace/LICENSE b/vendor/go.opentelemetry.io/otel/trace/LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/trace/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/go.opentelemetry.io/otel/trace/config.go b/vendor/go.opentelemetry.io/otel/trace/config.go new file mode 100644 index 00000000..f058cc78 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/trace/config.go @@ -0,0 +1,316 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trace // import "go.opentelemetry.io/otel/trace" + +import ( + "time" + + "go.opentelemetry.io/otel/attribute" +) + +// TracerConfig is a group of options for a Tracer. +type TracerConfig struct { + instrumentationVersion string + // Schema URL of the telemetry emitted by the Tracer. + schemaURL string +} + +// InstrumentationVersion returns the version of the library providing instrumentation. +func (t *TracerConfig) InstrumentationVersion() string { + return t.instrumentationVersion +} + +// SchemaURL returns the Schema URL of the telemetry emitted by the Tracer. +func (t *TracerConfig) SchemaURL() string { + return t.schemaURL +} + +// NewTracerConfig applies all the options to a returned TracerConfig. +func NewTracerConfig(options ...TracerOption) TracerConfig { + var config TracerConfig + for _, option := range options { + config = option.apply(config) + } + return config +} + +// TracerOption applies an option to a TracerConfig. +type TracerOption interface { + apply(TracerConfig) TracerConfig +} + +type tracerOptionFunc func(TracerConfig) TracerConfig + +func (fn tracerOptionFunc) apply(cfg TracerConfig) TracerConfig { + return fn(cfg) +} + +// SpanConfig is a group of options for a Span. +type SpanConfig struct { + attributes []attribute.KeyValue + timestamp time.Time + links []Link + newRoot bool + spanKind SpanKind + stackTrace bool +} + +// Attributes describe the associated qualities of a Span. +func (cfg *SpanConfig) Attributes() []attribute.KeyValue { + return cfg.attributes +} + +// Timestamp is a time in a Span life-cycle. +func (cfg *SpanConfig) Timestamp() time.Time { + return cfg.timestamp +} + +// StackTrace checks whether stack trace capturing is enabled. +func (cfg *SpanConfig) StackTrace() bool { + return cfg.stackTrace +} + +// Links are the associations a Span has with other Spans. +func (cfg *SpanConfig) Links() []Link { + return cfg.links +} + +// NewRoot identifies a Span as the root Span for a new trace. This is +// commonly used when an existing trace crosses trust boundaries and the +// remote parent span context should be ignored for security. +func (cfg *SpanConfig) NewRoot() bool { + return cfg.newRoot +} + +// SpanKind is the role a Span has in a trace. +func (cfg *SpanConfig) SpanKind() SpanKind { + return cfg.spanKind +} + +// NewSpanStartConfig applies all the options to a returned SpanConfig. +// No validation is performed on the returned SpanConfig (e.g. no uniqueness +// checking or bounding of data), it is left to the SDK to perform this +// action. +func NewSpanStartConfig(options ...SpanStartOption) SpanConfig { + var c SpanConfig + for _, option := range options { + c = option.applySpanStart(c) + } + return c +} + +// NewSpanEndConfig applies all the options to a returned SpanConfig. +// No validation is performed on the returned SpanConfig (e.g. no uniqueness +// checking or bounding of data), it is left to the SDK to perform this +// action. +func NewSpanEndConfig(options ...SpanEndOption) SpanConfig { + var c SpanConfig + for _, option := range options { + c = option.applySpanEnd(c) + } + return c +} + +// SpanStartOption applies an option to a SpanConfig. These options are applicable +// only when the span is created. +type SpanStartOption interface { + applySpanStart(SpanConfig) SpanConfig +} + +type spanOptionFunc func(SpanConfig) SpanConfig + +func (fn spanOptionFunc) applySpanStart(cfg SpanConfig) SpanConfig { + return fn(cfg) +} + +// SpanEndOption applies an option to a SpanConfig. These options are +// applicable only when the span is ended. +type SpanEndOption interface { + applySpanEnd(SpanConfig) SpanConfig +} + +// EventConfig is a group of options for an Event. +type EventConfig struct { + attributes []attribute.KeyValue + timestamp time.Time + stackTrace bool +} + +// Attributes describe the associated qualities of an Event. +func (cfg *EventConfig) Attributes() []attribute.KeyValue { + return cfg.attributes +} + +// Timestamp is a time in an Event life-cycle. +func (cfg *EventConfig) Timestamp() time.Time { + return cfg.timestamp +} + +// StackTrace checks whether stack trace capturing is enabled. +func (cfg *EventConfig) StackTrace() bool { + return cfg.stackTrace +} + +// NewEventConfig applies all the EventOptions to a returned EventConfig. If no +// timestamp option is passed, the returned EventConfig will have a Timestamp +// set to the call time, otherwise no validation is performed on the returned +// EventConfig. +func NewEventConfig(options ...EventOption) EventConfig { + var c EventConfig + for _, option := range options { + c = option.applyEvent(c) + } + if c.timestamp.IsZero() { + c.timestamp = time.Now() + } + return c +} + +// EventOption applies span event options to an EventConfig. +type EventOption interface { + applyEvent(EventConfig) EventConfig +} + +// SpanOption are options that can be used at both the beginning and end of a span. +type SpanOption interface { + SpanStartOption + SpanEndOption +} + +// SpanStartEventOption are options that can be used at the start of a span, or with an event. +type SpanStartEventOption interface { + SpanStartOption + EventOption +} + +// SpanEndEventOption are options that can be used at the end of a span, or with an event. +type SpanEndEventOption interface { + SpanEndOption + EventOption +} + +type attributeOption []attribute.KeyValue + +func (o attributeOption) applySpan(c SpanConfig) SpanConfig { + c.attributes = append(c.attributes, []attribute.KeyValue(o)...) + return c +} +func (o attributeOption) applySpanStart(c SpanConfig) SpanConfig { return o.applySpan(c) } +func (o attributeOption) applyEvent(c EventConfig) EventConfig { + c.attributes = append(c.attributes, []attribute.KeyValue(o)...) + return c +} + +var _ SpanStartEventOption = attributeOption{} + +// WithAttributes adds the attributes related to a span life-cycle event. +// These attributes are used to describe the work a Span represents when this +// option is provided to a Span's start or end events. Otherwise, these +// attributes provide additional information about the event being recorded +// (e.g. error, state change, processing progress, system event). +// +// If multiple of these options are passed the attributes of each successive +// option will extend the attributes instead of overwriting. There is no +// guarantee of uniqueness in the resulting attributes. +func WithAttributes(attributes ...attribute.KeyValue) SpanStartEventOption { + return attributeOption(attributes) +} + +// SpanEventOption are options that can be used with an event or a span. +type SpanEventOption interface { + SpanOption + EventOption +} + +type timestampOption time.Time + +func (o timestampOption) applySpan(c SpanConfig) SpanConfig { + c.timestamp = time.Time(o) + return c +} +func (o timestampOption) applySpanStart(c SpanConfig) SpanConfig { return o.applySpan(c) } +func (o timestampOption) applySpanEnd(c SpanConfig) SpanConfig { return o.applySpan(c) } +func (o timestampOption) applyEvent(c EventConfig) EventConfig { + c.timestamp = time.Time(o) + return c +} + +var _ SpanEventOption = timestampOption{} + +// WithTimestamp sets the time of a Span or Event life-cycle moment (e.g. +// started, stopped, errored). +func WithTimestamp(t time.Time) SpanEventOption { + return timestampOption(t) +} + +type stackTraceOption bool + +func (o stackTraceOption) applyEvent(c EventConfig) EventConfig { + c.stackTrace = bool(o) + return c +} +func (o stackTraceOption) applySpan(c SpanConfig) SpanConfig { + c.stackTrace = bool(o) + return c +} +func (o stackTraceOption) applySpanEnd(c SpanConfig) SpanConfig { return o.applySpan(c) } + +// WithStackTrace sets the flag to capture the error with stack trace (e.g. true, false). +func WithStackTrace(b bool) SpanEndEventOption { + return stackTraceOption(b) +} + +// WithLinks adds links to a Span. The links are added to the existing Span +// links, i.e. this does not overwrite. Links with invalid span context are ignored. +func WithLinks(links ...Link) SpanStartOption { + return spanOptionFunc(func(cfg SpanConfig) SpanConfig { + cfg.links = append(cfg.links, links...) + return cfg + }) +} + +// WithNewRoot specifies that the Span should be treated as a root Span. Any +// existing parent span context will be ignored when defining the Span's trace +// identifiers. +func WithNewRoot() SpanStartOption { + return spanOptionFunc(func(cfg SpanConfig) SpanConfig { + cfg.newRoot = true + return cfg + }) +} + +// WithSpanKind sets the SpanKind of a Span. +func WithSpanKind(kind SpanKind) SpanStartOption { + return spanOptionFunc(func(cfg SpanConfig) SpanConfig { + cfg.spanKind = kind + return cfg + }) +} + +// WithInstrumentationVersion sets the instrumentation version. +func WithInstrumentationVersion(version string) TracerOption { + return tracerOptionFunc(func(cfg TracerConfig) TracerConfig { + cfg.instrumentationVersion = version + return cfg + }) +} + +// WithSchemaURL sets the schema URL for the Tracer. +func WithSchemaURL(schemaURL string) TracerOption { + return tracerOptionFunc(func(cfg TracerConfig) TracerConfig { + cfg.schemaURL = schemaURL + return cfg + }) +} diff --git a/vendor/go.opentelemetry.io/otel/trace/context.go b/vendor/go.opentelemetry.io/otel/trace/context.go new file mode 100644 index 00000000..76f9a083 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/trace/context.go @@ -0,0 +1,61 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trace // import "go.opentelemetry.io/otel/trace" + +import "context" + +type traceContextKeyType int + +const currentSpanKey traceContextKeyType = iota + +// ContextWithSpan returns a copy of parent with span set as the current Span. +func ContextWithSpan(parent context.Context, span Span) context.Context { + return context.WithValue(parent, currentSpanKey, span) +} + +// ContextWithSpanContext returns a copy of parent with sc as the current +// Span. The Span implementation that wraps sc is non-recording and performs +// no operations other than to return sc as the SpanContext from the +// SpanContext method. +func ContextWithSpanContext(parent context.Context, sc SpanContext) context.Context { + return ContextWithSpan(parent, nonRecordingSpan{sc: sc}) +} + +// ContextWithRemoteSpanContext returns a copy of parent with rsc set explicly +// as a remote SpanContext and as the current Span. The Span implementation +// that wraps rsc is non-recording and performs no operations other than to +// return rsc as the SpanContext from the SpanContext method. +func ContextWithRemoteSpanContext(parent context.Context, rsc SpanContext) context.Context { + return ContextWithSpanContext(parent, rsc.WithRemote(true)) +} + +// SpanFromContext returns the current Span from ctx. +// +// If no Span is currently set in ctx an implementation of a Span that +// performs no operations is returned. +func SpanFromContext(ctx context.Context) Span { + if ctx == nil { + return noopSpan{} + } + if span, ok := ctx.Value(currentSpanKey).(Span); ok { + return span + } + return noopSpan{} +} + +// SpanContextFromContext returns the current Span's SpanContext. +func SpanContextFromContext(ctx context.Context) SpanContext { + return SpanFromContext(ctx).SpanContext() +} diff --git a/vendor/go.opentelemetry.io/otel/trace/doc.go b/vendor/go.opentelemetry.io/otel/trace/doc.go new file mode 100644 index 00000000..39141771 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/trace/doc.go @@ -0,0 +1,66 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package trace provides an implementation of the tracing part of the +OpenTelemetry API. + +To participate in distributed traces a Span needs to be created for the +operation being performed as part of a traced workflow. It its simplest form: + + var tracer trace.Tracer + + func init() { + tracer = otel.Tracer("instrumentation/package/name") + } + + func operation(ctx context.Context) { + var span trace.Span + ctx, span = tracer.Start(ctx, "operation") + defer span.End() + // ... + } + +A Tracer is unique to the instrumentation and is used to create Spans. +Instrumentation should be designed to accept a TracerProvider from which it +can create its own unique Tracer. Alternatively, the registered global +TracerProvider from the go.opentelemetry.io/otel package can be used as +a default. + + const ( + name = "instrumentation/package/name" + version = "0.1.0" + ) + + type Instrumentation struct { + tracer trace.Tracer + } + + func NewInstrumentation(tp trace.TracerProvider) *Instrumentation { + if tp == nil { + tp = otel.TracerProvider() + } + return &Instrumentation{ + tracer: tp.Tracer(name, trace.WithInstrumentationVersion(version)), + } + } + + func operation(ctx context.Context, inst *Instrumentation) { + var span trace.Span + ctx, span = inst.tracer.Start(ctx, "operation") + defer span.End() + // ... + } +*/ +package trace // import "go.opentelemetry.io/otel/trace" diff --git a/vendor/go.opentelemetry.io/otel/trace/nonrecording.go b/vendor/go.opentelemetry.io/otel/trace/nonrecording.go new file mode 100644 index 00000000..88fcb816 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/trace/nonrecording.go @@ -0,0 +1,27 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trace // import "go.opentelemetry.io/otel/trace" + +// nonRecordingSpan is a minimal implementation of a Span that wraps a +// SpanContext. It performs no operations other than to return the wrapped +// SpanContext. +type nonRecordingSpan struct { + noopSpan + + sc SpanContext +} + +// SpanContext returns the wrapped SpanContext. +func (s nonRecordingSpan) SpanContext() SpanContext { return s.sc } diff --git a/vendor/go.opentelemetry.io/otel/trace/noop.go b/vendor/go.opentelemetry.io/otel/trace/noop.go new file mode 100644 index 00000000..73950f20 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/trace/noop.go @@ -0,0 +1,89 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trace // import "go.opentelemetry.io/otel/trace" + +import ( + "context" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" +) + +// NewNoopTracerProvider returns an implementation of TracerProvider that +// performs no operations. The Tracer and Spans created from the returned +// TracerProvider also perform no operations. +func NewNoopTracerProvider() TracerProvider { + return noopTracerProvider{} +} + +type noopTracerProvider struct{} + +var _ TracerProvider = noopTracerProvider{} + +// Tracer returns noop implementation of Tracer. +func (p noopTracerProvider) Tracer(string, ...TracerOption) Tracer { + return noopTracer{} +} + +// noopTracer is an implementation of Tracer that preforms no operations. +type noopTracer struct{} + +var _ Tracer = noopTracer{} + +// Start carries forward a non-recording Span, if one is present in the context, otherwise it +// creates a no-op Span. +func (t noopTracer) Start(ctx context.Context, name string, _ ...SpanStartOption) (context.Context, Span) { + span := SpanFromContext(ctx) + if _, ok := span.(nonRecordingSpan); !ok { + // span is likely already a noopSpan, but let's be sure + span = noopSpan{} + } + return ContextWithSpan(ctx, span), span +} + +// noopSpan is an implementation of Span that preforms no operations. +type noopSpan struct{} + +var _ Span = noopSpan{} + +// SpanContext returns an empty span context. +func (noopSpan) SpanContext() SpanContext { return SpanContext{} } + +// IsRecording always returns false. +func (noopSpan) IsRecording() bool { return false } + +// SetStatus does nothing. +func (noopSpan) SetStatus(codes.Code, string) {} + +// SetError does nothing. +func (noopSpan) SetError(bool) {} + +// SetAttributes does nothing. +func (noopSpan) SetAttributes(...attribute.KeyValue) {} + +// End does nothing. +func (noopSpan) End(...SpanEndOption) {} + +// RecordError does nothing. +func (noopSpan) RecordError(error, ...EventOption) {} + +// AddEvent does nothing. +func (noopSpan) AddEvent(string, ...EventOption) {} + +// SetName does nothing. +func (noopSpan) SetName(string) {} + +// TracerProvider returns a no-op TracerProvider. +func (noopSpan) TracerProvider() TracerProvider { return noopTracerProvider{} } diff --git a/vendor/go.opentelemetry.io/otel/trace/trace.go b/vendor/go.opentelemetry.io/otel/trace/trace.go new file mode 100644 index 00000000..1bc040c2 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/trace/trace.go @@ -0,0 +1,519 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trace // import "go.opentelemetry.io/otel/trace" + +import ( + "bytes" + "context" + "encoding/hex" + "encoding/json" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" +) + +const ( + // FlagsSampled is a bitmask with the sampled bit set. A SpanContext + // with the sampling bit set means the span is sampled. + FlagsSampled = TraceFlags(0x01) + + errInvalidHexID errorConst = "trace-id and span-id can only contain [0-9a-f] characters, all lowercase" + + errInvalidTraceIDLength errorConst = "hex encoded trace-id must have length equals to 32" + errNilTraceID errorConst = "trace-id can't be all zero" + + errInvalidSpanIDLength errorConst = "hex encoded span-id must have length equals to 16" + errNilSpanID errorConst = "span-id can't be all zero" +) + +type errorConst string + +func (e errorConst) Error() string { + return string(e) +} + +// TraceID is a unique identity of a trace. +// nolint:revive // revive complains about stutter of `trace.TraceID`. +type TraceID [16]byte + +var nilTraceID TraceID +var _ json.Marshaler = nilTraceID + +// IsValid checks whether the trace TraceID is valid. A valid trace ID does +// not consist of zeros only. +func (t TraceID) IsValid() bool { + return !bytes.Equal(t[:], nilTraceID[:]) +} + +// MarshalJSON implements a custom marshal function to encode TraceID +// as a hex string. +func (t TraceID) MarshalJSON() ([]byte, error) { + return json.Marshal(t.String()) +} + +// String returns the hex string representation form of a TraceID. +func (t TraceID) String() string { + return hex.EncodeToString(t[:]) +} + +// SpanID is a unique identity of a span in a trace. +type SpanID [8]byte + +var nilSpanID SpanID +var _ json.Marshaler = nilSpanID + +// IsValid checks whether the SpanID is valid. A valid SpanID does not consist +// of zeros only. +func (s SpanID) IsValid() bool { + return !bytes.Equal(s[:], nilSpanID[:]) +} + +// MarshalJSON implements a custom marshal function to encode SpanID +// as a hex string. +func (s SpanID) MarshalJSON() ([]byte, error) { + return json.Marshal(s.String()) +} + +// String returns the hex string representation form of a SpanID. +func (s SpanID) String() string { + return hex.EncodeToString(s[:]) +} + +// TraceIDFromHex returns a TraceID from a hex string if it is compliant with +// the W3C trace-context specification. See more at +// https://www.w3.org/TR/trace-context/#trace-id +// nolint:revive // revive complains about stutter of `trace.TraceIDFromHex`. +func TraceIDFromHex(h string) (TraceID, error) { + t := TraceID{} + if len(h) != 32 { + return t, errInvalidTraceIDLength + } + + if err := decodeHex(h, t[:]); err != nil { + return t, err + } + + if !t.IsValid() { + return t, errNilTraceID + } + return t, nil +} + +// SpanIDFromHex returns a SpanID from a hex string if it is compliant +// with the w3c trace-context specification. +// See more at https://www.w3.org/TR/trace-context/#parent-id +func SpanIDFromHex(h string) (SpanID, error) { + s := SpanID{} + if len(h) != 16 { + return s, errInvalidSpanIDLength + } + + if err := decodeHex(h, s[:]); err != nil { + return s, err + } + + if !s.IsValid() { + return s, errNilSpanID + } + return s, nil +} + +func decodeHex(h string, b []byte) error { + for _, r := range h { + switch { + case 'a' <= r && r <= 'f': + continue + case '0' <= r && r <= '9': + continue + default: + return errInvalidHexID + } + } + + decoded, err := hex.DecodeString(h) + if err != nil { + return err + } + + copy(b, decoded) + return nil +} + +// TraceFlags contains flags that can be set on a SpanContext. +type TraceFlags byte //nolint:revive // revive complains about stutter of `trace.TraceFlags`. + +// IsSampled returns if the sampling bit is set in the TraceFlags. +func (tf TraceFlags) IsSampled() bool { + return tf&FlagsSampled == FlagsSampled +} + +// WithSampled sets the sampling bit in a new copy of the TraceFlags. +func (tf TraceFlags) WithSampled(sampled bool) TraceFlags { + if sampled { + return tf | FlagsSampled + } + + return tf &^ FlagsSampled +} + +// MarshalJSON implements a custom marshal function to encode TraceFlags +// as a hex string. +func (tf TraceFlags) MarshalJSON() ([]byte, error) { + return json.Marshal(tf.String()) +} + +// String returns the hex string representation form of TraceFlags. +func (tf TraceFlags) String() string { + return hex.EncodeToString([]byte{byte(tf)}[:]) +} + +// SpanContextConfig contains mutable fields usable for constructing +// an immutable SpanContext. +type SpanContextConfig struct { + TraceID TraceID + SpanID SpanID + TraceFlags TraceFlags + TraceState TraceState + Remote bool +} + +// NewSpanContext constructs a SpanContext using values from the provided +// SpanContextConfig. +func NewSpanContext(config SpanContextConfig) SpanContext { + return SpanContext{ + traceID: config.TraceID, + spanID: config.SpanID, + traceFlags: config.TraceFlags, + traceState: config.TraceState, + remote: config.Remote, + } +} + +// SpanContext contains identifying trace information about a Span. +type SpanContext struct { + traceID TraceID + spanID SpanID + traceFlags TraceFlags + traceState TraceState + remote bool +} + +var _ json.Marshaler = SpanContext{} + +// IsValid returns if the SpanContext is valid. A valid span context has a +// valid TraceID and SpanID. +func (sc SpanContext) IsValid() bool { + return sc.HasTraceID() && sc.HasSpanID() +} + +// IsRemote indicates whether the SpanContext represents a remotely-created Span. +func (sc SpanContext) IsRemote() bool { + return sc.remote +} + +// WithRemote returns a copy of sc with the Remote property set to remote. +func (sc SpanContext) WithRemote(remote bool) SpanContext { + return SpanContext{ + traceID: sc.traceID, + spanID: sc.spanID, + traceFlags: sc.traceFlags, + traceState: sc.traceState, + remote: remote, + } +} + +// TraceID returns the TraceID from the SpanContext. +func (sc SpanContext) TraceID() TraceID { + return sc.traceID +} + +// HasTraceID checks if the SpanContext has a valid TraceID. +func (sc SpanContext) HasTraceID() bool { + return sc.traceID.IsValid() +} + +// WithTraceID returns a new SpanContext with the TraceID replaced. +func (sc SpanContext) WithTraceID(traceID TraceID) SpanContext { + return SpanContext{ + traceID: traceID, + spanID: sc.spanID, + traceFlags: sc.traceFlags, + traceState: sc.traceState, + remote: sc.remote, + } +} + +// SpanID returns the SpanID from the SpanContext. +func (sc SpanContext) SpanID() SpanID { + return sc.spanID +} + +// HasSpanID checks if the SpanContext has a valid SpanID. +func (sc SpanContext) HasSpanID() bool { + return sc.spanID.IsValid() +} + +// WithSpanID returns a new SpanContext with the SpanID replaced. +func (sc SpanContext) WithSpanID(spanID SpanID) SpanContext { + return SpanContext{ + traceID: sc.traceID, + spanID: spanID, + traceFlags: sc.traceFlags, + traceState: sc.traceState, + remote: sc.remote, + } +} + +// TraceFlags returns the flags from the SpanContext. +func (sc SpanContext) TraceFlags() TraceFlags { + return sc.traceFlags +} + +// IsSampled returns if the sampling bit is set in the SpanContext's TraceFlags. +func (sc SpanContext) IsSampled() bool { + return sc.traceFlags.IsSampled() +} + +// WithTraceFlags returns a new SpanContext with the TraceFlags replaced. +func (sc SpanContext) WithTraceFlags(flags TraceFlags) SpanContext { + return SpanContext{ + traceID: sc.traceID, + spanID: sc.spanID, + traceFlags: flags, + traceState: sc.traceState, + remote: sc.remote, + } +} + +// TraceState returns the TraceState from the SpanContext. +func (sc SpanContext) TraceState() TraceState { + return sc.traceState +} + +// WithTraceState returns a new SpanContext with the TraceState replaced. +func (sc SpanContext) WithTraceState(state TraceState) SpanContext { + return SpanContext{ + traceID: sc.traceID, + spanID: sc.spanID, + traceFlags: sc.traceFlags, + traceState: state, + remote: sc.remote, + } +} + +// Equal is a predicate that determines whether two SpanContext values are equal. +func (sc SpanContext) Equal(other SpanContext) bool { + return sc.traceID == other.traceID && + sc.spanID == other.spanID && + sc.traceFlags == other.traceFlags && + sc.traceState.String() == other.traceState.String() && + sc.remote == other.remote +} + +// MarshalJSON implements a custom marshal function to encode a SpanContext. +func (sc SpanContext) MarshalJSON() ([]byte, error) { + return json.Marshal(SpanContextConfig{ + TraceID: sc.traceID, + SpanID: sc.spanID, + TraceFlags: sc.traceFlags, + TraceState: sc.traceState, + Remote: sc.remote, + }) +} + +// Span is the individual component of a trace. It represents a single named +// and timed operation of a workflow that is traced. A Tracer is used to +// create a Span and it is then up to the operation the Span represents to +// properly end the Span when the operation itself ends. +// +// Warning: methods may be added to this interface in minor releases. +type Span interface { + // End completes the Span. The Span is considered complete and ready to be + // delivered through the rest of the telemetry pipeline after this method + // is called. Therefore, updates to the Span are not allowed after this + // method has been called. + End(options ...SpanEndOption) + + // AddEvent adds an event with the provided name and options. + AddEvent(name string, options ...EventOption) + + // IsRecording returns the recording state of the Span. It will return + // true if the Span is active and events can be recorded. + IsRecording() bool + + // RecordError will record err as an exception span event for this span. An + // additional call to SetStatus is required if the Status of the Span should + // be set to Error, as this method does not change the Span status. If this + // span is not being recorded or err is nil then this method does nothing. + RecordError(err error, options ...EventOption) + + // SpanContext returns the SpanContext of the Span. The returned SpanContext + // is usable even after the End method has been called for the Span. + SpanContext() SpanContext + + // SetStatus sets the status of the Span in the form of a code and a + // description, overriding previous values set. The description is only + // included in a status when the code is for an error. + SetStatus(code codes.Code, description string) + + // SetName sets the Span name. + SetName(name string) + + // SetAttributes sets kv as attributes of the Span. If a key from kv + // already exists for an attribute of the Span it will be overwritten with + // the value contained in kv. + SetAttributes(kv ...attribute.KeyValue) + + // TracerProvider returns a TracerProvider that can be used to generate + // additional Spans on the same telemetry pipeline as the current Span. + TracerProvider() TracerProvider +} + +// Link is the relationship between two Spans. The relationship can be within +// the same Trace or across different Traces. +// +// For example, a Link is used in the following situations: +// +// 1. Batch Processing: A batch of operations may contain operations +// associated with one or more traces/spans. Since there can only be one +// parent SpanContext, a Link is used to keep reference to the +// SpanContext of all operations in the batch. +// 2. Public Endpoint: A SpanContext for an in incoming client request on a +// public endpoint should be considered untrusted. In such a case, a new +// trace with its own identity and sampling decision needs to be created, +// but this new trace needs to be related to the original trace in some +// form. A Link is used to keep reference to the original SpanContext and +// track the relationship. +type Link struct { + // SpanContext of the linked Span. + SpanContext SpanContext + + // Attributes describe the aspects of the link. + Attributes []attribute.KeyValue +} + +// LinkFromContext returns a link encapsulating the SpanContext in the provided ctx. +func LinkFromContext(ctx context.Context, attrs ...attribute.KeyValue) Link { + return Link{ + SpanContext: SpanContextFromContext(ctx), + Attributes: attrs, + } +} + +// SpanKind is the role a Span plays in a Trace. +type SpanKind int + +// As a convenience, these match the proto definition, see +// https://github.com/open-telemetry/opentelemetry-proto/blob/30d237e1ff3ab7aa50e0922b5bebdd93505090af/opentelemetry/proto/trace/v1/trace.proto#L101-L129 +// +// The unspecified value is not a valid `SpanKind`. Use `ValidateSpanKind()` +// to coerce a span kind to a valid value. +const ( + // SpanKindUnspecified is an unspecified SpanKind and is not a valid + // SpanKind. SpanKindUnspecified should be replaced with SpanKindInternal + // if it is received. + SpanKindUnspecified SpanKind = 0 + // SpanKindInternal is a SpanKind for a Span that represents an internal + // operation within an application. + SpanKindInternal SpanKind = 1 + // SpanKindServer is a SpanKind for a Span that represents the operation + // of handling a request from a client. + SpanKindServer SpanKind = 2 + // SpanKindClient is a SpanKind for a Span that represents the operation + // of client making a request to a server. + SpanKindClient SpanKind = 3 + // SpanKindProducer is a SpanKind for a Span that represents the operation + // of a producer sending a message to a message broker. Unlike + // SpanKindClient and SpanKindServer, there is often no direct + // relationship between this kind of Span and a SpanKindConsumer kind. A + // SpanKindProducer Span will end once the message is accepted by the + // message broker which might not overlap with the processing of that + // message. + SpanKindProducer SpanKind = 4 + // SpanKindConsumer is a SpanKind for a Span that represents the operation + // of a consumer receiving a message from a message broker. Like + // SpanKindProducer Spans, there is often no direct relationship between + // this Span and the Span that produced the message. + SpanKindConsumer SpanKind = 5 +) + +// ValidateSpanKind returns a valid span kind value. This will coerce +// invalid values into the default value, SpanKindInternal. +func ValidateSpanKind(spanKind SpanKind) SpanKind { + switch spanKind { + case SpanKindInternal, + SpanKindServer, + SpanKindClient, + SpanKindProducer, + SpanKindConsumer: + // valid + return spanKind + default: + return SpanKindInternal + } +} + +// String returns the specified name of the SpanKind in lower-case. +func (sk SpanKind) String() string { + switch sk { + case SpanKindInternal: + return "internal" + case SpanKindServer: + return "server" + case SpanKindClient: + return "client" + case SpanKindProducer: + return "producer" + case SpanKindConsumer: + return "consumer" + default: + return "unspecified" + } +} + +// Tracer is the creator of Spans. +// +// Warning: methods may be added to this interface in minor releases. +type Tracer interface { + // Start creates a span and a context.Context containing the newly-created span. + // + // If the context.Context provided in `ctx` contains a Span then the newly-created + // Span will be a child of that span, otherwise it will be a root span. This behavior + // can be overridden by providing `WithNewRoot()` as a SpanOption, causing the + // newly-created Span to be a root span even if `ctx` contains a Span. + // + // When creating a Span it is recommended to provide all known span attributes using + // the `WithAttributes()` SpanOption as samplers will only have access to the + // attributes provided when a Span is created. + // + // Any Span that is created MUST also be ended. This is the responsibility of the user. + // Implementations of this API may leak memory or other resources if Spans are not ended. + Start(ctx context.Context, spanName string, opts ...SpanStartOption) (context.Context, Span) +} + +// TracerProvider provides access to instrumentation Tracers. +// +// Warning: methods may be added to this interface in minor releases. +type TracerProvider interface { + // Tracer creates an implementation of the Tracer interface. + // The instrumentationName must be the name of the library providing + // instrumentation. This name may be the same as the instrumented code + // only if that code provides built-in instrumentation. If the + // instrumentationName is empty, then a implementation defined default + // name will be used instead. + // + // This method must be concurrency safe. + Tracer(instrumentationName string, opts ...TracerOption) Tracer +} diff --git a/vendor/go.opentelemetry.io/otel/trace/tracestate.go b/vendor/go.opentelemetry.io/otel/trace/tracestate.go new file mode 100644 index 00000000..7b7af695 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/trace/tracestate.go @@ -0,0 +1,211 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trace // import "go.opentelemetry.io/otel/trace" + +import ( + "encoding/json" + "fmt" + "regexp" + "strings" +) + +var ( + maxListMembers = 32 + + listDelimiter = "," + + // based on the W3C Trace Context specification, see + // https://www.w3.org/TR/trace-context-1/#tracestate-header + noTenantKeyFormat = `[a-z][_0-9a-z\-\*\/]{0,255}` + withTenantKeyFormat = `[a-z0-9][_0-9a-z\-\*\/]{0,240}@[a-z][_0-9a-z\-\*\/]{0,13}` + valueFormat = `[\x20-\x2b\x2d-\x3c\x3e-\x7e]{0,255}[\x21-\x2b\x2d-\x3c\x3e-\x7e]` + + keyRe = regexp.MustCompile(`^((` + noTenantKeyFormat + `)|(` + withTenantKeyFormat + `))$`) + valueRe = regexp.MustCompile(`^(` + valueFormat + `)$`) + memberRe = regexp.MustCompile(`^\s*((` + noTenantKeyFormat + `)|(` + withTenantKeyFormat + `))=(` + valueFormat + `)\s*$`) + + errInvalidKey errorConst = "invalid tracestate key" + errInvalidValue errorConst = "invalid tracestate value" + errInvalidMember errorConst = "invalid tracestate list-member" + errMemberNumber errorConst = "too many list-members in tracestate" + errDuplicate errorConst = "duplicate list-member in tracestate" +) + +type member struct { + Key string + Value string +} + +func newMember(key, value string) (member, error) { + if !keyRe.MatchString(key) { + return member{}, fmt.Errorf("%w: %s", errInvalidKey, key) + } + if !valueRe.MatchString(value) { + return member{}, fmt.Errorf("%w: %s", errInvalidValue, value) + } + return member{Key: key, Value: value}, nil +} + +func parseMember(m string) (member, error) { + matches := memberRe.FindStringSubmatch(m) + if len(matches) != 5 { + return member{}, fmt.Errorf("%w: %s", errInvalidMember, m) + } + + return member{ + Key: matches[1], + Value: matches[4], + }, nil + +} + +// String encodes member into a string compliant with the W3C Trace Context +// specification. +func (m member) String() string { + return fmt.Sprintf("%s=%s", m.Key, m.Value) +} + +// TraceState provides additional vendor-specific trace identification +// information across different distributed tracing systems. It represents an +// immutable list consisting of key/value pairs, each pair is referred to as a +// list-member. +// +// TraceState conforms to the W3C Trace Context specification +// (https://www.w3.org/TR/trace-context-1). All operations that create or copy +// a TraceState do so by validating all input and will only produce TraceState +// that conform to the specification. Specifically, this means that all +// list-member's key/value pairs are valid, no duplicate list-members exist, +// and the maximum number of list-members (32) is not exceeded. +type TraceState struct { //nolint:revive // revive complains about stutter of `trace.TraceState` + // list is the members in order. + list []member +} + +var _ json.Marshaler = TraceState{} + +// ParseTraceState attempts to decode a TraceState from the passed +// string. It returns an error if the input is invalid according to the W3C +// Trace Context specification. +func ParseTraceState(tracestate string) (TraceState, error) { + if tracestate == "" { + return TraceState{}, nil + } + + wrapErr := func(err error) error { + return fmt.Errorf("failed to parse tracestate: %w", err) + } + + var members []member + found := make(map[string]struct{}) + for _, memberStr := range strings.Split(tracestate, listDelimiter) { + if len(memberStr) == 0 { + continue + } + + m, err := parseMember(memberStr) + if err != nil { + return TraceState{}, wrapErr(err) + } + + if _, ok := found[m.Key]; ok { + return TraceState{}, wrapErr(errDuplicate) + } + found[m.Key] = struct{}{} + + members = append(members, m) + if n := len(members); n > maxListMembers { + return TraceState{}, wrapErr(errMemberNumber) + } + } + + return TraceState{list: members}, nil +} + +// MarshalJSON marshals the TraceState into JSON. +func (ts TraceState) MarshalJSON() ([]byte, error) { + return json.Marshal(ts.String()) +} + +// String encodes the TraceState into a string compliant with the W3C +// Trace Context specification. The returned string will be invalid if the +// TraceState contains any invalid members. +func (ts TraceState) String() string { + members := make([]string, len(ts.list)) + for i, m := range ts.list { + members[i] = m.String() + } + return strings.Join(members, listDelimiter) +} + +// Get returns the value paired with key from the corresponding TraceState +// list-member if it exists, otherwise an empty string is returned. +func (ts TraceState) Get(key string) string { + for _, member := range ts.list { + if member.Key == key { + return member.Value + } + } + + return "" +} + +// Insert adds a new list-member defined by the key/value pair to the +// TraceState. If a list-member already exists for the given key, that +// list-member's value is updated. The new or updated list-member is always +// moved to the beginning of the TraceState as specified by the W3C Trace +// Context specification. +// +// If key or value are invalid according to the W3C Trace Context +// specification an error is returned with the original TraceState. +// +// If adding a new list-member means the TraceState would have more members +// then is allowed, the new list-member will be inserted and the right-most +// list-member will be dropped in the returned TraceState. +func (ts TraceState) Insert(key, value string) (TraceState, error) { + m, err := newMember(key, value) + if err != nil { + return ts, err + } + + cTS := ts.Delete(key) + if cTS.Len()+1 <= maxListMembers { + cTS.list = append(cTS.list, member{}) + } + // When the number of members exceeds capacity, drop the "right-most". + copy(cTS.list[1:], cTS.list) + cTS.list[0] = m + + return cTS, nil +} + +// Delete returns a copy of the TraceState with the list-member identified by +// key removed. +func (ts TraceState) Delete(key string) TraceState { + members := make([]member, ts.Len()) + copy(members, ts.list) + for i, member := range ts.list { + if member.Key == key { + members = append(members[:i], members[i+1:]...) + // TraceState should contain no duplicate members. + break + } + } + return TraceState{list: members} +} + +// Len returns the number of list-members in the TraceState. +func (ts TraceState) Len() int { + return len(ts.list) +} diff --git a/vendor/golang.org/x/sys/unix/asm_linux_loong64.s b/vendor/golang.org/x/sys/unix/asm_linux_loong64.s new file mode 100644 index 00000000..6abd48ee --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_linux_loong64.s @@ -0,0 +1,54 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && loong64 && gc +// +build linux +// +build loong64 +// +build gc + +#include "textflag.h" + + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + JMP syscall·Syscall6(SB) + +TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 + JAL runtime·entersyscall(SB) + MOVV a1+8(FP), R4 + MOVV a2+16(FP), R5 + MOVV a3+24(FP), R6 + MOVV R0, R7 + MOVV R0, R8 + MOVV R0, R9 + MOVV trap+0(FP), R11 // syscall entry + SYSCALL + MOVV R4, r1+32(FP) + MOVV R5, r2+40(FP) + JAL runtime·exitsyscall(SB) + RET + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + JMP syscall·RawSyscall6(SB) + +TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 + MOVV a1+8(FP), R4 + MOVV a2+16(FP), R5 + MOVV a3+24(FP), R6 + MOVV R0, R7 + MOVV R0, R8 + MOVV R0, R9 + MOVV trap+0(FP), R11 // syscall entry + SYSCALL + MOVV R4, r1+32(FP) + MOVV R5, r2+40(FP) + RET diff --git a/vendor/golang.org/x/sys/unix/endian_little.go b/vendor/golang.org/x/sys/unix/endian_little.go index 4362f47e..b0f2bc4a 100644 --- a/vendor/golang.org/x/sys/unix/endian_little.go +++ b/vendor/golang.org/x/sys/unix/endian_little.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // -//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh -// +build 386 amd64 amd64p32 alpha arm arm64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh +//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh +// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh package unix diff --git a/vendor/golang.org/x/sys/unix/ioctl_linux.go b/vendor/golang.org/x/sys/unix/ioctl_linux.go index 1dadead2..884430b8 100644 --- a/vendor/golang.org/x/sys/unix/ioctl_linux.go +++ b/vendor/golang.org/x/sys/unix/ioctl_linux.go @@ -194,3 +194,26 @@ func ioctlIfreqData(fd int, req uint, value *ifreqData) error { // identical so pass *IfreqData directly. return ioctlPtr(fd, req, unsafe.Pointer(value)) } + +// IoctlKCMClone attaches a new file descriptor to a multiplexor by cloning an +// existing KCM socket, returning a structure containing the file descriptor of +// the new socket. +func IoctlKCMClone(fd int) (*KCMClone, error) { + var info KCMClone + if err := ioctlPtr(fd, SIOCKCMCLONE, unsafe.Pointer(&info)); err != nil { + return nil, err + } + + return &info, nil +} + +// IoctlKCMAttach attaches a TCP socket and associated BPF program file +// descriptor to a multiplexor. +func IoctlKCMAttach(fd int, info KCMAttach) error { + return ioctlPtr(fd, SIOCKCMATTACH, unsafe.Pointer(&info)) +} + +// IoctlKCMUnattach unattaches a TCP socket file descriptor from a multiplexor. +func IoctlKCMUnattach(fd int, info KCMUnattach) error { + return ioctlPtr(fd, SIOCKCMUNATTACH, unsafe.Pointer(&info)) +} diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index a47b035f..d888fb77 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -205,6 +205,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -214,6 +215,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -231,6 +233,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -503,6 +506,7 @@ ccflags="$@" $2 ~ /^O?XTABS$/ || $2 ~ /^TC[IO](ON|OFF)$/ || $2 ~ /^IN_/ || + $2 ~ /^KCM/ || $2 ~ /^LANDLOCK_/ || $2 ~ /^LOCK_(SH|EX|NB|UN)$/ || $2 ~ /^LO_(KEY|NAME)_SIZE$/ || @@ -597,8 +601,10 @@ ccflags="$@" $2 ~ /^DEVLINK_/ || $2 ~ /^ETHTOOL_/ || $2 ~ /^LWTUNNEL_IP/ || + $2 ~ /^ITIMER_/ || $2 !~ "WMESGLEN" && $2 ~ /^W[A-Z0-9]+$/ || + $2 ~ /^P_/ || $2 ~/^PPPIOC/ || $2 ~ /^FAN_|FANOTIFY_/ || $2 == "HID_MAX_DESCRIPTOR_SIZE" || @@ -608,6 +614,7 @@ ccflags="$@" $2 ~ /^OTP/ || $2 ~ /^MEM/ || $2 ~ /^WG/ || + $2 ~ /^FIB_RULE_/ || $2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)} $2 ~ /^__WCOREFLAG$/ {next} $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)} diff --git a/vendor/golang.org/x/sys/unix/syscall_aix.go b/vendor/golang.org/x/sys/unix/syscall_aix.go index 4f55c8d9..ad22c33d 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix.go @@ -37,6 +37,7 @@ func Creat(path string, mode uint32) (fd int, err error) { } //sys utimes(path string, times *[2]Timeval) (err error) + func Utimes(path string, tv []Timeval) error { if len(tv) != 2 { return EINVAL @@ -45,6 +46,7 @@ func Utimes(path string, tv []Timeval) error { } //sys utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error) + func UtimesNano(path string, ts []Timespec) error { if len(ts) != 2 { return EINVAL @@ -215,18 +217,12 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) { return } -func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { +func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn int, recvflags int, err error) { // Recvmsg not implemented on AIX - sa := new(SockaddrUnix) - return -1, -1, -1, sa, ENOSYS -} - -func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { - _, err = SendmsgN(fd, p, oob, to, flags) - return + return -1, -1, -1, ENOSYS } -func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { +func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags int) (n int, err error) { // SendmsgN not implemented on AIX return -1, ENOSYS } @@ -306,11 +302,13 @@ func direntNamlen(buf []byte) (uint64, bool) { } //sys getdirent(fd int, buf []byte) (n int, err error) + func Getdents(fd int, buf []byte) (n int, err error) { return getdirent(fd, buf) } //sys wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, err error) + func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { var status _C_int var r Pid_t @@ -378,6 +376,7 @@ func (w WaitStatus) TrapCause() int { return -1 } //sys fcntl(fd int, cmd int, arg int) (val int, err error) //sys fsyncRange(fd int, how int, start int64, length int64) (err error) = fsync_range + func Fsync(fd int) error { return fsyncRange(fd, O_SYNC, 0, 0) } @@ -458,8 +457,8 @@ func Fsync(fd int) error { //sys Listen(s int, n int) (err error) //sys lstat(path string, stat *Stat_t) (err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = pread64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = pwrite64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = pread64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = pwrite64 //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) //sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) //sysnb Setregid(rgid int, egid int) (err error) @@ -542,6 +541,7 @@ func Poll(fds []PollFd, timeout int) (n int, err error) { //sys Getsystemcfg(label int) (n uint64) //sys umount(target string) (err error) + func Unmount(target string, flags int) (err error) { if flags != 0 { // AIX doesn't have any flags for umount. diff --git a/vendor/golang.org/x/sys/unix/syscall_bsd.go b/vendor/golang.org/x/sys/unix/syscall_bsd.go index 0ce45232..9c87c5f0 100644 --- a/vendor/golang.org/x/sys/unix/syscall_bsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_bsd.go @@ -325,10 +325,9 @@ func GetsockoptString(fd, level, opt int) (string, error) { //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) -func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { +func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn int, recvflags int, err error) { var msg Msghdr - var rsa RawSockaddrAny - msg.Name = (*byte)(unsafe.Pointer(&rsa)) + msg.Name = (*byte)(unsafe.Pointer(rsa)) msg.Namelen = uint32(SizeofSockaddrAny) var iov Iovec if len(p) > 0 { @@ -352,29 +351,12 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from } oobn = int(msg.Controllen) recvflags = int(msg.Flags) - // source address is only specified if the socket is unconnected - if rsa.Addr.Family != AF_UNSPEC { - from, err = anyToSockaddr(fd, &rsa) - } return } //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) -func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { - _, err = SendmsgN(fd, p, oob, to, flags) - return -} - -func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { - var ptr unsafe.Pointer - var salen _Socklen - if to != nil { - ptr, salen, err = to.sockaddr() - if err != nil { - return 0, err - } - } +func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags int) (n int, err error) { var msg Msghdr msg.Name = (*byte)(unsafe.Pointer(ptr)) msg.Namelen = uint32(salen) @@ -571,12 +553,7 @@ func UtimesNano(path string, ts []Timespec) error { if len(ts) != 2 { return EINVAL } - // Darwin setattrlist can set nanosecond timestamps - err := setattrlistTimes(path, ts, 0) - if err != ENOSYS { - return err - } - err = utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) + err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) if err != ENOSYS { return err } @@ -596,10 +573,6 @@ func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error { if len(ts) != 2 { return EINVAL } - err := setattrlistTimes(path, ts, flags) - if err != ENOSYS { - return err - } return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags) } diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index 0eaab913..09a25c65 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -141,16 +141,6 @@ func direntNamlen(buf []byte) (uint64, bool) { func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) } func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) } -type attrList struct { - bitmapCount uint16 - _ uint16 - CommonAttr uint32 - VolAttr uint32 - DirAttr uint32 - FileAttr uint32 - Forkattr uint32 -} - //sysnb pipe(p *[2]int32) (err error) func Pipe(p []int) (err error) { @@ -282,36 +272,7 @@ func Flistxattr(fd int, dest []byte) (sz int, err error) { return flistxattr(fd, xattrPointer(dest), len(dest), 0) } -func setattrlistTimes(path string, times []Timespec, flags int) error { - _p0, err := BytePtrFromString(path) - if err != nil { - return err - } - - var attrList attrList - attrList.bitmapCount = ATTR_BIT_MAP_COUNT - attrList.CommonAttr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME - - // order is mtime, atime: the opposite of Chtimes - attributes := [2]Timespec{times[1], times[0]} - options := 0 - if flags&AT_SYMLINK_NOFOLLOW != 0 { - options |= FSOPT_NOFOLLOW - } - return setattrlist( - _p0, - unsafe.Pointer(&attrList), - unsafe.Pointer(&attributes), - unsafe.Sizeof(attributes), - options) -} - -//sys setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) - -func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error { - // Darwin doesn't support SYS_UTIMENSAT - return ENOSYS -} +//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) /* * Wrapped @@ -546,8 +507,8 @@ func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go index 2e37c316..61c0d0de 100644 --- a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go @@ -125,12 +125,14 @@ func Pipe2(p []int, flags int) (err error) { } //sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error) -func Pread(fd int, p []byte, offset int64) (n int, err error) { + +func pread(fd int, p []byte, offset int64) (n int, err error) { return extpread(fd, p, 0, offset) } //sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error) -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + +func pwrite(fd int, p []byte, offset int64) (n int, err error) { return extpwrite(fd, p, 0, offset) } @@ -169,11 +171,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { return } -func setattrlistTimes(path string, times []Timespec, flags int) error { - // used on Darwin for UtimesNano - return ENOSYS -} - //sys ioctl(fd int, req uint, arg uintptr) (err error) //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/vendor/golang.org/x/sys/unix/syscall_freebsd.go index 2f650ae6..6f6c510f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd.go @@ -194,11 +194,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { return } -func setattrlistTimes(path string, times []Timespec, flags int) error { - // used on Darwin for UtimesNano - return ENOSYS -} - //sys ioctl(fd int, req uint, arg uintptr) (err error) //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL @@ -638,8 +633,8 @@ func PtraceSingleStep(pid int) (err error) { //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(fdat int, path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index f432b068..c8d20321 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -14,6 +14,7 @@ package unix import ( "encoding/binary" "syscall" + "time" "unsafe" ) @@ -249,6 +250,13 @@ func Getwd() (wd string, err error) { if n < 1 || n > len(buf) || buf[n-1] != 0 { return "", EINVAL } + // In some cases, Linux can return a path that starts with the + // "(unreachable)" prefix, which can potentially be a valid relative + // path. To work around that, return ENOENT if path is not absolute. + if buf[0] != '/' { + return "", ENOENT + } + return string(buf[0 : n-1]), nil } @@ -358,6 +366,8 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, return } +//sys Waitid(idType int, id int, info *Siginfo, options int, rusage *Rusage) (err error) + func Mkfifo(path string, mode uint32) error { return Mknod(path, mode|S_IFIFO, 0) } @@ -502,24 +512,24 @@ func (sa *SockaddrL2) sockaddr() (unsafe.Pointer, _Socklen, error) { // // Server example: // -// fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM) -// _ = unix.Bind(fd, &unix.SockaddrRFCOMM{ -// Channel: 1, -// Addr: [6]uint8{0, 0, 0, 0, 0, 0}, // BDADDR_ANY or 00:00:00:00:00:00 -// }) -// _ = Listen(fd, 1) -// nfd, sa, _ := Accept(fd) -// fmt.Printf("conn addr=%v fd=%d", sa.(*unix.SockaddrRFCOMM).Addr, nfd) -// Read(nfd, buf) +// fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM) +// _ = unix.Bind(fd, &unix.SockaddrRFCOMM{ +// Channel: 1, +// Addr: [6]uint8{0, 0, 0, 0, 0, 0}, // BDADDR_ANY or 00:00:00:00:00:00 +// }) +// _ = Listen(fd, 1) +// nfd, sa, _ := Accept(fd) +// fmt.Printf("conn addr=%v fd=%d", sa.(*unix.SockaddrRFCOMM).Addr, nfd) +// Read(nfd, buf) // // Client example: // -// fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM) -// _ = Connect(fd, &SockaddrRFCOMM{ -// Channel: 1, -// Addr: [6]byte{0x11, 0x22, 0x33, 0xaa, 0xbb, 0xcc}, // CC:BB:AA:33:22:11 -// }) -// Write(fd, []byte(`hello`)) +// fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM) +// _ = Connect(fd, &SockaddrRFCOMM{ +// Channel: 1, +// Addr: [6]byte{0x11, 0x22, 0x33, 0xaa, 0xbb, 0xcc}, // CC:BB:AA:33:22:11 +// }) +// Write(fd, []byte(`hello`)) type SockaddrRFCOMM struct { // Addr represents a bluetooth address, byte ordering is little-endian. Addr [6]uint8 @@ -546,12 +556,12 @@ func (sa *SockaddrRFCOMM) sockaddr() (unsafe.Pointer, _Socklen, error) { // The SockaddrCAN struct must be bound to the socket file descriptor // using Bind before the CAN socket can be used. // -// // Read one raw CAN frame -// fd, _ := Socket(AF_CAN, SOCK_RAW, CAN_RAW) -// addr := &SockaddrCAN{Ifindex: index} -// Bind(fd, addr) -// frame := make([]byte, 16) -// Read(fd, frame) +// // Read one raw CAN frame +// fd, _ := Socket(AF_CAN, SOCK_RAW, CAN_RAW) +// addr := &SockaddrCAN{Ifindex: index} +// Bind(fd, addr) +// frame := make([]byte, 16) +// Read(fd, frame) // // The full SocketCAN documentation can be found in the linux kernel // archives at: https://www.kernel.org/doc/Documentation/networking/can.txt @@ -622,13 +632,13 @@ func (sa *SockaddrCANJ1939) sockaddr() (unsafe.Pointer, _Socklen, error) { // Here is an example of using an AF_ALG socket with SHA1 hashing. // The initial socket setup process is as follows: // -// // Open a socket to perform SHA1 hashing. -// fd, _ := unix.Socket(unix.AF_ALG, unix.SOCK_SEQPACKET, 0) -// addr := &unix.SockaddrALG{Type: "hash", Name: "sha1"} -// unix.Bind(fd, addr) -// // Note: unix.Accept does not work at this time; must invoke accept() -// // manually using unix.Syscall. -// hashfd, _, _ := unix.Syscall(unix.SYS_ACCEPT, uintptr(fd), 0, 0) +// // Open a socket to perform SHA1 hashing. +// fd, _ := unix.Socket(unix.AF_ALG, unix.SOCK_SEQPACKET, 0) +// addr := &unix.SockaddrALG{Type: "hash", Name: "sha1"} +// unix.Bind(fd, addr) +// // Note: unix.Accept does not work at this time; must invoke accept() +// // manually using unix.Syscall. +// hashfd, _, _ := unix.Syscall(unix.SYS_ACCEPT, uintptr(fd), 0, 0) // // Once a file descriptor has been returned from Accept, it may be used to // perform SHA1 hashing. The descriptor is not safe for concurrent use, but @@ -637,39 +647,39 @@ func (sa *SockaddrCANJ1939) sockaddr() (unsafe.Pointer, _Socklen, error) { // When hashing a small byte slice or string, a single Write and Read may // be used: // -// // Assume hashfd is already configured using the setup process. -// hash := os.NewFile(hashfd, "sha1") -// // Hash an input string and read the results. Each Write discards -// // previous hash state. Read always reads the current state. -// b := make([]byte, 20) -// for i := 0; i < 2; i++ { -// io.WriteString(hash, "Hello, world.") -// hash.Read(b) -// fmt.Println(hex.EncodeToString(b)) -// } -// // Output: -// // 2ae01472317d1935a84797ec1983ae243fc6aa28 -// // 2ae01472317d1935a84797ec1983ae243fc6aa28 +// // Assume hashfd is already configured using the setup process. +// hash := os.NewFile(hashfd, "sha1") +// // Hash an input string and read the results. Each Write discards +// // previous hash state. Read always reads the current state. +// b := make([]byte, 20) +// for i := 0; i < 2; i++ { +// io.WriteString(hash, "Hello, world.") +// hash.Read(b) +// fmt.Println(hex.EncodeToString(b)) +// } +// // Output: +// // 2ae01472317d1935a84797ec1983ae243fc6aa28 +// // 2ae01472317d1935a84797ec1983ae243fc6aa28 // // For hashing larger byte slices, or byte streams such as those read from // a file or socket, use Sendto with MSG_MORE to instruct the kernel to update // the hash digest instead of creating a new one for a given chunk and finalizing it. // -// // Assume hashfd and addr are already configured using the setup process. -// hash := os.NewFile(hashfd, "sha1") -// // Hash the contents of a file. -// f, _ := os.Open("/tmp/linux-4.10-rc7.tar.xz") -// b := make([]byte, 4096) -// for { -// n, err := f.Read(b) -// if err == io.EOF { -// break -// } -// unix.Sendto(hashfd, b[:n], unix.MSG_MORE, addr) -// } -// hash.Read(b) -// fmt.Println(hex.EncodeToString(b)) -// // Output: 85cdcad0c06eef66f805ecce353bec9accbeecc5 +// // Assume hashfd and addr are already configured using the setup process. +// hash := os.NewFile(hashfd, "sha1") +// // Hash the contents of a file. +// f, _ := os.Open("/tmp/linux-4.10-rc7.tar.xz") +// b := make([]byte, 4096) +// for { +// n, err := f.Read(b) +// if err == io.EOF { +// break +// } +// unix.Sendto(hashfd, b[:n], unix.MSG_MORE, addr) +// } +// hash.Read(b) +// fmt.Println(hex.EncodeToString(b)) +// // Output: 85cdcad0c06eef66f805ecce353bec9accbeecc5 // // For more information, see: http://www.chronox.de/crypto-API/crypto/userspace-if.html. type SockaddrALG struct { @@ -1489,10 +1499,9 @@ func KeyctlRestrictKeyring(ringid int, keyType string, restriction string) error //sys keyctlRestrictKeyringByType(cmd int, arg2 int, keyType string, restriction string) (err error) = SYS_KEYCTL //sys keyctlRestrictKeyring(cmd int, arg2 int) (err error) = SYS_KEYCTL -func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { +func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn int, recvflags int, err error) { var msg Msghdr - var rsa RawSockaddrAny - msg.Name = (*byte)(unsafe.Pointer(&rsa)) + msg.Name = (*byte)(unsafe.Pointer(rsa)) msg.Namelen = uint32(SizeofSockaddrAny) var iov Iovec if len(p) > 0 { @@ -1523,28 +1532,10 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from } oobn = int(msg.Controllen) recvflags = int(msg.Flags) - // source address is only specified if the socket is unconnected - if rsa.Addr.Family != AF_UNSPEC { - from, err = anyToSockaddr(fd, &rsa) - } - return -} - -func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { - _, err = SendmsgN(fd, p, oob, to, flags) return } -func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { - var ptr unsafe.Pointer - var salen _Socklen - if to != nil { - var err error - ptr, salen, err = to.sockaddr() - if err != nil { - return 0, err - } - } +func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags int) (n int, err error) { var msg Msghdr msg.Name = (*byte)(ptr) msg.Namelen = uint32(salen) @@ -1838,6 +1829,9 @@ func Dup2(oldfd, newfd int) error { //sys Fremovexattr(fd int, attr string) (err error) //sys Fsetxattr(fd int, attr string, dest []byte, flags int) (err error) //sys Fsync(fd int) (err error) +//sys Fsmount(fd int, flags int, mountAttrs int) (fsfd int, err error) +//sys Fsopen(fsName string, flags int) (fd int, err error) +//sys Fspick(dirfd int, pathName string, flags int) (fd int, err error) //sys Getdents(fd int, buf []byte) (n int, err error) = SYS_GETDENTS64 //sysnb Getpgid(pid int) (pgid int, err error) @@ -1868,7 +1862,9 @@ func Getpgrp() (pid int) { //sys MemfdCreate(name string, flags int) (fd int, err error) //sys Mkdirat(dirfd int, path string, mode uint32) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys MoveMount(fromDirfd int, fromPathName string, toDirfd int, toPathName string, flags int) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) +//sys OpenTree(dfd int, fileName string, flags uint) (r int, err error) //sys PerfEventOpen(attr *PerfEventAttr, pid int, cpu int, groupFd int, flags int) (fd int, err error) //sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT //sysnb Prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) = SYS_PRLIMIT64 @@ -2193,7 +2189,7 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { gid = Getgid() } - if uint32(gid) == st.Gid || isGroupMember(gid) { + if uint32(gid) == st.Gid || isGroupMember(int(st.Gid)) { fmode = (st.Mode >> 3) & 7 } else { fmode = st.Mode & 7 @@ -2308,17 +2304,63 @@ type RemoteIovec struct { //sys PidfdOpen(pid int, flags int) (fd int, err error) = SYS_PIDFD_OPEN //sys PidfdGetfd(pidfd int, targetfd int, flags int) (fd int, err error) = SYS_PIDFD_GETFD +//sys PidfdSendSignal(pidfd int, sig Signal, info *Siginfo, flags int) (err error) = SYS_PIDFD_SEND_SIGNAL //sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error) //sys shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error) //sys shmdt(addr uintptr) (err error) //sys shmget(key int, size int, flag int) (id int, err error) +//sys getitimer(which int, currValue *Itimerval) (err error) +//sys setitimer(which int, newValue *Itimerval, oldValue *Itimerval) (err error) + +// MakeItimerval creates an Itimerval from interval and value durations. +func MakeItimerval(interval, value time.Duration) Itimerval { + return Itimerval{ + Interval: NsecToTimeval(interval.Nanoseconds()), + Value: NsecToTimeval(value.Nanoseconds()), + } +} + +// A value which may be passed to the which parameter for Getitimer and +// Setitimer. +type ItimerWhich int + +// Possible which values for Getitimer and Setitimer. +const ( + ItimerReal ItimerWhich = ITIMER_REAL + ItimerVirtual ItimerWhich = ITIMER_VIRTUAL + ItimerProf ItimerWhich = ITIMER_PROF +) + +// Getitimer wraps getitimer(2) to return the current value of the timer +// specified by which. +func Getitimer(which ItimerWhich) (Itimerval, error) { + var it Itimerval + if err := getitimer(int(which), &it); err != nil { + return Itimerval{}, err + } + + return it, nil +} + +// Setitimer wraps setitimer(2) to arm or disarm the timer specified by which. +// It returns the previous value of the timer. +// +// If the Itimerval argument is the zero value, the timer will be disarmed. +func Setitimer(which ItimerWhich, it Itimerval) (Itimerval, error) { + var prev Itimerval + if err := setitimer(int(which), &it, &prev); err != nil { + return Itimerval{}, err + } + + return prev, nil +} + /* * Unimplemented */ // AfsSyscall -// Alarm // ArchPrctl // Brk // ClockNanosleep @@ -2334,7 +2376,6 @@ type RemoteIovec struct { // GetMempolicy // GetRobustList // GetThreadArea -// Getitimer // Getpmsg // IoCancel // IoDestroy @@ -2412,5 +2453,4 @@ type RemoteIovec struct { // Vfork // Vhangup // Vserver -// Waitid // _Sysctl diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_386.go index 5f757e8a..518e476e 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_386.go @@ -35,8 +35,8 @@ func setTimeval(sec, usec int64) Timeval { //sys Iopl(level int) (err error) //sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32 //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 //sys setfsgid(gid int) (prev int, err error) = SYS_SETFSGID32 @@ -173,14 +173,6 @@ const ( _SENDMMSG = 20 ) -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - fd, e := socketcall(_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) - if e != 0 { - err = e - } - return -} - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { fd, e := socketcall(_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) if e != 0 { diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_alarm.go b/vendor/golang.org/x/sys/unix/syscall_linux_alarm.go new file mode 100644 index 00000000..08086ac6 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_alarm.go @@ -0,0 +1,14 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (386 || amd64 || mips || mipsle || mips64 || mipsle || ppc64 || ppc64le || ppc || s390x || sparc64) +// +build linux +// +build 386 amd64 mips mipsle mips64 mipsle ppc64 ppc64le ppc s390x sparc64 + +package unix + +// SYS_ALARM is not defined on arm or riscv, but is available for other GOARCH +// values. + +//sys Alarm(seconds uint) (remaining uint, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go index 4299125a..f5e9d6be 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -28,9 +28,10 @@ func Lstat(path string, stat *Stat_t) (err error) { return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) } +//sys MemfdSecret(flags int) (fd int, err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK @@ -62,7 +63,6 @@ func Stat(path string, stat *Stat_t) (err error) { //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) //sys Truncate(path string, length int64) (err error) //sys Ustat(dev int, ubuf *Ustat_t) (err error) -//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go index 79edeb9c..c1a7778f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go @@ -27,7 +27,6 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { return newoffset, nil } -//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) @@ -97,8 +96,8 @@ func Utime(path string, buf *Utimbuf) error { //sys utimes(path string, times *[2]Timeval) (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64 //sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64 diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go index 862890de..d83e2c65 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -22,8 +22,9 @@ import "unsafe" //sysnb getrlimit(resource int, rlim *Rlimit) (err error) //sysnb Getuid() (uid int) //sys Listen(s int, n int) (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys MemfdSecret(flags int) (fd int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK @@ -66,7 +67,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { return ENOSYS } -//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go new file mode 100644 index 00000000..28ba7b8c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go @@ -0,0 +1,191 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build loong64 && linux +// +build loong64,linux + +package unix + +import "unsafe" + +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT +//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (euid int) +//sysnb Getgid() (gid int) +//sysnb Getuid() (uid int) +//sys Listen(s int, n int) (err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + var ts *Timespec + if timeout != nil { + ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} + } + return Pselect(nfd, r, w, e, ts, nil) +} + +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) +//sys setfsgid(gid int) (prev int, err error) +//sys setfsuid(uid int) (prev int, err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sys Shutdown(fd int, how int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) + +func Stat(path string, stat *Stat_t) (err error) { + return Fstatat(AT_FDCWD, path, stat, 0) +} + +func Lchown(path string, uid int, gid int) (err error) { + return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) +} + +func Lstat(path string, stat *Stat_t) (err error) { + return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) +} + +//sys Statfs(path string, buf *Statfs_t) (err error) +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) +//sys Truncate(path string, length int64) (err error) + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + return ENOSYS +} + +//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) + +//sysnb Gettimeofday(tv *Timeval) (err error) + +func setTimespec(sec, nsec int64) Timespec { + return Timespec{Sec: sec, Nsec: nsec} +} + +func setTimeval(sec, usec int64) Timeval { + return Timeval{Sec: sec, Usec: usec} +} + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + err = Prlimit(0, resource, nil, rlim) + return +} + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + err = Prlimit(0, resource, rlim, nil) + return +} + +func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) { + if tv == nil { + return utimensat(dirfd, path, nil, 0) + } + + ts := []Timespec{ + NsecToTimespec(TimevalToNsec(tv[0])), + NsecToTimespec(TimevalToNsec(tv[1])), + } + return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) +} + +func Time(t *Time_t) (Time_t, error) { + var tv Timeval + err := Gettimeofday(&tv) + if err != nil { + return 0, err + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +func Utime(path string, buf *Utimbuf) error { + tv := []Timeval{ + {Sec: buf.Actime}, + {Sec: buf.Modtime}, + } + return Utimes(path, tv) +} + +func utimes(path string, tv *[2]Timeval) (err error) { + if tv == nil { + return utimensat(AT_FDCWD, path, nil, 0) + } + + ts := []Timespec{ + NsecToTimespec(TimevalToNsec(tv[0])), + NsecToTimespec(TimevalToNsec(tv[1])), + } + return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) +} + +func (r *PtraceRegs) PC() uint64 { return r.Era } + +func (r *PtraceRegs) SetPC(era uint64) { r.Era = era } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint64(length) +} + +func (msghdr *Msghdr) SetIovlen(length int) { + msghdr.Iovlen = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint64(length) +} + +func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { + rsa.Service_name_len = uint64(length) +} + +func Pause() error { + _, err := ppoll(nil, 0, nil, nil) + return err +} + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + return Renameat2(olddirfd, oldpath, newdirfd, newpath, 0) +} + +//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) + +func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { + cmdlineLen := len(cmdline) + if cmdlineLen > 0 { + // Account for the additional NULL byte added by + // BytePtrFromString in kexecFileLoad. The kexec_file_load + // syscall expects a NULL-terminated string. + cmdlineLen++ + } + return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go index 8932e34a..98a2660b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go @@ -21,8 +21,8 @@ package unix //sys Lchown(path string, uid int, gid int) (err error) //sys Listen(s int, n int) (err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK @@ -48,7 +48,6 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) //sys Truncate(path string, length int64) (err error) //sys Ustat(dev int, ubuf *Ustat_t) (err error) -//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go index 7821c25d..b8a18c0a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go @@ -25,8 +25,8 @@ func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, //sysnb Getuid() (uid int) //sys Lchown(path string, uid int, gid int) (err error) //sys Listen(s int, n int) (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 @@ -41,7 +41,6 @@ func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) //sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64 //sys Ustat(dev int, ubuf *Ustat_t) (err error) -//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go index c5053a0f..4ed9e67c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go @@ -27,8 +27,8 @@ import ( //sys Listen(s int, n int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 @@ -43,7 +43,6 @@ import ( //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 //sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64 //sys Ustat(dev int, ubuf *Ustat_t) (err error) -//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go index 25786c42..db63d384 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -26,8 +26,8 @@ package unix //sys Listen(s int, n int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT @@ -45,7 +45,6 @@ package unix //sys Statfs(path string, buf *Statfs_t) (err error) //sys Truncate(path string, length int64) (err error) //sys Ustat(dev int, ubuf *Ustat_t) (err error) -//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go index 6f9f7104..8ff7adba 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go @@ -22,8 +22,8 @@ import "unsafe" //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) //sysnb Getuid() (uid int) //sys Listen(s int, n int) (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { @@ -65,7 +65,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { return ENOSYS } -//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go index 6aa59cb2..6fcf277b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -26,8 +26,8 @@ import ( //sys Lchown(path string, uid int, gid int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) @@ -145,15 +145,6 @@ const ( netSendMMsg = 20 ) -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (int, error) { - args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))} - fd, _, err := Syscall(SYS_SOCKETCALL, netAccept, uintptr(unsafe.Pointer(&args)), 0) - if err != 0 { - return 0, err - } - return int(fd), nil -} - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (int, error) { args := [4]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags)} fd, _, err := Syscall(SYS_SOCKETCALL, netAccept4, uintptr(unsafe.Pointer(&args)), 0) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go index bbe8d174..02a45d9c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go @@ -23,8 +23,8 @@ package unix //sys Listen(s int, n int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) @@ -42,7 +42,6 @@ package unix //sys Statfs(path string, buf *Statfs_t) (err error) //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) //sys Truncate(path string, length int64) (err error) -//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/golang.org/x/sys/unix/syscall_netbsd.go index 696fed49..666f0a1b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd.go @@ -163,11 +163,6 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e return -1, ENOSYS } -func setattrlistTimes(path string, times []Timespec, flags int) error { - // used on Darwin for UtimesNano - return ENOSYS -} - //sys ioctl(fd int, req uint, arg uintptr) (err error) //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL @@ -313,8 +308,8 @@ func Statvfs(path string, buf *Statvfs_t) (err error) { //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index 11b1d419..78daceb3 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -81,6 +81,7 @@ func Pipe(p []int) (err error) { } //sysnb pipe2(p *[2]_C_int, flags int) (err error) + func Pipe2(p []int, flags int) error { if len(p) != 2 { return EINVAL @@ -95,6 +96,7 @@ func Pipe2(p []int, flags int) error { } //sys Getdents(fd int, buf []byte) (n int, err error) + func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { n, err = Getdents(fd, buf) if err != nil || basep == nil { @@ -149,11 +151,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { return } -func setattrlistTimes(path string, times []Timespec, flags int) error { - // used on Darwin for UtimesNano - return ENOSYS -} - //sys ioctl(fd int, req uint, arg uintptr) (err error) //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL @@ -274,8 +271,8 @@ func Uname(uname *Utsname) error { //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go index 5c813921..5c2003ce 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go @@ -451,10 +451,9 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) { //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.__xnet_recvmsg -func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { +func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn int, recvflags int, err error) { var msg Msghdr - var rsa RawSockaddrAny - msg.Name = (*byte)(unsafe.Pointer(&rsa)) + msg.Name = (*byte)(unsafe.Pointer(rsa)) msg.Namelen = uint32(SizeofSockaddrAny) var iov Iovec if len(p) > 0 { @@ -476,29 +475,12 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from return } oobn = int(msg.Accrightslen) - // source address is only specified if the socket is unconnected - if rsa.Addr.Family != AF_UNSPEC { - from, err = anyToSockaddr(fd, &rsa) - } - return -} - -func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { - _, err = SendmsgN(fd, p, oob, to, flags) return } //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.__xnet_sendmsg -func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { - var ptr unsafe.Pointer - var salen _Socklen - if to != nil { - ptr, salen, err = to.sockaddr() - if err != nil { - return 0, err - } - } +func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags int) (n int, err error) { var msg Msghdr msg.Name = (*byte)(unsafe.Pointer(ptr)) msg.Namelen = uint32(salen) @@ -661,8 +643,8 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Rename(from string, to string) (err error) @@ -755,8 +737,20 @@ type fileObjCookie struct { type EventPort struct { port int mu sync.Mutex - fds map[uintptr]interface{} + fds map[uintptr]*fileObjCookie paths map[string]*fileObjCookie + // The user cookie presents an interesting challenge from a memory management perspective. + // There are two paths by which we can discover that it is no longer in use: + // 1. The user calls port_dissociate before any events fire + // 2. An event fires and we return it to the user + // The tricky situation is if the event has fired in the kernel but + // the user hasn't requested/received it yet. + // If the user wants to port_dissociate before the event has been processed, + // we should handle things gracefully. To do so, we need to keep an extra + // reference to the cookie around until the event is processed + // thus the otherwise seemingly extraneous "cookies" map + // The key of this map is a pointer to the corresponding &fCookie.cookie + cookies map[*interface{}]*fileObjCookie } // PortEvent is an abstraction of the port_event C struct. @@ -780,9 +774,10 @@ func NewEventPort() (*EventPort, error) { return nil, err } e := &EventPort{ - port: port, - fds: make(map[uintptr]interface{}), - paths: make(map[string]*fileObjCookie), + port: port, + fds: make(map[uintptr]*fileObjCookie), + paths: make(map[string]*fileObjCookie), + cookies: make(map[*interface{}]*fileObjCookie), } return e, nil } @@ -797,9 +792,13 @@ func NewEventPort() (*EventPort, error) { func (e *EventPort) Close() error { e.mu.Lock() defer e.mu.Unlock() + err := Close(e.port) + if err != nil { + return err + } e.fds = nil e.paths = nil - return Close(e.port) + return nil } // PathIsWatched checks to see if path is associated with this EventPort. @@ -836,6 +835,7 @@ func (e *EventPort) AssociatePath(path string, stat os.FileInfo, events int, coo return err } e.paths[path] = fCookie + e.cookies[&fCookie.cookie] = fCookie return nil } @@ -848,11 +848,19 @@ func (e *EventPort) DissociatePath(path string) error { return fmt.Errorf("%v is not associated with this Event Port", path) } _, err := port_dissociate(e.port, PORT_SOURCE_FILE, uintptr(unsafe.Pointer(f.fobj))) - if err != nil { + // If the path is no longer associated with this event port (ENOENT) + // we should delete it from our map. We can still return ENOENT to the caller. + // But we need to save the cookie + if err != nil && err != ENOENT { return err } + if err == nil { + // dissociate was successful, safe to delete the cookie + fCookie := e.paths[path] + delete(e.cookies, &fCookie.cookie) + } delete(e.paths, path) - return nil + return err } // AssociateFd wraps calls to port_associate(3c) on file descriptors. @@ -862,12 +870,13 @@ func (e *EventPort) AssociateFd(fd uintptr, events int, cookie interface{}) erro if _, found := e.fds[fd]; found { return fmt.Errorf("%v is already associated with this Event Port", fd) } - pcookie := &cookie - _, err := port_associate(e.port, PORT_SOURCE_FD, fd, events, (*byte)(unsafe.Pointer(pcookie))) + fCookie := &fileObjCookie{nil, cookie} + _, err := port_associate(e.port, PORT_SOURCE_FD, fd, events, (*byte)(unsafe.Pointer(&fCookie.cookie))) if err != nil { return err } - e.fds[fd] = pcookie + e.fds[fd] = fCookie + e.cookies[&fCookie.cookie] = fCookie return nil } @@ -880,11 +889,16 @@ func (e *EventPort) DissociateFd(fd uintptr) error { return fmt.Errorf("%v is not associated with this Event Port", fd) } _, err := port_dissociate(e.port, PORT_SOURCE_FD, fd) - if err != nil { + if err != nil && err != ENOENT { return err } + if err == nil { + // dissociate was successful, safe to delete the cookie + fCookie := e.fds[fd] + delete(e.cookies, &fCookie.cookie) + } delete(e.fds, fd) - return nil + return err } func createFileObj(name string, stat os.FileInfo) (*fileObj, error) { @@ -912,24 +926,46 @@ func (e *EventPort) GetOne(t *Timespec) (*PortEvent, error) { return nil, err } p := new(PortEvent) - p.Events = pe.Events - p.Source = pe.Source e.mu.Lock() defer e.mu.Unlock() - switch pe.Source { + e.peIntToExt(pe, p) + return p, nil +} + +// peIntToExt converts a cgo portEvent struct into the friendlier PortEvent +// NOTE: Always call this function while holding the e.mu mutex +func (e *EventPort) peIntToExt(peInt *portEvent, peExt *PortEvent) { + peExt.Events = peInt.Events + peExt.Source = peInt.Source + cookie := (*interface{})(unsafe.Pointer(peInt.User)) + peExt.Cookie = *cookie + switch peInt.Source { case PORT_SOURCE_FD: - p.Fd = uintptr(pe.Object) - cookie := (*interface{})(unsafe.Pointer(pe.User)) - p.Cookie = *cookie - delete(e.fds, p.Fd) + delete(e.cookies, cookie) + peExt.Fd = uintptr(peInt.Object) + // Only remove the fds entry if it exists and this cookie matches + if fobj, ok := e.fds[peExt.Fd]; ok { + if &fobj.cookie == cookie { + delete(e.fds, peExt.Fd) + } + } case PORT_SOURCE_FILE: - p.fobj = (*fileObj)(unsafe.Pointer(uintptr(pe.Object))) - p.Path = BytePtrToString((*byte)(unsafe.Pointer(p.fobj.Name))) - cookie := (*interface{})(unsafe.Pointer(pe.User)) - p.Cookie = *cookie - delete(e.paths, p.Path) + if fCookie, ok := e.cookies[cookie]; ok && uintptr(unsafe.Pointer(fCookie.fobj)) == uintptr(peInt.Object) { + // Use our stashed reference rather than using unsafe on what we got back + // the unsafe version would be (*fileObj)(unsafe.Pointer(uintptr(peInt.Object))) + peExt.fobj = fCookie.fobj + } else { + panic("mismanaged memory") + } + delete(e.cookies, cookie) + peExt.Path = BytePtrToString((*byte)(unsafe.Pointer(peExt.fobj.Name))) + // Only remove the paths entry if it exists and this cookie matches + if fobj, ok := e.paths[peExt.Path]; ok { + if &fobj.cookie == cookie { + delete(e.paths, peExt.Path) + } + } } - return p, nil } // Pending wraps port_getn(3c) and returns how many events are pending. @@ -962,21 +998,7 @@ func (e *EventPort) Get(s []PortEvent, min int, timeout *Timespec) (int, error) e.mu.Lock() defer e.mu.Unlock() for i := 0; i < int(got); i++ { - s[i].Events = ps[i].Events - s[i].Source = ps[i].Source - switch ps[i].Source { - case PORT_SOURCE_FD: - s[i].Fd = uintptr(ps[i].Object) - cookie := (*interface{})(unsafe.Pointer(ps[i].User)) - s[i].Cookie = *cookie - delete(e.fds, s[i].Fd) - case PORT_SOURCE_FILE: - s[i].fobj = (*fileObj)(unsafe.Pointer(uintptr(ps[i].Object))) - s[i].Path = BytePtrToString((*byte)(unsafe.Pointer(s[i].fobj.Name))) - cookie := (*interface{})(unsafe.Pointer(ps[i].User)) - s[i].Cookie = *cookie - delete(e.paths, s[i].Path) - } + e.peIntToExt(&ps[i], &s[i]) } return int(got), err } diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index cf296a24..70508afc 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -177,6 +177,30 @@ func Write(fd int, p []byte) (n int, err error) { return } +func Pread(fd int, p []byte, offset int64) (n int, err error) { + n, err = pread(fd, p, offset) + if raceenabled { + if n > 0 { + raceWriteRange(unsafe.Pointer(&p[0]), n) + } + if err == nil { + raceAcquire(unsafe.Pointer(&ioSync)) + } + } + return +} + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + if raceenabled { + raceReleaseMerge(unsafe.Pointer(&ioSync)) + } + n, err = pwrite(fd, p, offset) + if raceenabled && n > 0 { + raceReadRange(unsafe.Pointer(&p[0]), n) + } + return +} + // For testing: clients can set this flag to force // creation of IPv6 sockets to return EAFNOSUPPORT. var SocketDisableIPv6 bool @@ -313,6 +337,33 @@ func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) { return } +func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { + var rsa RawSockaddrAny + n, oobn, recvflags, err = recvmsgRaw(fd, p, oob, flags, &rsa) + // source address is only specified if the socket is unconnected + if rsa.Addr.Family != AF_UNSPEC { + from, err = anyToSockaddr(fd, &rsa) + } + return +} + +func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { + _, err = SendmsgN(fd, p, oob, to, flags) + return +} + +func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { + var ptr unsafe.Pointer + var salen _Socklen + if to != nil { + ptr, salen, err = to.sockaddr() + if err != nil { + return 0, err + } + } + return sendmsgN(fd, p, oob, ptr, salen, flags) +} + func Send(s int, buf []byte, flags int) (err error) { return sendto(s, buf, flags, nil, 0) } diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 4e542058..c0a43f8b 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -38,7 +38,8 @@ const ( AF_KEY = 0xf AF_LLC = 0x1a AF_LOCAL = 0x1 - AF_MAX = 0x2d + AF_MAX = 0x2e + AF_MCTP = 0x2d AF_MPLS = 0x1c AF_NETBEUI = 0xd AF_NETLINK = 0x10 @@ -259,6 +260,17 @@ const ( BUS_USB = 0x3 BUS_VIRTUAL = 0x6 CAN_BCM = 0x2 + CAN_CTRLMODE_3_SAMPLES = 0x4 + CAN_CTRLMODE_BERR_REPORTING = 0x10 + CAN_CTRLMODE_CC_LEN8_DLC = 0x100 + CAN_CTRLMODE_FD = 0x20 + CAN_CTRLMODE_FD_NON_ISO = 0x80 + CAN_CTRLMODE_LISTENONLY = 0x2 + CAN_CTRLMODE_LOOPBACK = 0x1 + CAN_CTRLMODE_ONE_SHOT = 0x8 + CAN_CTRLMODE_PRESUME_ACK = 0x40 + CAN_CTRLMODE_TDC_AUTO = 0x200 + CAN_CTRLMODE_TDC_MANUAL = 0x400 CAN_EFF_FLAG = 0x80000000 CAN_EFF_ID_BITS = 0x1d CAN_EFF_MASK = 0x1fffffff @@ -336,6 +348,7 @@ const ( CAN_RTR_FLAG = 0x40000000 CAN_SFF_ID_BITS = 0xb CAN_SFF_MASK = 0x7ff + CAN_TERMINATION_DISABLED = 0x0 CAN_TP16 = 0x3 CAN_TP20 = 0x4 CAP_AUDIT_CONTROL = 0x1e @@ -380,9 +393,11 @@ const ( CAP_SYS_TIME = 0x19 CAP_SYS_TTY_CONFIG = 0x1a CAP_WAKE_ALARM = 0x23 + CEPH_SUPER_MAGIC = 0xc36400 CFLUSH = 0xf CGROUP2_SUPER_MAGIC = 0x63677270 CGROUP_SUPER_MAGIC = 0x27e0eb + CIFS_SUPER_MAGIC = 0xff534d42 CLOCK_BOOTTIME = 0x7 CLOCK_BOOTTIME_ALARM = 0x9 CLOCK_DEFAULT = 0x0 @@ -771,6 +786,7 @@ const ( EV_SYN = 0x0 EV_VERSION = 0x10001 EXABYTE_ENABLE_NEST = 0xf0 + EXFAT_SUPER_MAGIC = 0x2011bab0 EXT2_SUPER_MAGIC = 0xef53 EXT3_SUPER_MAGIC = 0xef53 EXT4_SUPER_MAGIC = 0xef53 @@ -813,6 +829,8 @@ const ( FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2 FAN_EVENT_INFO_TYPE_ERROR = 0x5 FAN_EVENT_INFO_TYPE_FID = 0x1 + FAN_EVENT_INFO_TYPE_NEW_DFID_NAME = 0xc + FAN_EVENT_INFO_TYPE_OLD_DFID_NAME = 0xa FAN_EVENT_INFO_TYPE_PIDFD = 0x4 FAN_EVENT_METADATA_LEN = 0x18 FAN_EVENT_ON_CHILD = 0x8000000 @@ -841,17 +859,27 @@ const ( FAN_OPEN_EXEC_PERM = 0x40000 FAN_OPEN_PERM = 0x10000 FAN_Q_OVERFLOW = 0x4000 + FAN_RENAME = 0x10000000 FAN_REPORT_DFID_NAME = 0xc00 + FAN_REPORT_DFID_NAME_TARGET = 0x1e00 FAN_REPORT_DIR_FID = 0x400 FAN_REPORT_FID = 0x200 FAN_REPORT_NAME = 0x800 FAN_REPORT_PIDFD = 0x80 + FAN_REPORT_TARGET_FID = 0x1000 FAN_REPORT_TID = 0x100 FAN_UNLIMITED_MARKS = 0x20 FAN_UNLIMITED_QUEUE = 0x10 FD_CLOEXEC = 0x1 FD_SETSIZE = 0x400 FF0 = 0x0 + FIB_RULE_DEV_DETACHED = 0x8 + FIB_RULE_FIND_SADDR = 0x10000 + FIB_RULE_IIF_DETACHED = 0x8 + FIB_RULE_INVERT = 0x2 + FIB_RULE_OIF_DETACHED = 0x10 + FIB_RULE_PERMANENT = 0x1 + FIB_RULE_UNRESOLVED = 0x4 FIDEDUPERANGE = 0xc0189436 FSCRYPT_KEY_DESCRIPTOR_SIZE = 0x8 FSCRYPT_KEY_DESC_PREFIX = "fscrypt:" @@ -914,6 +942,7 @@ const ( FS_VERITY_METADATA_TYPE_DESCRIPTOR = 0x2 FS_VERITY_METADATA_TYPE_MERKLE_TREE = 0x1 FS_VERITY_METADATA_TYPE_SIGNATURE = 0x3 + FUSE_SUPER_MAGIC = 0x65735546 FUTEXFS_SUPER_MAGIC = 0xbad1dea F_ADD_SEALS = 0x409 F_DUPFD = 0x0 @@ -1267,15 +1296,21 @@ const ( IP_XFRM_POLICY = 0x11 ISOFS_SUPER_MAGIC = 0x9660 ISTRIP = 0x20 + ITIMER_PROF = 0x2 + ITIMER_REAL = 0x0 + ITIMER_VIRTUAL = 0x1 IUTF8 = 0x4000 IXANY = 0x800 JFFS2_SUPER_MAGIC = 0x72b6 + KCMPROTO_CONNECTED = 0x0 + KCM_RECV_DISABLE = 0x1 KEXEC_ARCH_386 = 0x30000 KEXEC_ARCH_68K = 0x40000 KEXEC_ARCH_AARCH64 = 0xb70000 KEXEC_ARCH_ARM = 0x280000 KEXEC_ARCH_DEFAULT = 0x0 KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_LOONGARCH = 0x1020000 KEXEC_ARCH_MASK = 0xffff0000 KEXEC_ARCH_MIPS = 0x80000 KEXEC_ARCH_MIPS_LE = 0xa0000 @@ -1477,6 +1512,7 @@ const ( MNT_DETACH = 0x2 MNT_EXPIRE = 0x4 MNT_FORCE = 0x1 + MODULE_INIT_COMPRESSED_FILE = 0x4 MODULE_INIT_IGNORE_MODVERSIONS = 0x1 MODULE_INIT_IGNORE_VERMAGIC = 0x2 MOUNT_ATTR_IDMAP = 0x100000 @@ -1831,6 +1867,9 @@ const ( PERF_MEM_BLK_NA = 0x1 PERF_MEM_BLK_SHIFT = 0x28 PERF_MEM_HOPS_0 = 0x1 + PERF_MEM_HOPS_1 = 0x2 + PERF_MEM_HOPS_2 = 0x3 + PERF_MEM_HOPS_3 = 0x4 PERF_MEM_HOPS_SHIFT = 0x2b PERF_MEM_LOCK_LOCKED = 0x2 PERF_MEM_LOCK_NA = 0x1 @@ -2034,6 +2073,8 @@ const ( PR_SET_TIMING = 0xe PR_SET_TSC = 0x1a PR_SET_UNALIGN = 0x6 + PR_SET_VMA = 0x53564d41 + PR_SET_VMA_ANON_NAME = 0x0 PR_SPEC_DISABLE = 0x4 PR_SPEC_DISABLE_NOEXEC = 0x10 PR_SPEC_ENABLE = 0x2 @@ -2117,6 +2158,10 @@ const ( PTRACE_SYSCALL_INFO_NONE = 0x0 PTRACE_SYSCALL_INFO_SECCOMP = 0x3 PTRACE_TRACEME = 0x0 + P_ALL = 0x0 + P_PGID = 0x2 + P_PID = 0x1 + P_PIDFD = 0x3 QNX4_SUPER_MAGIC = 0x2f QNX6_SUPER_MAGIC = 0x68191122 RAMFS_MAGIC = 0x858458f6 @@ -2442,6 +2487,9 @@ const ( SIOCGSTAMPNS = 0x8907 SIOCGSTAMPNS_OLD = 0x8907 SIOCGSTAMP_OLD = 0x8906 + SIOCKCMATTACH = 0x89e0 + SIOCKCMCLONE = 0x89e2 + SIOCKCMUNATTACH = 0x89e1 SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d @@ -2484,6 +2532,7 @@ const ( SMART_STATUS = 0xda SMART_WRITE_LOG_SECTOR = 0xd6 SMART_WRITE_THRESHOLDS = 0xd7 + SMB2_SUPER_MAGIC = 0xfe534d42 SMB_SUPER_MAGIC = 0x517b SOCKFS_MAGIC = 0x534f434b SOCK_BUF_LOCK_MASK = 0x3 @@ -2625,7 +2674,7 @@ const ( TASKSTATS_GENL_NAME = "TASKSTATS" TASKSTATS_GENL_VERSION = 0x1 TASKSTATS_TYPE_MAX = 0x6 - TASKSTATS_VERSION = 0xa + TASKSTATS_VERSION = 0xb TCIFLUSH = 0x0 TCIOFF = 0x2 TCIOFLUSH = 0x2 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go new file mode 100644 index 00000000..ebc5f321 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -0,0 +1,818 @@ +// mkerrors.sh -Wall -Werror -static -I/tmp/include +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build loong64 && linux +// +build loong64,linux + +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go + +package unix + +import "syscall" + +const ( + B1000000 = 0x1008 + B115200 = 0x1002 + B1152000 = 0x1009 + B1500000 = 0x100a + B2000000 = 0x100b + B230400 = 0x1003 + B2500000 = 0x100c + B3000000 = 0x100d + B3500000 = 0x100e + B4000000 = 0x100f + B460800 = 0x1004 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B921600 = 0x1007 + BLKBSZGET = 0x80081270 + BLKBSZSET = 0x40081271 + BLKFLSBUF = 0x1261 + BLKFRAGET = 0x1265 + BLKFRASET = 0x1264 + BLKGETSIZE = 0x1260 + BLKGETSIZE64 = 0x80081272 + BLKPBSZGET = 0x127b + BLKRAGET = 0x1263 + BLKRASET = 0x1262 + BLKROGET = 0x125e + BLKROSET = 0x125d + BLKRRPART = 0x125f + BLKSECTGET = 0x1267 + BLKSECTSET = 0x1266 + BLKSSZGET = 0x1268 + BOTHER = 0x1000 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 + CIBAUD = 0x100f0000 + CLOCAL = 0x800 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 + CREAD = 0x80 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIZE = 0x30 + CSTOPB = 0x40 + ECCGETLAYOUT = 0x81484d11 + ECCGETSTATS = 0x80104d12 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + EFD_CLOEXEC = 0x80000 + EFD_NONBLOCK = 0x800 + EPOLL_CLOEXEC = 0x80000 + EXTPROC = 0x10000 + FF1 = 0x8000 + FFDLY = 0x8000 + FICLONE = 0x40049409 + FICLONERANGE = 0x4020940d + FLUSHO = 0x1000 + FPU_CTX_MAGIC = 0x46505501 + FS_IOC_ENABLE_VERITY = 0x40806685 + FS_IOC_GETFLAGS = 0x80086601 + FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b + FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 + FS_IOC_SETFLAGS = 0x40086602 + FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 + F_GETLK = 0x5 + F_GETLK64 = 0x5 + F_GETOWN = 0x9 + F_RDLCK = 0x0 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETOWN = 0x8 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x80084803 + HIDIOCGRDESC = 0x90044802 + HIDIOCGRDESCSIZE = 0x80044801 + HUPCL = 0x400 + ICANON = 0x2 + IEXTEN = 0x8000 + IN_CLOEXEC = 0x80000 + IN_NONBLOCK = 0x800 + IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 + ISIG = 0x1 + IUCLC = 0x200 + IXOFF = 0x1000 + IXON = 0x400 + LASX_CTX_MAGIC = 0x41535801 + LSX_CTX_MAGIC = 0x53580001 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_LOCKED = 0x2000 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x4000 + MAP_POPULATE = 0x8000 + MAP_STACK = 0x20000 + MAP_SYNC = 0x80000 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MCL_ONFAULT = 0x4 + MEMERASE = 0x40084d02 + MEMERASE64 = 0x40104d14 + MEMGETBADBLOCK = 0x40084d0b + MEMGETINFO = 0x80204d01 + MEMGETOOBSEL = 0x80c84d0a + MEMGETREGIONCOUNT = 0x80044d07 + MEMISLOCKED = 0x80084d17 + MEMLOCK = 0x40084d05 + MEMREADOOB = 0xc0104d04 + MEMSETBADBLOCK = 0x40084d0c + MEMUNLOCK = 0x40084d06 + MEMWRITEOOB = 0xc0104d03 + MTDFILEMODE = 0x4d13 + NFDBITS = 0x40 + NLDLY = 0x100 + NOFLSH = 0x80 + NS_GET_NSTYPE = 0xb703 + NS_GET_OWNER_UID = 0xb704 + NS_GET_PARENT = 0xb702 + NS_GET_USERNS = 0xb701 + OLCUC = 0x2 + ONLCR = 0x4 + OTPERASE = 0x400c4d19 + OTPGETREGIONCOUNT = 0x40044d0e + OTPGETREGIONINFO = 0x400c4d0f + OTPLOCK = 0x800c4d10 + OTPSELECT = 0x80044d0d + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x4000 + O_DIRECTORY = 0x10000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x0 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x20000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + PARENB = 0x100 + PARODD = 0x200 + PENDIN = 0x4000 + PERF_EVENT_IOC_DISABLE = 0x2401 + PERF_EVENT_IOC_ENABLE = 0x2400 + PERF_EVENT_IOC_ID = 0x80082407 + PERF_EVENT_IOC_MODIFY_ATTRIBUTES = 0x4008240b + PERF_EVENT_IOC_PAUSE_OUTPUT = 0x40042409 + PERF_EVENT_IOC_PERIOD = 0x40082404 + PERF_EVENT_IOC_QUERY_BPF = 0xc008240a + PERF_EVENT_IOC_REFRESH = 0x2402 + PERF_EVENT_IOC_RESET = 0x2403 + PERF_EVENT_IOC_SET_BPF = 0x40042408 + PERF_EVENT_IOC_SET_FILTER = 0x40082406 + PERF_EVENT_IOC_SET_OUTPUT = 0x2405 + PPPIOCATTACH = 0x4004743d + PPPIOCATTCHAN = 0x40047438 + PPPIOCBRIDGECHAN = 0x40047435 + PPPIOCCONNECT = 0x4004743a + PPPIOCDETACH = 0x4004743c + PPPIOCDISCONN = 0x7439 + PPPIOCGASYNCMAP = 0x80047458 + PPPIOCGCHAN = 0x80047437 + PPPIOCGDEBUG = 0x80047441 + PPPIOCGFLAGS = 0x8004745a + PPPIOCGIDLE = 0x8010743f + PPPIOCGIDLE32 = 0x8008743f + PPPIOCGIDLE64 = 0x8010743f + PPPIOCGL2TPSTATS = 0x80487436 + PPPIOCGMRU = 0x80047453 + PPPIOCGRASYNCMAP = 0x80047455 + PPPIOCGUNIT = 0x80047456 + PPPIOCGXASYNCMAP = 0x80207450 + PPPIOCSACTIVE = 0x40107446 + PPPIOCSASYNCMAP = 0x40047457 + PPPIOCSCOMPRESS = 0x4010744d + PPPIOCSDEBUG = 0x40047440 + PPPIOCSFLAGS = 0x40047459 + PPPIOCSMAXCID = 0x40047451 + PPPIOCSMRRU = 0x4004743b + PPPIOCSMRU = 0x40047452 + PPPIOCSNPMODE = 0x4008744b + PPPIOCSPASS = 0x40107447 + PPPIOCSRASYNCMAP = 0x40047454 + PPPIOCSXASYNCMAP = 0x4020744f + PPPIOCUNBRIDGECHAN = 0x7434 + PPPIOCXFERUNIT = 0x744e + PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTRACE_SYSEMU = 0x1f + PTRACE_SYSEMU_SINGLESTEP = 0x20 + RLIMIT_AS = 0x9 + RLIMIT_MEMLOCK = 0x8 + RLIMIT_NOFILE = 0x7 + RLIMIT_NPROC = 0x6 + RLIMIT_RSS = 0x5 + RNDADDENTROPY = 0x40085203 + RNDADDTOENTCNT = 0x40045201 + RNDCLEARPOOL = 0x5206 + RNDGETENTCNT = 0x80045200 + RNDGETPOOL = 0x80085202 + RNDRESEEDCRNG = 0x5207 + RNDZAPENTCNT = 0x5204 + RTC_AIE_OFF = 0x7002 + RTC_AIE_ON = 0x7001 + RTC_ALM_READ = 0x80247008 + RTC_ALM_SET = 0x40247007 + RTC_EPOCH_READ = 0x8008700d + RTC_EPOCH_SET = 0x4008700e + RTC_IRQP_READ = 0x8008700b + RTC_IRQP_SET = 0x4008700c + RTC_PARAM_GET = 0x40187013 + RTC_PARAM_SET = 0x40187014 + RTC_PIE_OFF = 0x7006 + RTC_PIE_ON = 0x7005 + RTC_PLL_GET = 0x80207011 + RTC_PLL_SET = 0x40207012 + RTC_RD_TIME = 0x80247009 + RTC_SET_TIME = 0x4024700a + RTC_UIE_OFF = 0x7004 + RTC_UIE_ON = 0x7003 + RTC_VL_CLR = 0x7014 + RTC_VL_READ = 0x80047013 + RTC_WIE_OFF = 0x7010 + RTC_WIE_ON = 0x700f + RTC_WKALM_RD = 0x80287010 + RTC_WKALM_SET = 0x4028700f + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPING_OPT_STATS = 0x36 + SCM_TIMESTAMPING_PKTINFO = 0x3a + SCM_TIMESTAMPNS = 0x23 + SCM_TXTIME = 0x3d + SCM_WIFI_STATUS = 0x29 + SFD_CLOEXEC = 0x80000 + SFD_NONBLOCK = 0x800 + SIOCATMARK = 0x8905 + SIOCGPGRP = 0x8904 + SIOCGSTAMPNS_NEW = 0x80108907 + SIOCGSTAMP_NEW = 0x80108906 + SIOCINQ = 0x541b + SIOCOUTQ = 0x5411 + SIOCSPGRP = 0x8902 + SOCK_CLOEXEC = 0x80000 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0x1 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_BPF = 0x32 + SO_ATTACH_REUSEPORT_CBPF = 0x33 + SO_ATTACH_REUSEPORT_EBPF = 0x34 + SO_BINDTODEVICE = 0x19 + SO_BINDTOIFINDEX = 0x3e + SO_BPF_EXTENSIONS = 0x30 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 + SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 + SO_CNX_ADVICE = 0x35 + SO_COOKIE = 0x39 + SO_DETACH_REUSEPORT_BPF = 0x44 + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_INCOMING_CPU = 0x31 + SO_INCOMING_NAPI_ID = 0x38 + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_MEMINFO = 0x37 + SO_NETNS_COOKIE = 0x47 + SO_NOFCS = 0x2b + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x10 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x11 + SO_PEERGROUPS = 0x3b + SO_PEERSEC = 0x1f + SO_PREFER_BUSY_POLL = 0x45 + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x12 + SO_RCVTIMEO = 0x14 + SO_RCVTIMEO_NEW = 0x42 + SO_RCVTIMEO_OLD = 0x14 + SO_RESERVE_MEM = 0x49 + SO_REUSEADDR = 0x2 + SO_REUSEPORT = 0xf + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x13 + SO_SNDTIMEO = 0x15 + SO_SNDTIMEO_NEW = 0x43 + SO_SNDTIMEO_OLD = 0x15 + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPING_NEW = 0x41 + SO_TIMESTAMPING_OLD = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TIMESTAMPNS_NEW = 0x40 + SO_TIMESTAMPNS_OLD = 0x23 + SO_TIMESTAMP_NEW = 0x3f + SO_TXTIME = 0x3d + SO_TYPE = 0x3 + SO_WIFI_STATUS = 0x29 + SO_ZEROCOPY = 0x3c + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 + TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 + TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a + TFD_CLOEXEC = 0x80000 + TFD_NONBLOCK = 0x800 + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x80045432 + TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 + TIOCGICOUNT = 0x545d + TIOCGISO7816 = 0x80285442 + TIOCGLCKTRMIOS = 0x5456 + TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 + TIOCGPTN = 0x80045430 + TIOCGPTPEER = 0x5441 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x5413 + TIOCINQ = 0x541b + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x5411 + TIOCPKT = 0x5420 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x5423 + TIOCSIG = 0x40045436 + TIOCSISO7816 = 0xc0285443 + TIOCSLCKTRMIOS = 0x5457 + TIOCSPGRP = 0x5410 + TIOCSPTLCK = 0x40045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTI = 0x5412 + TIOCSWINSZ = 0x5414 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x100 + TUNATTACHFILTER = 0x401054d5 + TUNDETACHFILTER = 0x401054d6 + TUNGETDEVNETNS = 0x54e3 + TUNGETFEATURES = 0x800454cf + TUNGETFILTER = 0x801054db + TUNGETIFF = 0x800454d2 + TUNGETSNDBUF = 0x800454d3 + TUNGETVNETBE = 0x800454df + TUNGETVNETHDRSZ = 0x800454d7 + TUNGETVNETLE = 0x800454dd + TUNSETCARRIER = 0x400454e2 + TUNSETDEBUG = 0x400454c9 + TUNSETFILTEREBPF = 0x800454e1 + TUNSETGROUP = 0x400454ce + TUNSETIFF = 0x400454ca + TUNSETIFINDEX = 0x400454da + TUNSETLINK = 0x400454cd + TUNSETNOCSUM = 0x400454c8 + TUNSETOFFLOAD = 0x400454d0 + TUNSETOWNER = 0x400454cc + TUNSETPERSIST = 0x400454cb + TUNSETQUEUE = 0x400454d9 + TUNSETSNDBUF = 0x400454d4 + TUNSETSTEERINGEBPF = 0x800454e0 + TUNSETTXFILTER = 0x400454d1 + TUNSETVNETBE = 0x400454de + TUNSETVNETHDRSZ = 0x400454d8 + TUNSETVNETLE = 0x400454dc + UBI_IOCATT = 0x40186f40 + UBI_IOCDET = 0x40046f41 + UBI_IOCEBCH = 0x40044f02 + UBI_IOCEBER = 0x40044f01 + UBI_IOCEBISMAP = 0x80044f05 + UBI_IOCEBMAP = 0x40084f03 + UBI_IOCEBUNMAP = 0x40044f04 + UBI_IOCMKVOL = 0x40986f00 + UBI_IOCRMVOL = 0x40046f01 + UBI_IOCRNVOL = 0x51106f03 + UBI_IOCRPEB = 0x40046f04 + UBI_IOCRSVOL = 0x400c6f02 + UBI_IOCSETVOLPROP = 0x40104f06 + UBI_IOCSPEB = 0x40046f05 + UBI_IOCVOLCRBLK = 0x40804f07 + UBI_IOCVOLRMBLK = 0x4f08 + UBI_IOCVOLUP = 0x40084f00 + VDISCARD = 0xd + VEOF = 0x4 + VEOL = 0xb + VEOL2 = 0x10 + VMIN = 0x6 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WDIOC_GETBOOTSTATUS = 0x80045702 + WDIOC_GETPRETIMEOUT = 0x80045709 + WDIOC_GETSTATUS = 0x80045701 + WDIOC_GETSUPPORT = 0x80285700 + WDIOC_GETTEMP = 0x80045703 + WDIOC_GETTIMELEFT = 0x8004570a + WDIOC_GETTIMEOUT = 0x80045707 + WDIOC_KEEPALIVE = 0x80045705 + WDIOC_SETOPTIONS = 0x80045704 + WORDSIZE = 0x40 + XCASE = 0x4 + XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x80804804 + _HIDIOCGRAWPHYS = 0x80404805 + _HIDIOCGRAWUNIQ = 0x80404808 +) + +// Errors +const ( + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + ECANCELED = syscall.Errno(0x7d) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x23) + EDESTADDRREQ = syscall.Errno(0x59) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EISCONN = syscall.Errno(0x6a) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTCONN = syscall.Errno(0x6b) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTUNIQ = syscall.Errno(0x4c) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPFNOSUPPORT = syscall.Errno(0x60) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGIO = syscall.Signal(0x1d) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errorList = [...]struct { + num syscall.Errno + name string + desc string +}{ + {1, "EPERM", "operation not permitted"}, + {2, "ENOENT", "no such file or directory"}, + {3, "ESRCH", "no such process"}, + {4, "EINTR", "interrupted system call"}, + {5, "EIO", "input/output error"}, + {6, "ENXIO", "no such device or address"}, + {7, "E2BIG", "argument list too long"}, + {8, "ENOEXEC", "exec format error"}, + {9, "EBADF", "bad file descriptor"}, + {10, "ECHILD", "no child processes"}, + {11, "EAGAIN", "resource temporarily unavailable"}, + {12, "ENOMEM", "cannot allocate memory"}, + {13, "EACCES", "permission denied"}, + {14, "EFAULT", "bad address"}, + {15, "ENOTBLK", "block device required"}, + {16, "EBUSY", "device or resource busy"}, + {17, "EEXIST", "file exists"}, + {18, "EXDEV", "invalid cross-device link"}, + {19, "ENODEV", "no such device"}, + {20, "ENOTDIR", "not a directory"}, + {21, "EISDIR", "is a directory"}, + {22, "EINVAL", "invalid argument"}, + {23, "ENFILE", "too many open files in system"}, + {24, "EMFILE", "too many open files"}, + {25, "ENOTTY", "inappropriate ioctl for device"}, + {26, "ETXTBSY", "text file busy"}, + {27, "EFBIG", "file too large"}, + {28, "ENOSPC", "no space left on device"}, + {29, "ESPIPE", "illegal seek"}, + {30, "EROFS", "read-only file system"}, + {31, "EMLINK", "too many links"}, + {32, "EPIPE", "broken pipe"}, + {33, "EDOM", "numerical argument out of domain"}, + {34, "ERANGE", "numerical result out of range"}, + {35, "EDEADLK", "resource deadlock avoided"}, + {36, "ENAMETOOLONG", "file name too long"}, + {37, "ENOLCK", "no locks available"}, + {38, "ENOSYS", "function not implemented"}, + {39, "ENOTEMPTY", "directory not empty"}, + {40, "ELOOP", "too many levels of symbolic links"}, + {42, "ENOMSG", "no message of desired type"}, + {43, "EIDRM", "identifier removed"}, + {44, "ECHRNG", "channel number out of range"}, + {45, "EL2NSYNC", "level 2 not synchronized"}, + {46, "EL3HLT", "level 3 halted"}, + {47, "EL3RST", "level 3 reset"}, + {48, "ELNRNG", "link number out of range"}, + {49, "EUNATCH", "protocol driver not attached"}, + {50, "ENOCSI", "no CSI structure available"}, + {51, "EL2HLT", "level 2 halted"}, + {52, "EBADE", "invalid exchange"}, + {53, "EBADR", "invalid request descriptor"}, + {54, "EXFULL", "exchange full"}, + {55, "ENOANO", "no anode"}, + {56, "EBADRQC", "invalid request code"}, + {57, "EBADSLT", "invalid slot"}, + {59, "EBFONT", "bad font file format"}, + {60, "ENOSTR", "device not a stream"}, + {61, "ENODATA", "no data available"}, + {62, "ETIME", "timer expired"}, + {63, "ENOSR", "out of streams resources"}, + {64, "ENONET", "machine is not on the network"}, + {65, "ENOPKG", "package not installed"}, + {66, "EREMOTE", "object is remote"}, + {67, "ENOLINK", "link has been severed"}, + {68, "EADV", "advertise error"}, + {69, "ESRMNT", "srmount error"}, + {70, "ECOMM", "communication error on send"}, + {71, "EPROTO", "protocol error"}, + {72, "EMULTIHOP", "multihop attempted"}, + {73, "EDOTDOT", "RFS specific error"}, + {74, "EBADMSG", "bad message"}, + {75, "EOVERFLOW", "value too large for defined data type"}, + {76, "ENOTUNIQ", "name not unique on network"}, + {77, "EBADFD", "file descriptor in bad state"}, + {78, "EREMCHG", "remote address changed"}, + {79, "ELIBACC", "can not access a needed shared library"}, + {80, "ELIBBAD", "accessing a corrupted shared library"}, + {81, "ELIBSCN", ".lib section in a.out corrupted"}, + {82, "ELIBMAX", "attempting to link in too many shared libraries"}, + {83, "ELIBEXEC", "cannot exec a shared library directly"}, + {84, "EILSEQ", "invalid or incomplete multibyte or wide character"}, + {85, "ERESTART", "interrupted system call should be restarted"}, + {86, "ESTRPIPE", "streams pipe error"}, + {87, "EUSERS", "too many users"}, + {88, "ENOTSOCK", "socket operation on non-socket"}, + {89, "EDESTADDRREQ", "destination address required"}, + {90, "EMSGSIZE", "message too long"}, + {91, "EPROTOTYPE", "protocol wrong type for socket"}, + {92, "ENOPROTOOPT", "protocol not available"}, + {93, "EPROTONOSUPPORT", "protocol not supported"}, + {94, "ESOCKTNOSUPPORT", "socket type not supported"}, + {95, "ENOTSUP", "operation not supported"}, + {96, "EPFNOSUPPORT", "protocol family not supported"}, + {97, "EAFNOSUPPORT", "address family not supported by protocol"}, + {98, "EADDRINUSE", "address already in use"}, + {99, "EADDRNOTAVAIL", "cannot assign requested address"}, + {100, "ENETDOWN", "network is down"}, + {101, "ENETUNREACH", "network is unreachable"}, + {102, "ENETRESET", "network dropped connection on reset"}, + {103, "ECONNABORTED", "software caused connection abort"}, + {104, "ECONNRESET", "connection reset by peer"}, + {105, "ENOBUFS", "no buffer space available"}, + {106, "EISCONN", "transport endpoint is already connected"}, + {107, "ENOTCONN", "transport endpoint is not connected"}, + {108, "ESHUTDOWN", "cannot send after transport endpoint shutdown"}, + {109, "ETOOMANYREFS", "too many references: cannot splice"}, + {110, "ETIMEDOUT", "connection timed out"}, + {111, "ECONNREFUSED", "connection refused"}, + {112, "EHOSTDOWN", "host is down"}, + {113, "EHOSTUNREACH", "no route to host"}, + {114, "EALREADY", "operation already in progress"}, + {115, "EINPROGRESS", "operation now in progress"}, + {116, "ESTALE", "stale file handle"}, + {117, "EUCLEAN", "structure needs cleaning"}, + {118, "ENOTNAM", "not a XENIX named type file"}, + {119, "ENAVAIL", "no XENIX semaphores available"}, + {120, "EISNAM", "is a named type file"}, + {121, "EREMOTEIO", "remote I/O error"}, + {122, "EDQUOT", "disk quota exceeded"}, + {123, "ENOMEDIUM", "no medium found"}, + {124, "EMEDIUMTYPE", "wrong medium type"}, + {125, "ECANCELED", "operation canceled"}, + {126, "ENOKEY", "required key not available"}, + {127, "EKEYEXPIRED", "key has expired"}, + {128, "EKEYREVOKED", "key has been revoked"}, + {129, "EKEYREJECTED", "key was rejected by service"}, + {130, "EOWNERDEAD", "owner died"}, + {131, "ENOTRECOVERABLE", "state not recoverable"}, + {132, "ERFKILL", "operation not possible due to RF-kill"}, + {133, "EHWPOISON", "memory page has hardware error"}, +} + +// Signal table +var signalList = [...]struct { + num syscall.Signal + name string + desc string +}{ + {1, "SIGHUP", "hangup"}, + {2, "SIGINT", "interrupt"}, + {3, "SIGQUIT", "quit"}, + {4, "SIGILL", "illegal instruction"}, + {5, "SIGTRAP", "trace/breakpoint trap"}, + {6, "SIGABRT", "aborted"}, + {7, "SIGBUS", "bus error"}, + {8, "SIGFPE", "floating point exception"}, + {9, "SIGKILL", "killed"}, + {10, "SIGUSR1", "user defined signal 1"}, + {11, "SIGSEGV", "segmentation fault"}, + {12, "SIGUSR2", "user defined signal 2"}, + {13, "SIGPIPE", "broken pipe"}, + {14, "SIGALRM", "alarm clock"}, + {15, "SIGTERM", "terminated"}, + {16, "SIGSTKFLT", "stack fault"}, + {17, "SIGCHLD", "child exited"}, + {18, "SIGCONT", "continued"}, + {19, "SIGSTOP", "stopped (signal)"}, + {20, "SIGTSTP", "stopped"}, + {21, "SIGTTIN", "stopped (tty input)"}, + {22, "SIGTTOU", "stopped (tty output)"}, + {23, "SIGURG", "urgent I/O condition"}, + {24, "SIGXCPU", "CPU time limit exceeded"}, + {25, "SIGXFSZ", "file size limit exceeded"}, + {26, "SIGVTALRM", "virtual timer expired"}, + {27, "SIGPROF", "profiling timer expired"}, + {28, "SIGWINCH", "window changed"}, + {29, "SIGIO", "I/O possible"}, + {30, "SIGPWR", "power failure"}, + {31, "SIGSYS", "bad system call"}, +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go index 85e0cc38..870215d2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go @@ -975,7 +975,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { _p0 = &p[0] @@ -992,7 +992,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { _p0 = &p[0] diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go index f1d4a73b..a89b0bfa 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go @@ -931,7 +931,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { _p0 = &p[0] @@ -946,7 +946,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { _p0 = &p[0] diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 0ae0ed4c..87937658 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -643,17 +643,22 @@ var libc_flistxattr_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) { - _, _, e1 := syscall_syscall6(libc_setattrlist_trampoline_addr, uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0) +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_utimensat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } -var libc_setattrlist_trampoline_addr uintptr +var libc_utimensat_trampoline_addr uintptr -//go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic libc_utimensat utimensat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1698,7 +1703,7 @@ var libc_pathconf_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1719,7 +1724,7 @@ var libc_pread_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index eac6ca80..8da90cf0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -228,11 +228,11 @@ TEXT libc_flistxattr_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_flistxattr_trampoline_addr(SB), RODATA, $8 DATA ·libc_flistxattr_trampoline_addr(SB)/8, $libc_flistxattr_trampoline<>(SB) -TEXT libc_setattrlist_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_setattrlist(SB) +TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_utimensat(SB) -GLOBL ·libc_setattrlist_trampoline_addr(SB), RODATA, $8 -DATA ·libc_setattrlist_trampoline_addr(SB)/8, $libc_setattrlist_trampoline<>(SB) +GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_utimensat_trampoline_addr(SB)/8, $libc_utimensat_trampoline<>(SB) TEXT libc_fcntl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_fcntl(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index cf71be3e..f47eedd5 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -643,17 +643,22 @@ var libc_flistxattr_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) { - _, _, e1 := syscall_syscall6(libc_setattrlist_trampoline_addr, uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0) +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_utimensat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } -var libc_setattrlist_trampoline_addr uintptr +var libc_utimensat_trampoline_addr uintptr -//go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic libc_utimensat utimensat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1698,7 +1703,7 @@ var libc_pathconf_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1719,7 +1724,7 @@ var libc_pread_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 4ebcf217..4d26f7d0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -228,11 +228,11 @@ TEXT libc_flistxattr_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_flistxattr_trampoline_addr(SB), RODATA, $8 DATA ·libc_flistxattr_trampoline_addr(SB)/8, $libc_flistxattr_trampoline<>(SB) -TEXT libc_setattrlist_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_setattrlist(SB) +TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_utimensat(SB) -GLOBL ·libc_setattrlist_trampoline_addr(SB), RODATA, $8 -DATA ·libc_setattrlist_trampoline_addr(SB)/8, $libc_setattrlist_trampoline<>(SB) +GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_utimensat_trampoline_addr(SB)/8, $libc_utimensat_trampoline<>(SB) TEXT libc_fcntl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_fcntl(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go index 3e9bddb7..e9d9997e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go @@ -1420,7 +1420,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1437,7 +1437,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go index c72a462b..edd373b1 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go @@ -1420,7 +1420,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1437,7 +1437,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go index 530d5df9..82e9764b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go @@ -1420,7 +1420,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1437,7 +1437,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go index 71e7df9e..a6479acd 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go @@ -1420,7 +1420,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1437,7 +1437,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 93edda4c..bc4a2753 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -231,6 +231,16 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Waitid(idType int, id int, info *Siginfo, options int, rusage *Rusage) (err error) { + _, _, e1 := Syscall6(SYS_WAITID, uintptr(idType), uintptr(id), uintptr(unsafe.Pointer(info)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func KeyctlInt(cmd int, arg2 int, arg3 int, arg4 int, arg5 int) (ret int, err error) { r0, _, e1 := Syscall6(SYS_KEYCTL, uintptr(cmd), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) ret = int(r0) @@ -818,6 +828,49 @@ func Fsync(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fsmount(fd int, flags int, mountAttrs int) (fsfd int, err error) { + r0, _, e1 := Syscall(SYS_FSMOUNT, uintptr(fd), uintptr(flags), uintptr(mountAttrs)) + fsfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsopen(fsName string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsName) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_FSOPEN, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fspick(dirfd int, pathName string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathName) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_FSPICK, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdents(fd int, buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { @@ -1195,6 +1248,26 @@ func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MoveMount(fromDirfd int, fromPathName string, toDirfd int, toPathName string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fromPathName) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(toPathName) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOVE_MOUNT, uintptr(fromDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(toDirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { @@ -1205,6 +1278,22 @@ func Nanosleep(time *Timespec, leftover *Timespec) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func OpenTree(dfd int, fileName string, flags uint) (r int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fileName) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN_TREE, uintptr(dfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + r = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func PerfEventOpen(attr *PerfEventAttr, pid int, cpu int, groupFd int, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_PERF_EVENT_OPEN, uintptr(unsafe.Pointer(attr)), uintptr(pid), uintptr(cpu), uintptr(groupFd), uintptr(flags), 0) fd = int(r0) @@ -1992,6 +2081,16 @@ func PidfdGetfd(pidfd int, targetfd int, flags int) (fd int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func PidfdSendSignal(pidfd int, sig Signal, info *Siginfo, flags int) (err error) { + _, _, e1 := Syscall6(SYS_PIDFD_SEND_SIGNAL, uintptr(pidfd), uintptr(sig), uintptr(unsafe.Pointer(info)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func shmat(id int, addr uintptr, flag int) (ret uintptr, err error) { r0, _, e1 := Syscall(SYS_SHMAT, uintptr(id), uintptr(addr), uintptr(flag)) ret = uintptr(r0) @@ -2032,3 +2131,23 @@ func shmget(key int, size int, flag int) (id int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getitimer(which int, currValue *Itimerval) (err error) { + _, _, e1 := Syscall(SYS_GETITIMER, uintptr(which), uintptr(unsafe.Pointer(currValue)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setitimer(which int, newValue *Itimerval, oldValue *Itimerval) (err error) { + _, _, e1 := Syscall(SYS_SETITIMER, uintptr(which), uintptr(unsafe.Pointer(newValue)), uintptr(unsafe.Pointer(oldValue))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index ff90c81e..88af526b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -1,4 +1,4 @@ -// go run mksyscall.go -l32 -tags linux,386 syscall_linux.go syscall_linux_386.go +// go run mksyscall.go -l32 -tags linux,386 syscall_linux.go syscall_linux_386.go syscall_linux_alarm.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && 386 @@ -200,7 +200,7 @@ func Lstat(path string, stat *Stat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -217,7 +217,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -524,3 +524,14 @@ func utimes(path string, times *[2]Timeval) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Alarm(seconds uint) (remaining uint, err error) { + r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) + remaining = uint(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index fa7d3dbe..2a0c4aa6 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -1,4 +1,4 @@ -// go run mksyscall.go -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go +// go run mksyscall.go -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go syscall_linux_alarm.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && amd64 @@ -215,6 +215,17 @@ func Listen(s int, n int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdSecret(flags int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_MEMFD_SECRET, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Pause() (err error) { _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) if e1 != 0 { @@ -225,7 +236,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -242,7 +253,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -444,17 +455,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) @@ -691,3 +691,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Alarm(seconds uint) (remaining uint, err error) { + r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) + remaining = uint(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go index 654f9153..4882bde3 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -46,17 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) @@ -549,7 +538,7 @@ func utimes(path string, times *[2]Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -566,7 +555,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go index e893f987..9f8c24e4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -180,7 +180,18 @@ func Listen(s int, n int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func MemfdSecret(flags int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_MEMFD_SECRET, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -197,7 +208,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -389,17 +400,6 @@ func Truncate(path string, length int64) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go new file mode 100644 index 00000000..8cdfbe71 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go @@ -0,0 +1,552 @@ +// go run mksyscall.go -tags linux,loong64 syscall_linux.go syscall_linux_loong64.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build linux && loong64 +// +build linux,loong64 + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) { + _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_PWAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fadvise(fd int, offset int64, length int64, advice int) (err error) { + _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FSTATAT, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _ := RawSyscallNoError(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _ := RawSyscallNoError(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _ := RawSyscallNoError(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _ := RawSyscallNoError(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setfsgid(gid int) (prev int, err error) { + r0, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + prev = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setfsuid(uid int) (prev int, err error) { + r0, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + prev = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(cmdline) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go index 6d155288..d7d6f424 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go @@ -1,4 +1,4 @@ -// go run mksyscall.go -b32 -arm -tags linux,mips syscall_linux.go syscall_linux_mipsx.go +// go run mksyscall.go -b32 -arm -tags linux,mips syscall_linux.go syscall_linux_mipsx.go syscall_linux_alarm.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && mips @@ -150,7 +150,7 @@ func Listen(s int, n int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -167,7 +167,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -344,17 +344,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) @@ -702,3 +691,14 @@ func setrlimit(resource int, rlim *rlimit32) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Alarm(seconds uint) (remaining uint, err error) { + r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) + remaining = uint(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index 1e20d72d..7f1f8e65 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -1,4 +1,4 @@ -// go run mksyscall.go -tags linux,mips64 syscall_linux.go syscall_linux_mips64x.go +// go run mksyscall.go -tags linux,mips64 syscall_linux.go syscall_linux_mips64x.go syscall_linux_alarm.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && mips64 @@ -180,7 +180,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -197,7 +197,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -399,17 +399,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) @@ -696,3 +685,14 @@ func stat(path string, st *stat_t) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Alarm(seconds uint) (remaining uint, err error) { + r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) + remaining = uint(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go index 82b5e2d9..f933d0f5 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -180,7 +180,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -197,7 +197,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -399,17 +399,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go index a0440c1d..297d0a99 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go @@ -1,4 +1,4 @@ -// go run mksyscall.go -l32 -arm -tags linux,mipsle syscall_linux.go syscall_linux_mipsx.go +// go run mksyscall.go -l32 -arm -tags linux,mipsle syscall_linux.go syscall_linux_mipsx.go syscall_linux_alarm.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && mipsle @@ -150,7 +150,7 @@ func Listen(s int, n int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -167,7 +167,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -344,17 +344,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) @@ -702,3 +691,14 @@ func setrlimit(resource int, rlim *rlimit32) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Alarm(seconds uint) (remaining uint, err error) { + r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) + remaining = uint(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go index 5864b9ca..2e32e7a4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go @@ -1,4 +1,4 @@ -// go run mksyscall.go -b32 -tags linux,ppc syscall_linux.go syscall_linux_ppc.go +// go run mksyscall.go -b32 -tags linux,ppc syscall_linux.go syscall_linux_ppc.go syscall_linux_alarm.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && ppc @@ -210,7 +210,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -227,7 +227,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -409,17 +409,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) @@ -707,3 +696,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Alarm(seconds uint) (remaining uint, err error) { + r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) + remaining = uint(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index beeb49e3..3c531704 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -1,4 +1,4 @@ -// go run mksyscall.go -tags linux,ppc64 syscall_linux.go syscall_linux_ppc64x.go +// go run mksyscall.go -tags linux,ppc64 syscall_linux.go syscall_linux_ppc64x.go syscall_linux_alarm.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && ppc64 @@ -240,7 +240,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -257,7 +257,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -475,17 +475,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) @@ -753,3 +742,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Alarm(seconds uint) (remaining uint, err error) { + r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) + remaining = uint(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 53139b82..a00c6744 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -1,4 +1,4 @@ -// go run mksyscall.go -tags linux,ppc64le syscall_linux.go syscall_linux_ppc64x.go +// go run mksyscall.go -tags linux,ppc64le syscall_linux.go syscall_linux_ppc64x.go syscall_linux_alarm.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && ppc64le @@ -240,7 +240,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -257,7 +257,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -475,17 +475,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) @@ -753,3 +742,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Alarm(seconds uint) (remaining uint, err error) { + r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) + remaining = uint(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go index 63b393b8..a1a9bcbb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go @@ -180,7 +180,7 @@ func Listen(s int, n int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -197,7 +197,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -369,17 +369,6 @@ func Truncate(path string, length int64) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index 202add37..e0dabc60 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -1,4 +1,4 @@ -// go run mksyscall.go -tags linux,s390x syscall_linux.go syscall_linux_s390x.go +// go run mksyscall.go -tags linux,s390x syscall_linux.go syscall_linux_s390x.go syscall_linux_alarm.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && s390x @@ -210,7 +210,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -227,7 +227,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -533,3 +533,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Alarm(seconds uint) (remaining uint, err error) { + r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) + remaining = uint(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go index 2ab268c3..368623c0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go @@ -1,4 +1,4 @@ -// go run mksyscall.go -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go +// go run mksyscall.go -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go syscall_linux_alarm.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && sparc64 @@ -220,7 +220,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -237,7 +237,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -455,17 +455,6 @@ func Truncate(path string, length int64) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) fd = int(r0) @@ -697,3 +686,14 @@ func utimes(path string, times *[2]Timeval) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Alarm(seconds uint) (remaining uint, err error) { + r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) + remaining = uint(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go index 51d0c074..4af561a4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go @@ -1330,7 +1330,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1347,7 +1347,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go index df2efb6d..3b90e944 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go @@ -1330,7 +1330,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1347,7 +1347,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go index c8536c2c..890f4ccd 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go @@ -1330,7 +1330,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1347,7 +1347,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go index 8b981bfc..c79f071f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go @@ -1330,7 +1330,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1347,7 +1347,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 8f80f4ad..a057fc5d 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1128,7 +1128,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1145,7 +1145,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 3a47aca7..04db8fa2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1128,7 +1128,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1145,7 +1145,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index 883a9b45..69f80300 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1128,7 +1128,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1145,7 +1145,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index aac7fdc9..c96a5051 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1128,7 +1128,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1145,7 +1145,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index 87761874..016d959b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1128,7 +1128,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1145,7 +1145,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index b5f926ce..d12f4fbf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -227,8 +227,8 @@ import ( //go:linkname procOpenat libc_openat //go:linkname procPathconf libc_pathconf //go:linkname procPause libc_pause -//go:linkname procPread libc_pread -//go:linkname procPwrite libc_pwrite +//go:linkname procpread libc_pread +//go:linkname procpwrite libc_pwrite //go:linkname procread libc_read //go:linkname procReadlink libc_readlink //go:linkname procRename libc_rename @@ -364,8 +364,8 @@ var ( procOpenat, procPathconf, procPause, - procPread, - procPwrite, + procpread, + procpwrite, procread, procReadlink, procRename, @@ -1380,12 +1380,12 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { _p0 = &p[0] } - r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPread)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procpread)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -1395,12 +1395,12 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { _p0 = &p[0] } - r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPwrite)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procpwrite)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) n = int(r0) if e1 != 0 { err = e1 diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index cac1f758..62192e1d 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -446,4 +446,5 @@ const ( SYS_MEMFD_SECRET = 447 SYS_PROCESS_MRELEASE = 448 SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index f327e4a0..490aab5d 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -368,4 +368,5 @@ const ( SYS_MEMFD_SECRET = 447 SYS_PROCESS_MRELEASE = 448 SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index fb06a08d..aca17b6f 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -410,4 +410,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index 58285646..54b4dfa5 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -313,4 +313,5 @@ const ( SYS_MEMFD_SECRET = 447 SYS_PROCESS_MRELEASE = 448 SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go new file mode 100644 index 00000000..e443f9a3 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -0,0 +1,313 @@ +// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build loong64 && linux +// +build loong64,linux + +package unix + +const ( + SYS_IO_SETUP = 0 + SYS_IO_DESTROY = 1 + SYS_IO_SUBMIT = 2 + SYS_IO_CANCEL = 3 + SYS_IO_GETEVENTS = 4 + SYS_SETXATTR = 5 + SYS_LSETXATTR = 6 + SYS_FSETXATTR = 7 + SYS_GETXATTR = 8 + SYS_LGETXATTR = 9 + SYS_FGETXATTR = 10 + SYS_LISTXATTR = 11 + SYS_LLISTXATTR = 12 + SYS_FLISTXATTR = 13 + SYS_REMOVEXATTR = 14 + SYS_LREMOVEXATTR = 15 + SYS_FREMOVEXATTR = 16 + SYS_GETCWD = 17 + SYS_LOOKUP_DCOOKIE = 18 + SYS_EVENTFD2 = 19 + SYS_EPOLL_CREATE1 = 20 + SYS_EPOLL_CTL = 21 + SYS_EPOLL_PWAIT = 22 + SYS_DUP = 23 + SYS_DUP3 = 24 + SYS_FCNTL = 25 + SYS_INOTIFY_INIT1 = 26 + SYS_INOTIFY_ADD_WATCH = 27 + SYS_INOTIFY_RM_WATCH = 28 + SYS_IOCTL = 29 + SYS_IOPRIO_SET = 30 + SYS_IOPRIO_GET = 31 + SYS_FLOCK = 32 + SYS_MKNODAT = 33 + SYS_MKDIRAT = 34 + SYS_UNLINKAT = 35 + SYS_SYMLINKAT = 36 + SYS_LINKAT = 37 + SYS_UMOUNT2 = 39 + SYS_MOUNT = 40 + SYS_PIVOT_ROOT = 41 + SYS_NFSSERVCTL = 42 + SYS_STATFS = 43 + SYS_FSTATFS = 44 + SYS_TRUNCATE = 45 + SYS_FTRUNCATE = 46 + SYS_FALLOCATE = 47 + SYS_FACCESSAT = 48 + SYS_CHDIR = 49 + SYS_FCHDIR = 50 + SYS_CHROOT = 51 + SYS_FCHMOD = 52 + SYS_FCHMODAT = 53 + SYS_FCHOWNAT = 54 + SYS_FCHOWN = 55 + SYS_OPENAT = 56 + SYS_CLOSE = 57 + SYS_VHANGUP = 58 + SYS_PIPE2 = 59 + SYS_QUOTACTL = 60 + SYS_GETDENTS64 = 61 + SYS_LSEEK = 62 + SYS_READ = 63 + SYS_WRITE = 64 + SYS_READV = 65 + SYS_WRITEV = 66 + SYS_PREAD64 = 67 + SYS_PWRITE64 = 68 + SYS_PREADV = 69 + SYS_PWRITEV = 70 + SYS_SENDFILE = 71 + SYS_PSELECT6 = 72 + SYS_PPOLL = 73 + SYS_SIGNALFD4 = 74 + SYS_VMSPLICE = 75 + SYS_SPLICE = 76 + SYS_TEE = 77 + SYS_READLINKAT = 78 + SYS_FSTATAT = 79 + SYS_FSTAT = 80 + SYS_SYNC = 81 + SYS_FSYNC = 82 + SYS_FDATASYNC = 83 + SYS_SYNC_FILE_RANGE = 84 + SYS_TIMERFD_CREATE = 85 + SYS_TIMERFD_SETTIME = 86 + SYS_TIMERFD_GETTIME = 87 + SYS_UTIMENSAT = 88 + SYS_ACCT = 89 + SYS_CAPGET = 90 + SYS_CAPSET = 91 + SYS_PERSONALITY = 92 + SYS_EXIT = 93 + SYS_EXIT_GROUP = 94 + SYS_WAITID = 95 + SYS_SET_TID_ADDRESS = 96 + SYS_UNSHARE = 97 + SYS_FUTEX = 98 + SYS_SET_ROBUST_LIST = 99 + SYS_GET_ROBUST_LIST = 100 + SYS_NANOSLEEP = 101 + SYS_GETITIMER = 102 + SYS_SETITIMER = 103 + SYS_KEXEC_LOAD = 104 + SYS_INIT_MODULE = 105 + SYS_DELETE_MODULE = 106 + SYS_TIMER_CREATE = 107 + SYS_TIMER_GETTIME = 108 + SYS_TIMER_GETOVERRUN = 109 + SYS_TIMER_SETTIME = 110 + SYS_TIMER_DELETE = 111 + SYS_CLOCK_SETTIME = 112 + SYS_CLOCK_GETTIME = 113 + SYS_CLOCK_GETRES = 114 + SYS_CLOCK_NANOSLEEP = 115 + SYS_SYSLOG = 116 + SYS_PTRACE = 117 + SYS_SCHED_SETPARAM = 118 + SYS_SCHED_SETSCHEDULER = 119 + SYS_SCHED_GETSCHEDULER = 120 + SYS_SCHED_GETPARAM = 121 + SYS_SCHED_SETAFFINITY = 122 + SYS_SCHED_GETAFFINITY = 123 + SYS_SCHED_YIELD = 124 + SYS_SCHED_GET_PRIORITY_MAX = 125 + SYS_SCHED_GET_PRIORITY_MIN = 126 + SYS_SCHED_RR_GET_INTERVAL = 127 + SYS_RESTART_SYSCALL = 128 + SYS_KILL = 129 + SYS_TKILL = 130 + SYS_TGKILL = 131 + SYS_SIGALTSTACK = 132 + SYS_RT_SIGSUSPEND = 133 + SYS_RT_SIGACTION = 134 + SYS_RT_SIGPROCMASK = 135 + SYS_RT_SIGPENDING = 136 + SYS_RT_SIGTIMEDWAIT = 137 + SYS_RT_SIGQUEUEINFO = 138 + SYS_RT_SIGRETURN = 139 + SYS_SETPRIORITY = 140 + SYS_GETPRIORITY = 141 + SYS_REBOOT = 142 + SYS_SETREGID = 143 + SYS_SETGID = 144 + SYS_SETREUID = 145 + SYS_SETUID = 146 + SYS_SETRESUID = 147 + SYS_GETRESUID = 148 + SYS_SETRESGID = 149 + SYS_GETRESGID = 150 + SYS_SETFSUID = 151 + SYS_SETFSGID = 152 + SYS_TIMES = 153 + SYS_SETPGID = 154 + SYS_GETPGID = 155 + SYS_GETSID = 156 + SYS_SETSID = 157 + SYS_GETGROUPS = 158 + SYS_SETGROUPS = 159 + SYS_UNAME = 160 + SYS_SETHOSTNAME = 161 + SYS_SETDOMAINNAME = 162 + SYS_GETRUSAGE = 165 + SYS_UMASK = 166 + SYS_PRCTL = 167 + SYS_GETCPU = 168 + SYS_GETTIMEOFDAY = 169 + SYS_SETTIMEOFDAY = 170 + SYS_ADJTIMEX = 171 + SYS_GETPID = 172 + SYS_GETPPID = 173 + SYS_GETUID = 174 + SYS_GETEUID = 175 + SYS_GETGID = 176 + SYS_GETEGID = 177 + SYS_GETTID = 178 + SYS_SYSINFO = 179 + SYS_MQ_OPEN = 180 + SYS_MQ_UNLINK = 181 + SYS_MQ_TIMEDSEND = 182 + SYS_MQ_TIMEDRECEIVE = 183 + SYS_MQ_NOTIFY = 184 + SYS_MQ_GETSETATTR = 185 + SYS_MSGGET = 186 + SYS_MSGCTL = 187 + SYS_MSGRCV = 188 + SYS_MSGSND = 189 + SYS_SEMGET = 190 + SYS_SEMCTL = 191 + SYS_SEMTIMEDOP = 192 + SYS_SEMOP = 193 + SYS_SHMGET = 194 + SYS_SHMCTL = 195 + SYS_SHMAT = 196 + SYS_SHMDT = 197 + SYS_SOCKET = 198 + SYS_SOCKETPAIR = 199 + SYS_BIND = 200 + SYS_LISTEN = 201 + SYS_ACCEPT = 202 + SYS_CONNECT = 203 + SYS_GETSOCKNAME = 204 + SYS_GETPEERNAME = 205 + SYS_SENDTO = 206 + SYS_RECVFROM = 207 + SYS_SETSOCKOPT = 208 + SYS_GETSOCKOPT = 209 + SYS_SHUTDOWN = 210 + SYS_SENDMSG = 211 + SYS_RECVMSG = 212 + SYS_READAHEAD = 213 + SYS_BRK = 214 + SYS_MUNMAP = 215 + SYS_MREMAP = 216 + SYS_ADD_KEY = 217 + SYS_REQUEST_KEY = 218 + SYS_KEYCTL = 219 + SYS_CLONE = 220 + SYS_EXECVE = 221 + SYS_MMAP = 222 + SYS_FADVISE64 = 223 + SYS_SWAPON = 224 + SYS_SWAPOFF = 225 + SYS_MPROTECT = 226 + SYS_MSYNC = 227 + SYS_MLOCK = 228 + SYS_MUNLOCK = 229 + SYS_MLOCKALL = 230 + SYS_MUNLOCKALL = 231 + SYS_MINCORE = 232 + SYS_MADVISE = 233 + SYS_REMAP_FILE_PAGES = 234 + SYS_MBIND = 235 + SYS_GET_MEMPOLICY = 236 + SYS_SET_MEMPOLICY = 237 + SYS_MIGRATE_PAGES = 238 + SYS_MOVE_PAGES = 239 + SYS_RT_TGSIGQUEUEINFO = 240 + SYS_PERF_EVENT_OPEN = 241 + SYS_ACCEPT4 = 242 + SYS_RECVMMSG = 243 + SYS_ARCH_SPECIFIC_SYSCALL = 244 + SYS_WAIT4 = 260 + SYS_PRLIMIT64 = 261 + SYS_FANOTIFY_INIT = 262 + SYS_FANOTIFY_MARK = 263 + SYS_NAME_TO_HANDLE_AT = 264 + SYS_OPEN_BY_HANDLE_AT = 265 + SYS_CLOCK_ADJTIME = 266 + SYS_SYNCFS = 267 + SYS_SETNS = 268 + SYS_SENDMMSG = 269 + SYS_PROCESS_VM_READV = 270 + SYS_PROCESS_VM_WRITEV = 271 + SYS_KCMP = 272 + SYS_FINIT_MODULE = 273 + SYS_SCHED_SETATTR = 274 + SYS_SCHED_GETATTR = 275 + SYS_RENAMEAT2 = 276 + SYS_SECCOMP = 277 + SYS_GETRANDOM = 278 + SYS_MEMFD_CREATE = 279 + SYS_BPF = 280 + SYS_EXECVEAT = 281 + SYS_USERFAULTFD = 282 + SYS_MEMBARRIER = 283 + SYS_MLOCK2 = 284 + SYS_COPY_FILE_RANGE = 285 + SYS_PREADV2 = 286 + SYS_PWRITEV2 = 287 + SYS_PKEY_MPROTECT = 288 + SYS_PKEY_ALLOC = 289 + SYS_PKEY_FREE = 290 + SYS_STATX = 291 + SYS_IO_PGETEVENTS = 292 + SYS_RSEQ = 293 + SYS_KEXEC_FILE_LOAD = 294 + SYS_PIDFD_SEND_SIGNAL = 424 + SYS_IO_URING_SETUP = 425 + SYS_IO_URING_ENTER = 426 + SYS_IO_URING_REGISTER = 427 + SYS_OPEN_TREE = 428 + SYS_MOVE_MOUNT = 429 + SYS_FSOPEN = 430 + SYS_FSCONFIG = 431 + SYS_FSMOUNT = 432 + SYS_FSPICK = 433 + SYS_PIDFD_OPEN = 434 + SYS_CLONE3 = 435 + SYS_CLOSE_RANGE = 436 + SYS_OPENAT2 = 437 + SYS_PIDFD_GETFD = 438 + SYS_FACCESSAT2 = 439 + SYS_PROCESS_MADVISE = 440 + SYS_EPOLL_PWAIT2 = 441 + SYS_MOUNT_SETATTR = 442 + SYS_QUOTACTL_FD = 443 + SYS_LANDLOCK_CREATE_RULESET = 444 + SYS_LANDLOCK_ADD_RULE = 445 + SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index 3b0418e6..65a99efc 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -430,4 +430,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 4446 SYS_PROCESS_MRELEASE = 4448 SYS_FUTEX_WAITV = 4449 + SYS_SET_MEMPOLICY_HOME_NODE = 4450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 314ebf16..841c8a66 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -360,4 +360,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 5446 SYS_PROCESS_MRELEASE = 5448 SYS_FUTEX_WAITV = 5449 + SYS_SET_MEMPOLICY_HOME_NODE = 5450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index b8fbb937..e26a7c76 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -360,4 +360,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 5446 SYS_PROCESS_MRELEASE = 5448 SYS_FUTEX_WAITV = 5449 + SYS_SET_MEMPOLICY_HOME_NODE = 5450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index ee309b2b..26447260 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -430,4 +430,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 4446 SYS_PROCESS_MRELEASE = 4448 SYS_FUTEX_WAITV = 4449 + SYS_SET_MEMPOLICY_HOME_NODE = 4450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index ac374810..26aefc18 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -437,4 +437,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index 5aa47211..8d4cd9d9 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -409,4 +409,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 0793ac1a..3b405d1f 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -409,4 +409,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index a520962e..c3a5af86 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -311,4 +311,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index d1738586..8ffa6646 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -374,4 +374,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index dfd5660f..6a39640e 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -388,4 +388,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 66788f15..9962d26b 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -24,6 +24,11 @@ type ItimerSpec struct { Value Timespec } +type Itimerval struct { + Interval Timeval + Value Timeval +} + const ( TIME_OK = 0x0 TIME_INS = 0x1 @@ -749,6 +754,25 @@ const ( AT_SYMLINK_NOFOLLOW = 0x100 AT_EACCESS = 0x200 + + OPEN_TREE_CLONE = 0x1 + + MOVE_MOUNT_F_SYMLINKS = 0x1 + MOVE_MOUNT_F_AUTOMOUNTS = 0x2 + MOVE_MOUNT_F_EMPTY_PATH = 0x4 + MOVE_MOUNT_T_SYMLINKS = 0x10 + MOVE_MOUNT_T_AUTOMOUNTS = 0x20 + MOVE_MOUNT_T_EMPTY_PATH = 0x40 + MOVE_MOUNT_SET_GROUP = 0x100 + + FSOPEN_CLOEXEC = 0x1 + + FSPICK_CLOEXEC = 0x1 + FSPICK_SYMLINK_NOFOLLOW = 0x2 + FSPICK_NO_AUTOMOUNT = 0x4 + FSPICK_EMPTY_PATH = 0x8 + + FSMOUNT_CLOEXEC = 0x1 ) type OpenHow struct { @@ -3614,7 +3638,7 @@ const ( ETHTOOL_A_RINGS_RX_MINI = 0x7 ETHTOOL_A_RINGS_RX_JUMBO = 0x8 ETHTOOL_A_RINGS_TX = 0x9 - ETHTOOL_A_RINGS_MAX = 0x9 + ETHTOOL_A_RINGS_MAX = 0xa ETHTOOL_A_CHANNELS_UNSPEC = 0x0 ETHTOOL_A_CHANNELS_HEADER = 0x1 ETHTOOL_A_CHANNELS_RX_MAX = 0x2 @@ -3766,6 +3790,8 @@ const ( ETHTOOL_A_TUNNEL_INFO_MAX = 0x2 ) +const SPEED_UNKNOWN = -0x1 + type EthtoolDrvinfo struct { Cmd uint32 Driver [32]byte @@ -4065,3 +4091,1500 @@ const ( NL_POLICY_TYPE_ATTR_MASK = 0xc NL_POLICY_TYPE_ATTR_MAX = 0xc ) + +type CANBitTiming struct { + Bitrate uint32 + Sample_point uint32 + Tq uint32 + Prop_seg uint32 + Phase_seg1 uint32 + Phase_seg2 uint32 + Sjw uint32 + Brp uint32 +} + +type CANBitTimingConst struct { + Name [16]uint8 + Tseg1_min uint32 + Tseg1_max uint32 + Tseg2_min uint32 + Tseg2_max uint32 + Sjw_max uint32 + Brp_min uint32 + Brp_max uint32 + Brp_inc uint32 +} + +type CANClock struct { + Freq uint32 +} + +type CANBusErrorCounters struct { + Txerr uint16 + Rxerr uint16 +} + +type CANCtrlMode struct { + Mask uint32 + Flags uint32 +} + +type CANDeviceStats struct { + Bus_error uint32 + Error_warning uint32 + Error_passive uint32 + Bus_off uint32 + Arbitration_lost uint32 + Restarts uint32 +} + +const ( + CAN_STATE_ERROR_ACTIVE = 0x0 + CAN_STATE_ERROR_WARNING = 0x1 + CAN_STATE_ERROR_PASSIVE = 0x2 + CAN_STATE_BUS_OFF = 0x3 + CAN_STATE_STOPPED = 0x4 + CAN_STATE_SLEEPING = 0x5 + CAN_STATE_MAX = 0x6 +) + +const ( + IFLA_CAN_UNSPEC = 0x0 + IFLA_CAN_BITTIMING = 0x1 + IFLA_CAN_BITTIMING_CONST = 0x2 + IFLA_CAN_CLOCK = 0x3 + IFLA_CAN_STATE = 0x4 + IFLA_CAN_CTRLMODE = 0x5 + IFLA_CAN_RESTART_MS = 0x6 + IFLA_CAN_RESTART = 0x7 + IFLA_CAN_BERR_COUNTER = 0x8 + IFLA_CAN_DATA_BITTIMING = 0x9 + IFLA_CAN_DATA_BITTIMING_CONST = 0xa + IFLA_CAN_TERMINATION = 0xb + IFLA_CAN_TERMINATION_CONST = 0xc + IFLA_CAN_BITRATE_CONST = 0xd + IFLA_CAN_DATA_BITRATE_CONST = 0xe + IFLA_CAN_BITRATE_MAX = 0xf +) + +type KCMAttach struct { + Fd int32 + Bpf_fd int32 +} + +type KCMUnattach struct { + Fd int32 +} + +type KCMClone struct { + Fd int32 +} + +const ( + NL80211_AC_BE = 0x2 + NL80211_AC_BK = 0x3 + NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED = 0x0 + NL80211_ACL_POLICY_DENY_UNLESS_LISTED = 0x1 + NL80211_AC_VI = 0x1 + NL80211_AC_VO = 0x0 + NL80211_ATTR_4ADDR = 0x53 + NL80211_ATTR_ACK = 0x5c + NL80211_ATTR_ACK_SIGNAL = 0x107 + NL80211_ATTR_ACL_POLICY = 0xa5 + NL80211_ATTR_ADMITTED_TIME = 0xd4 + NL80211_ATTR_AIRTIME_WEIGHT = 0x112 + NL80211_ATTR_AKM_SUITES = 0x4c + NL80211_ATTR_AP_ISOLATE = 0x60 + NL80211_ATTR_AUTH_DATA = 0x9c + NL80211_ATTR_AUTH_TYPE = 0x35 + NL80211_ATTR_BANDS = 0xef + NL80211_ATTR_BEACON_HEAD = 0xe + NL80211_ATTR_BEACON_INTERVAL = 0xc + NL80211_ATTR_BEACON_TAIL = 0xf + NL80211_ATTR_BG_SCAN_PERIOD = 0x98 + NL80211_ATTR_BSS_BASIC_RATES = 0x24 + NL80211_ATTR_BSS = 0x2f + NL80211_ATTR_BSS_CTS_PROT = 0x1c + NL80211_ATTR_BSS_HT_OPMODE = 0x6d + NL80211_ATTR_BSSID = 0xf5 + NL80211_ATTR_BSS_SELECT = 0xe3 + NL80211_ATTR_BSS_SHORT_PREAMBLE = 0x1d + NL80211_ATTR_BSS_SHORT_SLOT_TIME = 0x1e + NL80211_ATTR_CENTER_FREQ1 = 0xa0 + NL80211_ATTR_CENTER_FREQ1_OFFSET = 0x123 + NL80211_ATTR_CENTER_FREQ2 = 0xa1 + NL80211_ATTR_CHANNEL_WIDTH = 0x9f + NL80211_ATTR_CH_SWITCH_BLOCK_TX = 0xb8 + NL80211_ATTR_CH_SWITCH_COUNT = 0xb7 + NL80211_ATTR_CIPHER_SUITE_GROUP = 0x4a + NL80211_ATTR_CIPHER_SUITES = 0x39 + NL80211_ATTR_CIPHER_SUITES_PAIRWISE = 0x49 + NL80211_ATTR_CNTDWN_OFFS_BEACON = 0xba + NL80211_ATTR_CNTDWN_OFFS_PRESP = 0xbb + NL80211_ATTR_COALESCE_RULE = 0xb6 + NL80211_ATTR_COALESCE_RULE_CONDITION = 0x2 + NL80211_ATTR_COALESCE_RULE_DELAY = 0x1 + NL80211_ATTR_COALESCE_RULE_MAX = 0x3 + NL80211_ATTR_COALESCE_RULE_PKT_PATTERN = 0x3 + NL80211_ATTR_CONN_FAILED_REASON = 0x9b + NL80211_ATTR_CONTROL_PORT = 0x44 + NL80211_ATTR_CONTROL_PORT_ETHERTYPE = 0x66 + NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT = 0x67 + NL80211_ATTR_CONTROL_PORT_NO_PREAUTH = 0x11e + NL80211_ATTR_CONTROL_PORT_OVER_NL80211 = 0x108 + NL80211_ATTR_COOKIE = 0x58 + NL80211_ATTR_CQM_BEACON_LOSS_EVENT = 0x8 + NL80211_ATTR_CQM = 0x5e + NL80211_ATTR_CQM_MAX = 0x9 + NL80211_ATTR_CQM_PKT_LOSS_EVENT = 0x4 + NL80211_ATTR_CQM_RSSI_HYST = 0x2 + NL80211_ATTR_CQM_RSSI_LEVEL = 0x9 + NL80211_ATTR_CQM_RSSI_THOLD = 0x1 + NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT = 0x3 + NL80211_ATTR_CQM_TXE_INTVL = 0x7 + NL80211_ATTR_CQM_TXE_PKTS = 0x6 + NL80211_ATTR_CQM_TXE_RATE = 0x5 + NL80211_ATTR_CRIT_PROT_ID = 0xb3 + NL80211_ATTR_CSA_C_OFF_BEACON = 0xba + NL80211_ATTR_CSA_C_OFF_PRESP = 0xbb + NL80211_ATTR_CSA_C_OFFSETS_TX = 0xcd + NL80211_ATTR_CSA_IES = 0xb9 + NL80211_ATTR_DEVICE_AP_SME = 0x8d + NL80211_ATTR_DFS_CAC_TIME = 0x7 + NL80211_ATTR_DFS_REGION = 0x92 + NL80211_ATTR_DISABLE_HE = 0x12d + NL80211_ATTR_DISABLE_HT = 0x93 + NL80211_ATTR_DISABLE_VHT = 0xaf + NL80211_ATTR_DISCONNECTED_BY_AP = 0x47 + NL80211_ATTR_DONT_WAIT_FOR_ACK = 0x8e + NL80211_ATTR_DTIM_PERIOD = 0xd + NL80211_ATTR_DURATION = 0x57 + NL80211_ATTR_EXT_CAPA = 0xa9 + NL80211_ATTR_EXT_CAPA_MASK = 0xaa + NL80211_ATTR_EXTERNAL_AUTH_ACTION = 0x104 + NL80211_ATTR_EXTERNAL_AUTH_SUPPORT = 0x105 + NL80211_ATTR_EXT_FEATURES = 0xd9 + NL80211_ATTR_FEATURE_FLAGS = 0x8f + NL80211_ATTR_FILS_CACHE_ID = 0xfd + NL80211_ATTR_FILS_DISCOVERY = 0x126 + NL80211_ATTR_FILS_ERP_NEXT_SEQ_NUM = 0xfb + NL80211_ATTR_FILS_ERP_REALM = 0xfa + NL80211_ATTR_FILS_ERP_RRK = 0xfc + NL80211_ATTR_FILS_ERP_USERNAME = 0xf9 + NL80211_ATTR_FILS_KEK = 0xf2 + NL80211_ATTR_FILS_NONCES = 0xf3 + NL80211_ATTR_FRAME = 0x33 + NL80211_ATTR_FRAME_MATCH = 0x5b + NL80211_ATTR_FRAME_TYPE = 0x65 + NL80211_ATTR_FREQ_AFTER = 0x3b + NL80211_ATTR_FREQ_BEFORE = 0x3a + NL80211_ATTR_FREQ_FIXED = 0x3c + NL80211_ATTR_FREQ_RANGE_END = 0x3 + NL80211_ATTR_FREQ_RANGE_MAX_BW = 0x4 + NL80211_ATTR_FREQ_RANGE_START = 0x2 + NL80211_ATTR_FTM_RESPONDER = 0x10e + NL80211_ATTR_FTM_RESPONDER_STATS = 0x10f + NL80211_ATTR_GENERATION = 0x2e + NL80211_ATTR_HANDLE_DFS = 0xbf + NL80211_ATTR_HE_6GHZ_CAPABILITY = 0x125 + NL80211_ATTR_HE_BSS_COLOR = 0x11b + NL80211_ATTR_HE_CAPABILITY = 0x10d + NL80211_ATTR_HE_OBSS_PD = 0x117 + NL80211_ATTR_HIDDEN_SSID = 0x7e + NL80211_ATTR_HT_CAPABILITY = 0x1f + NL80211_ATTR_HT_CAPABILITY_MASK = 0x94 + NL80211_ATTR_IE_ASSOC_RESP = 0x80 + NL80211_ATTR_IE = 0x2a + NL80211_ATTR_IE_PROBE_RESP = 0x7f + NL80211_ATTR_IE_RIC = 0xb2 + NL80211_ATTR_IFACE_SOCKET_OWNER = 0xcc + NL80211_ATTR_IFINDEX = 0x3 + NL80211_ATTR_IFNAME = 0x4 + NL80211_ATTR_IFTYPE_AKM_SUITES = 0x11c + NL80211_ATTR_IFTYPE = 0x5 + NL80211_ATTR_IFTYPE_EXT_CAPA = 0xe6 + NL80211_ATTR_INACTIVITY_TIMEOUT = 0x96 + NL80211_ATTR_INTERFACE_COMBINATIONS = 0x78 + NL80211_ATTR_KEY_CIPHER = 0x9 + NL80211_ATTR_KEY = 0x50 + NL80211_ATTR_KEY_DATA = 0x7 + NL80211_ATTR_KEY_DEFAULT = 0xb + NL80211_ATTR_KEY_DEFAULT_MGMT = 0x28 + NL80211_ATTR_KEY_DEFAULT_TYPES = 0x6e + NL80211_ATTR_KEY_IDX = 0x8 + NL80211_ATTR_KEYS = 0x51 + NL80211_ATTR_KEY_SEQ = 0xa + NL80211_ATTR_KEY_TYPE = 0x37 + NL80211_ATTR_LOCAL_MESH_POWER_MODE = 0xa4 + NL80211_ATTR_LOCAL_STATE_CHANGE = 0x5f + NL80211_ATTR_MAC_ACL_MAX = 0xa7 + NL80211_ATTR_MAC_ADDRS = 0xa6 + NL80211_ATTR_MAC = 0x6 + NL80211_ATTR_MAC_HINT = 0xc8 + NL80211_ATTR_MAC_MASK = 0xd7 + NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca + NL80211_ATTR_MAX = 0x135 + NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4 + NL80211_ATTR_MAX_CSA_COUNTERS = 0xce + NL80211_ATTR_MAX_MATCH_SETS = 0x85 + NL80211_ATTR_MAX_NUM_PMKIDS = 0x56 + NL80211_ATTR_MAX_NUM_SCAN_SSIDS = 0x2b + NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS = 0xde + NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS = 0x7b + NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION = 0x6f + NL80211_ATTR_MAX_SCAN_IE_LEN = 0x38 + NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL = 0xdf + NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS = 0xe0 + NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN = 0x7c + NL80211_ATTR_MCAST_RATE = 0x6b + NL80211_ATTR_MDID = 0xb1 + NL80211_ATTR_MEASUREMENT_DURATION = 0xeb + NL80211_ATTR_MEASUREMENT_DURATION_MANDATORY = 0xec + NL80211_ATTR_MESH_CONFIG = 0x23 + NL80211_ATTR_MESH_ID = 0x18 + NL80211_ATTR_MESH_PEER_AID = 0xed + NL80211_ATTR_MESH_SETUP = 0x70 + NL80211_ATTR_MGMT_SUBTYPE = 0x29 + NL80211_ATTR_MNTR_FLAGS = 0x17 + NL80211_ATTR_MPATH_INFO = 0x1b + NL80211_ATTR_MPATH_NEXT_HOP = 0x1a + NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED = 0xf4 + NL80211_ATTR_MU_MIMO_FOLLOW_MAC_ADDR = 0xe8 + NL80211_ATTR_MU_MIMO_GROUP_DATA = 0xe7 + NL80211_ATTR_NAN_FUNC = 0xf0 + NL80211_ATTR_NAN_MASTER_PREF = 0xee + NL80211_ATTR_NAN_MATCH = 0xf1 + NL80211_ATTR_NETNS_FD = 0xdb + NL80211_ATTR_NOACK_MAP = 0x95 + NL80211_ATTR_NSS = 0x106 + NL80211_ATTR_OFFCHANNEL_TX_OK = 0x6c + NL80211_ATTR_OPER_CLASS = 0xd6 + NL80211_ATTR_OPMODE_NOTIF = 0xc2 + NL80211_ATTR_P2P_CTWINDOW = 0xa2 + NL80211_ATTR_P2P_OPPPS = 0xa3 + NL80211_ATTR_PAD = 0xe5 + NL80211_ATTR_PBSS = 0xe2 + NL80211_ATTR_PEER_AID = 0xb5 + NL80211_ATTR_PEER_MEASUREMENTS = 0x111 + NL80211_ATTR_PID = 0x52 + NL80211_ATTR_PMK = 0xfe + NL80211_ATTR_PMKID = 0x55 + NL80211_ATTR_PMK_LIFETIME = 0x11f + NL80211_ATTR_PMKR0_NAME = 0x102 + NL80211_ATTR_PMK_REAUTH_THRESHOLD = 0x120 + NL80211_ATTR_PMKSA_CANDIDATE = 0x86 + NL80211_ATTR_PORT_AUTHORIZED = 0x103 + NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN = 0x5 + NL80211_ATTR_POWER_RULE_MAX_EIRP = 0x6 + NL80211_ATTR_PREV_BSSID = 0x4f + NL80211_ATTR_PRIVACY = 0x46 + NL80211_ATTR_PROBE_RESP = 0x91 + NL80211_ATTR_PROBE_RESP_OFFLOAD = 0x90 + NL80211_ATTR_PROTOCOL_FEATURES = 0xad + NL80211_ATTR_PS_STATE = 0x5d + NL80211_ATTR_QOS_MAP = 0xc7 + NL80211_ATTR_RADAR_EVENT = 0xa8 + NL80211_ATTR_REASON_CODE = 0x36 + NL80211_ATTR_RECEIVE_MULTICAST = 0x121 + NL80211_ATTR_RECONNECT_REQUESTED = 0x12b + NL80211_ATTR_REG_ALPHA2 = 0x21 + NL80211_ATTR_REG_INDOOR = 0xdd + NL80211_ATTR_REG_INITIATOR = 0x30 + NL80211_ATTR_REG_RULE_FLAGS = 0x1 + NL80211_ATTR_REG_RULES = 0x22 + NL80211_ATTR_REG_TYPE = 0x31 + NL80211_ATTR_REKEY_DATA = 0x7a + NL80211_ATTR_REQ_IE = 0x4d + NL80211_ATTR_RESP_IE = 0x4e + NL80211_ATTR_ROAM_SUPPORT = 0x83 + NL80211_ATTR_RX_FRAME_TYPES = 0x64 + NL80211_ATTR_RXMGMT_FLAGS = 0xbc + NL80211_ATTR_RX_SIGNAL_DBM = 0x97 + NL80211_ATTR_S1G_CAPABILITY = 0x128 + NL80211_ATTR_S1G_CAPABILITY_MASK = 0x129 + NL80211_ATTR_SAE_DATA = 0x9c + NL80211_ATTR_SAE_PASSWORD = 0x115 + NL80211_ATTR_SAE_PWE = 0x12a + NL80211_ATTR_SAR_SPEC = 0x12c + NL80211_ATTR_SCAN_FLAGS = 0x9e + NL80211_ATTR_SCAN_FREQ_KHZ = 0x124 + NL80211_ATTR_SCAN_FREQUENCIES = 0x2c + NL80211_ATTR_SCAN_GENERATION = 0x2e + NL80211_ATTR_SCAN_SSIDS = 0x2d + NL80211_ATTR_SCAN_START_TIME_TSF_BSSID = 0xea + NL80211_ATTR_SCAN_START_TIME_TSF = 0xe9 + NL80211_ATTR_SCAN_SUPP_RATES = 0x7d + NL80211_ATTR_SCHED_SCAN_DELAY = 0xdc + NL80211_ATTR_SCHED_SCAN_INTERVAL = 0x77 + NL80211_ATTR_SCHED_SCAN_MATCH = 0x84 + NL80211_ATTR_SCHED_SCAN_MATCH_SSID = 0x1 + NL80211_ATTR_SCHED_SCAN_MAX_REQS = 0x100 + NL80211_ATTR_SCHED_SCAN_MULTI = 0xff + NL80211_ATTR_SCHED_SCAN_PLANS = 0xe1 + NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI = 0xf6 + NL80211_ATTR_SCHED_SCAN_RSSI_ADJUST = 0xf7 + NL80211_ATTR_SMPS_MODE = 0xd5 + NL80211_ATTR_SOCKET_OWNER = 0xcc + NL80211_ATTR_SOFTWARE_IFTYPES = 0x79 + NL80211_ATTR_SPLIT_WIPHY_DUMP = 0xae + NL80211_ATTR_SSID = 0x34 + NL80211_ATTR_STA_AID = 0x10 + NL80211_ATTR_STA_CAPABILITY = 0xab + NL80211_ATTR_STA_EXT_CAPABILITY = 0xac + NL80211_ATTR_STA_FLAGS2 = 0x43 + NL80211_ATTR_STA_FLAGS = 0x11 + NL80211_ATTR_STA_INFO = 0x15 + NL80211_ATTR_STA_LISTEN_INTERVAL = 0x12 + NL80211_ATTR_STA_PLINK_ACTION = 0x19 + NL80211_ATTR_STA_PLINK_STATE = 0x74 + NL80211_ATTR_STA_SUPPORTED_CHANNELS = 0xbd + NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES = 0xbe + NL80211_ATTR_STA_SUPPORTED_RATES = 0x13 + NL80211_ATTR_STA_SUPPORT_P2P_PS = 0xe4 + NL80211_ATTR_STATUS_CODE = 0x48 + NL80211_ATTR_STA_TX_POWER = 0x114 + NL80211_ATTR_STA_TX_POWER_SETTING = 0x113 + NL80211_ATTR_STA_VLAN = 0x14 + NL80211_ATTR_STA_WME = 0x81 + NL80211_ATTR_SUPPORT_10_MHZ = 0xc1 + NL80211_ATTR_SUPPORT_5_MHZ = 0xc0 + NL80211_ATTR_SUPPORT_AP_UAPSD = 0x82 + NL80211_ATTR_SUPPORTED_COMMANDS = 0x32 + NL80211_ATTR_SUPPORTED_IFTYPES = 0x20 + NL80211_ATTR_SUPPORT_IBSS_RSN = 0x68 + NL80211_ATTR_SUPPORT_MESH_AUTH = 0x73 + NL80211_ATTR_SURVEY_INFO = 0x54 + NL80211_ATTR_SURVEY_RADIO_STATS = 0xda + NL80211_ATTR_TDLS_ACTION = 0x88 + NL80211_ATTR_TDLS_DIALOG_TOKEN = 0x89 + NL80211_ATTR_TDLS_EXTERNAL_SETUP = 0x8c + NL80211_ATTR_TDLS_INITIATOR = 0xcf + NL80211_ATTR_TDLS_OPERATION = 0x8a + NL80211_ATTR_TDLS_PEER_CAPABILITY = 0xcb + NL80211_ATTR_TDLS_SUPPORT = 0x8b + NL80211_ATTR_TESTDATA = 0x45 + NL80211_ATTR_TID_CONFIG = 0x11d + NL80211_ATTR_TIMED_OUT = 0x41 + NL80211_ATTR_TIMEOUT = 0x110 + NL80211_ATTR_TIMEOUT_REASON = 0xf8 + NL80211_ATTR_TSID = 0xd2 + NL80211_ATTR_TWT_RESPONDER = 0x116 + NL80211_ATTR_TX_FRAME_TYPES = 0x63 + NL80211_ATTR_TX_NO_CCK_RATE = 0x87 + NL80211_ATTR_TXQ_LIMIT = 0x10a + NL80211_ATTR_TXQ_MEMORY_LIMIT = 0x10b + NL80211_ATTR_TXQ_QUANTUM = 0x10c + NL80211_ATTR_TXQ_STATS = 0x109 + NL80211_ATTR_TX_RATES = 0x5a + NL80211_ATTR_UNSOL_BCAST_PROBE_RESP = 0x127 + NL80211_ATTR_UNSPEC = 0x0 + NL80211_ATTR_USE_MFP = 0x42 + NL80211_ATTR_USER_PRIO = 0xd3 + NL80211_ATTR_USER_REG_HINT_TYPE = 0x9a + NL80211_ATTR_USE_RRM = 0xd0 + NL80211_ATTR_VENDOR_DATA = 0xc5 + NL80211_ATTR_VENDOR_EVENTS = 0xc6 + NL80211_ATTR_VENDOR_ID = 0xc3 + NL80211_ATTR_VENDOR_SUBCMD = 0xc4 + NL80211_ATTR_VHT_CAPABILITY = 0x9d + NL80211_ATTR_VHT_CAPABILITY_MASK = 0xb0 + NL80211_ATTR_VLAN_ID = 0x11a + NL80211_ATTR_WANT_1X_4WAY_HS = 0x101 + NL80211_ATTR_WDEV = 0x99 + NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX = 0x72 + NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX = 0x71 + NL80211_ATTR_WIPHY_ANTENNA_RX = 0x6a + NL80211_ATTR_WIPHY_ANTENNA_TX = 0x69 + NL80211_ATTR_WIPHY_BANDS = 0x16 + NL80211_ATTR_WIPHY_CHANNEL_TYPE = 0x27 + NL80211_ATTR_WIPHY = 0x1 + NL80211_ATTR_WIPHY_COVERAGE_CLASS = 0x59 + NL80211_ATTR_WIPHY_DYN_ACK = 0xd1 + NL80211_ATTR_WIPHY_EDMG_BW_CONFIG = 0x119 + NL80211_ATTR_WIPHY_EDMG_CHANNELS = 0x118 + NL80211_ATTR_WIPHY_FRAG_THRESHOLD = 0x3f + NL80211_ATTR_WIPHY_FREQ = 0x26 + NL80211_ATTR_WIPHY_FREQ_HINT = 0xc9 + NL80211_ATTR_WIPHY_FREQ_OFFSET = 0x122 + NL80211_ATTR_WIPHY_NAME = 0x2 + NL80211_ATTR_WIPHY_RETRY_LONG = 0x3e + NL80211_ATTR_WIPHY_RETRY_SHORT = 0x3d + NL80211_ATTR_WIPHY_RTS_THRESHOLD = 0x40 + NL80211_ATTR_WIPHY_SELF_MANAGED_REG = 0xd8 + NL80211_ATTR_WIPHY_TX_POWER_LEVEL = 0x62 + NL80211_ATTR_WIPHY_TX_POWER_SETTING = 0x61 + NL80211_ATTR_WIPHY_TXQ_PARAMS = 0x25 + NL80211_ATTR_WOWLAN_TRIGGERS = 0x75 + NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED = 0x76 + NL80211_ATTR_WPA_VERSIONS = 0x4b + NL80211_AUTHTYPE_AUTOMATIC = 0x8 + NL80211_AUTHTYPE_FILS_PK = 0x7 + NL80211_AUTHTYPE_FILS_SK = 0x5 + NL80211_AUTHTYPE_FILS_SK_PFS = 0x6 + NL80211_AUTHTYPE_FT = 0x2 + NL80211_AUTHTYPE_MAX = 0x7 + NL80211_AUTHTYPE_NETWORK_EAP = 0x3 + NL80211_AUTHTYPE_OPEN_SYSTEM = 0x0 + NL80211_AUTHTYPE_SAE = 0x4 + NL80211_AUTHTYPE_SHARED_KEY = 0x1 + NL80211_BAND_2GHZ = 0x0 + NL80211_BAND_5GHZ = 0x1 + NL80211_BAND_60GHZ = 0x2 + NL80211_BAND_6GHZ = 0x3 + NL80211_BAND_ATTR_EDMG_BW_CONFIG = 0xb + NL80211_BAND_ATTR_EDMG_CHANNELS = 0xa + NL80211_BAND_ATTR_FREQS = 0x1 + NL80211_BAND_ATTR_HT_AMPDU_DENSITY = 0x6 + NL80211_BAND_ATTR_HT_AMPDU_FACTOR = 0x5 + NL80211_BAND_ATTR_HT_CAPA = 0x4 + NL80211_BAND_ATTR_HT_MCS_SET = 0x3 + NL80211_BAND_ATTR_IFTYPE_DATA = 0x9 + NL80211_BAND_ATTR_MAX = 0xb + NL80211_BAND_ATTR_RATES = 0x2 + NL80211_BAND_ATTR_VHT_CAPA = 0x8 + NL80211_BAND_ATTR_VHT_MCS_SET = 0x7 + NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA = 0x6 + NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC = 0x2 + NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET = 0x4 + NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY = 0x3 + NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE = 0x5 + NL80211_BAND_IFTYPE_ATTR_IFTYPES = 0x1 + NL80211_BAND_IFTYPE_ATTR_MAX = 0x7 + NL80211_BAND_S1GHZ = 0x4 + NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE = 0x2 + NL80211_BITRATE_ATTR_MAX = 0x2 + NL80211_BITRATE_ATTR_RATE = 0x1 + NL80211_BSS_BEACON_IES = 0xb + NL80211_BSS_BEACON_INTERVAL = 0x4 + NL80211_BSS_BEACON_TSF = 0xd + NL80211_BSS_BSSID = 0x1 + NL80211_BSS_CAPABILITY = 0x5 + NL80211_BSS_CHAIN_SIGNAL = 0x13 + NL80211_BSS_CHAN_WIDTH_10 = 0x1 + NL80211_BSS_CHAN_WIDTH_1 = 0x3 + NL80211_BSS_CHAN_WIDTH_20 = 0x0 + NL80211_BSS_CHAN_WIDTH_2 = 0x4 + NL80211_BSS_CHAN_WIDTH_5 = 0x2 + NL80211_BSS_CHAN_WIDTH = 0xc + NL80211_BSS_FREQUENCY = 0x2 + NL80211_BSS_FREQUENCY_OFFSET = 0x14 + NL80211_BSS_INFORMATION_ELEMENTS = 0x6 + NL80211_BSS_LAST_SEEN_BOOTTIME = 0xf + NL80211_BSS_MAX = 0x14 + NL80211_BSS_PAD = 0x10 + NL80211_BSS_PARENT_BSSID = 0x12 + NL80211_BSS_PARENT_TSF = 0x11 + NL80211_BSS_PRESP_DATA = 0xe + NL80211_BSS_SEEN_MS_AGO = 0xa + NL80211_BSS_SELECT_ATTR_BAND_PREF = 0x2 + NL80211_BSS_SELECT_ATTR_MAX = 0x3 + NL80211_BSS_SELECT_ATTR_RSSI_ADJUST = 0x3 + NL80211_BSS_SELECT_ATTR_RSSI = 0x1 + NL80211_BSS_SIGNAL_MBM = 0x7 + NL80211_BSS_SIGNAL_UNSPEC = 0x8 + NL80211_BSS_STATUS_ASSOCIATED = 0x1 + NL80211_BSS_STATUS_AUTHENTICATED = 0x0 + NL80211_BSS_STATUS = 0x9 + NL80211_BSS_STATUS_IBSS_JOINED = 0x2 + NL80211_BSS_TSF = 0x3 + NL80211_CHAN_HT20 = 0x1 + NL80211_CHAN_HT40MINUS = 0x2 + NL80211_CHAN_HT40PLUS = 0x3 + NL80211_CHAN_NO_HT = 0x0 + NL80211_CHAN_WIDTH_10 = 0x7 + NL80211_CHAN_WIDTH_160 = 0x5 + NL80211_CHAN_WIDTH_16 = 0xc + NL80211_CHAN_WIDTH_1 = 0x8 + NL80211_CHAN_WIDTH_20 = 0x1 + NL80211_CHAN_WIDTH_20_NOHT = 0x0 + NL80211_CHAN_WIDTH_2 = 0x9 + NL80211_CHAN_WIDTH_40 = 0x2 + NL80211_CHAN_WIDTH_4 = 0xa + NL80211_CHAN_WIDTH_5 = 0x6 + NL80211_CHAN_WIDTH_80 = 0x3 + NL80211_CHAN_WIDTH_80P80 = 0x4 + NL80211_CHAN_WIDTH_8 = 0xb + NL80211_CMD_ABORT_SCAN = 0x72 + NL80211_CMD_ACTION = 0x3b + NL80211_CMD_ACTION_TX_STATUS = 0x3c + NL80211_CMD_ADD_NAN_FUNCTION = 0x75 + NL80211_CMD_ADD_TX_TS = 0x69 + NL80211_CMD_ASSOCIATE = 0x26 + NL80211_CMD_AUTHENTICATE = 0x25 + NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL = 0x38 + NL80211_CMD_CHANGE_NAN_CONFIG = 0x77 + NL80211_CMD_CHANNEL_SWITCH = 0x66 + NL80211_CMD_CH_SWITCH_NOTIFY = 0x58 + NL80211_CMD_CH_SWITCH_STARTED_NOTIFY = 0x6e + NL80211_CMD_CONNECT = 0x2e + NL80211_CMD_CONN_FAILED = 0x5b + NL80211_CMD_CONTROL_PORT_FRAME = 0x81 + NL80211_CMD_CONTROL_PORT_FRAME_TX_STATUS = 0x8b + NL80211_CMD_CRIT_PROTOCOL_START = 0x62 + NL80211_CMD_CRIT_PROTOCOL_STOP = 0x63 + NL80211_CMD_DEAUTHENTICATE = 0x27 + NL80211_CMD_DEL_BEACON = 0x10 + NL80211_CMD_DEL_INTERFACE = 0x8 + NL80211_CMD_DEL_KEY = 0xc + NL80211_CMD_DEL_MPATH = 0x18 + NL80211_CMD_DEL_NAN_FUNCTION = 0x76 + NL80211_CMD_DEL_PMK = 0x7c + NL80211_CMD_DEL_PMKSA = 0x35 + NL80211_CMD_DEL_STATION = 0x14 + NL80211_CMD_DEL_TX_TS = 0x6a + NL80211_CMD_DEL_WIPHY = 0x4 + NL80211_CMD_DISASSOCIATE = 0x28 + NL80211_CMD_DISCONNECT = 0x30 + NL80211_CMD_EXTERNAL_AUTH = 0x7f + NL80211_CMD_FLUSH_PMKSA = 0x36 + NL80211_CMD_FRAME = 0x3b + NL80211_CMD_FRAME_TX_STATUS = 0x3c + NL80211_CMD_FRAME_WAIT_CANCEL = 0x43 + NL80211_CMD_FT_EVENT = 0x61 + NL80211_CMD_GET_BEACON = 0xd + NL80211_CMD_GET_COALESCE = 0x64 + NL80211_CMD_GET_FTM_RESPONDER_STATS = 0x82 + NL80211_CMD_GET_INTERFACE = 0x5 + NL80211_CMD_GET_KEY = 0x9 + NL80211_CMD_GET_MESH_CONFIG = 0x1c + NL80211_CMD_GET_MESH_PARAMS = 0x1c + NL80211_CMD_GET_MPATH = 0x15 + NL80211_CMD_GET_MPP = 0x6b + NL80211_CMD_GET_POWER_SAVE = 0x3e + NL80211_CMD_GET_PROTOCOL_FEATURES = 0x5f + NL80211_CMD_GET_REG = 0x1f + NL80211_CMD_GET_SCAN = 0x20 + NL80211_CMD_GET_STATION = 0x11 + NL80211_CMD_GET_SURVEY = 0x32 + NL80211_CMD_GET_WIPHY = 0x1 + NL80211_CMD_GET_WOWLAN = 0x49 + NL80211_CMD_JOIN_IBSS = 0x2b + NL80211_CMD_JOIN_MESH = 0x44 + NL80211_CMD_JOIN_OCB = 0x6c + NL80211_CMD_LEAVE_IBSS = 0x2c + NL80211_CMD_LEAVE_MESH = 0x45 + NL80211_CMD_LEAVE_OCB = 0x6d + NL80211_CMD_MAX = 0x93 + NL80211_CMD_MICHAEL_MIC_FAILURE = 0x29 + NL80211_CMD_NAN_MATCH = 0x78 + NL80211_CMD_NEW_BEACON = 0xf + NL80211_CMD_NEW_INTERFACE = 0x7 + NL80211_CMD_NEW_KEY = 0xb + NL80211_CMD_NEW_MPATH = 0x17 + NL80211_CMD_NEW_PEER_CANDIDATE = 0x48 + NL80211_CMD_NEW_SCAN_RESULTS = 0x22 + NL80211_CMD_NEW_STATION = 0x13 + NL80211_CMD_NEW_SURVEY_RESULTS = 0x33 + NL80211_CMD_NEW_WIPHY = 0x3 + NL80211_CMD_NOTIFY_CQM = 0x40 + NL80211_CMD_NOTIFY_RADAR = 0x86 + NL80211_CMD_PEER_MEASUREMENT_COMPLETE = 0x85 + NL80211_CMD_PEER_MEASUREMENT_RESULT = 0x84 + NL80211_CMD_PEER_MEASUREMENT_START = 0x83 + NL80211_CMD_PMKSA_CANDIDATE = 0x50 + NL80211_CMD_PORT_AUTHORIZED = 0x7d + NL80211_CMD_PROBE_CLIENT = 0x54 + NL80211_CMD_PROBE_MESH_LINK = 0x88 + NL80211_CMD_RADAR_DETECT = 0x5e + NL80211_CMD_REG_BEACON_HINT = 0x2a + NL80211_CMD_REG_CHANGE = 0x24 + NL80211_CMD_REGISTER_ACTION = 0x3a + NL80211_CMD_REGISTER_BEACONS = 0x55 + NL80211_CMD_REGISTER_FRAME = 0x3a + NL80211_CMD_RELOAD_REGDB = 0x7e + NL80211_CMD_REMAIN_ON_CHANNEL = 0x37 + NL80211_CMD_REQ_SET_REG = 0x1b + NL80211_CMD_ROAM = 0x2f + NL80211_CMD_SCAN_ABORTED = 0x23 + NL80211_CMD_SCHED_SCAN_RESULTS = 0x4d + NL80211_CMD_SCHED_SCAN_STOPPED = 0x4e + NL80211_CMD_SET_BEACON = 0xe + NL80211_CMD_SET_BSS = 0x19 + NL80211_CMD_SET_CHANNEL = 0x41 + NL80211_CMD_SET_COALESCE = 0x65 + NL80211_CMD_SET_CQM = 0x3f + NL80211_CMD_SET_INTERFACE = 0x6 + NL80211_CMD_SET_KEY = 0xa + NL80211_CMD_SET_MAC_ACL = 0x5d + NL80211_CMD_SET_MCAST_RATE = 0x5c + NL80211_CMD_SET_MESH_CONFIG = 0x1d + NL80211_CMD_SET_MESH_PARAMS = 0x1d + NL80211_CMD_SET_MGMT_EXTRA_IE = 0x1e + NL80211_CMD_SET_MPATH = 0x16 + NL80211_CMD_SET_MULTICAST_TO_UNICAST = 0x79 + NL80211_CMD_SET_NOACK_MAP = 0x57 + NL80211_CMD_SET_PMK = 0x7b + NL80211_CMD_SET_PMKSA = 0x34 + NL80211_CMD_SET_POWER_SAVE = 0x3d + NL80211_CMD_SET_QOS_MAP = 0x68 + NL80211_CMD_SET_REG = 0x1a + NL80211_CMD_SET_REKEY_OFFLOAD = 0x4f + NL80211_CMD_SET_SAR_SPECS = 0x8c + NL80211_CMD_SET_STATION = 0x12 + NL80211_CMD_SET_TID_CONFIG = 0x89 + NL80211_CMD_SET_TX_BITRATE_MASK = 0x39 + NL80211_CMD_SET_WDS_PEER = 0x42 + NL80211_CMD_SET_WIPHY = 0x2 + NL80211_CMD_SET_WIPHY_NETNS = 0x31 + NL80211_CMD_SET_WOWLAN = 0x4a + NL80211_CMD_STA_OPMODE_CHANGED = 0x80 + NL80211_CMD_START_AP = 0xf + NL80211_CMD_START_NAN = 0x73 + NL80211_CMD_START_P2P_DEVICE = 0x59 + NL80211_CMD_START_SCHED_SCAN = 0x4b + NL80211_CMD_STOP_AP = 0x10 + NL80211_CMD_STOP_NAN = 0x74 + NL80211_CMD_STOP_P2P_DEVICE = 0x5a + NL80211_CMD_STOP_SCHED_SCAN = 0x4c + NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH = 0x70 + NL80211_CMD_TDLS_CHANNEL_SWITCH = 0x6f + NL80211_CMD_TDLS_MGMT = 0x52 + NL80211_CMD_TDLS_OPER = 0x51 + NL80211_CMD_TESTMODE = 0x2d + NL80211_CMD_TRIGGER_SCAN = 0x21 + NL80211_CMD_UNEXPECTED_4ADDR_FRAME = 0x56 + NL80211_CMD_UNEXPECTED_FRAME = 0x53 + NL80211_CMD_UNPROT_BEACON = 0x8a + NL80211_CMD_UNPROT_DEAUTHENTICATE = 0x46 + NL80211_CMD_UNPROT_DISASSOCIATE = 0x47 + NL80211_CMD_UNSPEC = 0x0 + NL80211_CMD_UPDATE_CONNECT_PARAMS = 0x7a + NL80211_CMD_UPDATE_FT_IES = 0x60 + NL80211_CMD_UPDATE_OWE_INFO = 0x87 + NL80211_CMD_VENDOR = 0x67 + NL80211_CMD_WIPHY_REG_CHANGE = 0x71 + NL80211_COALESCE_CONDITION_MATCH = 0x0 + NL80211_COALESCE_CONDITION_NO_MATCH = 0x1 + NL80211_CONN_FAIL_BLOCKED_CLIENT = 0x1 + NL80211_CONN_FAIL_MAX_CLIENTS = 0x0 + NL80211_CQM_RSSI_BEACON_LOSS_EVENT = 0x2 + NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH = 0x1 + NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW = 0x0 + NL80211_CQM_TXE_MAX_INTVL = 0x708 + NL80211_CRIT_PROTO_APIPA = 0x3 + NL80211_CRIT_PROTO_DHCP = 0x1 + NL80211_CRIT_PROTO_EAPOL = 0x2 + NL80211_CRIT_PROTO_MAX_DURATION = 0x1388 + NL80211_CRIT_PROTO_UNSPEC = 0x0 + NL80211_DFS_AVAILABLE = 0x2 + NL80211_DFS_ETSI = 0x2 + NL80211_DFS_FCC = 0x1 + NL80211_DFS_JP = 0x3 + NL80211_DFS_UNAVAILABLE = 0x1 + NL80211_DFS_UNSET = 0x0 + NL80211_DFS_USABLE = 0x0 + NL80211_EDMG_BW_CONFIG_MAX = 0xf + NL80211_EDMG_BW_CONFIG_MIN = 0x4 + NL80211_EDMG_CHANNELS_MAX = 0x3c + NL80211_EDMG_CHANNELS_MIN = 0x1 + NL80211_EXTERNAL_AUTH_ABORT = 0x1 + NL80211_EXTERNAL_AUTH_START = 0x0 + NL80211_EXT_FEATURE_4WAY_HANDSHAKE_AP_PSK = 0x32 + NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_1X = 0x10 + NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK = 0xf + NL80211_EXT_FEATURE_ACCEPT_BCAST_PROBE_RESP = 0x12 + NL80211_EXT_FEATURE_ACK_SIGNAL_SUPPORT = 0x1b + NL80211_EXT_FEATURE_AIRTIME_FAIRNESS = 0x21 + NL80211_EXT_FEATURE_AP_PMKSA_CACHING = 0x22 + NL80211_EXT_FEATURE_AQL = 0x28 + NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT = 0x2e + NL80211_EXT_FEATURE_BEACON_PROTECTION = 0x29 + NL80211_EXT_FEATURE_BEACON_RATE_HE = 0x36 + NL80211_EXT_FEATURE_BEACON_RATE_HT = 0x7 + NL80211_EXT_FEATURE_BEACON_RATE_LEGACY = 0x6 + NL80211_EXT_FEATURE_BEACON_RATE_VHT = 0x8 + NL80211_EXT_FEATURE_BSS_PARENT_TSF = 0x4 + NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 = 0x1f + NL80211_EXT_FEATURE_CONTROL_PORT_NO_PREAUTH = 0x2a + NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211 = 0x1a + NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211_TX_STATUS = 0x30 + NL80211_EXT_FEATURE_CQM_RSSI_LIST = 0xd + NL80211_EXT_FEATURE_DATA_ACK_SIGNAL_SUPPORT = 0x1b + NL80211_EXT_FEATURE_DEL_IBSS_STA = 0x2c + NL80211_EXT_FEATURE_DFS_OFFLOAD = 0x19 + NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER = 0x20 + NL80211_EXT_FEATURE_EXT_KEY_ID = 0x24 + NL80211_EXT_FEATURE_FILS_DISCOVERY = 0x34 + NL80211_EXT_FEATURE_FILS_MAX_CHANNEL_TIME = 0x11 + NL80211_EXT_FEATURE_FILS_SK_OFFLOAD = 0xe + NL80211_EXT_FEATURE_FILS_STA = 0x9 + NL80211_EXT_FEATURE_HIGH_ACCURACY_SCAN = 0x18 + NL80211_EXT_FEATURE_LOW_POWER_SCAN = 0x17 + NL80211_EXT_FEATURE_LOW_SPAN_SCAN = 0x16 + NL80211_EXT_FEATURE_MFP_OPTIONAL = 0x15 + NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA = 0xa + NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED = 0xb + NL80211_EXT_FEATURE_MULTICAST_REGISTRATIONS = 0x2d + NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER = 0x2 + NL80211_EXT_FEATURE_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION = 0x14 + NL80211_EXT_FEATURE_OCE_PROBE_REQ_HIGH_TX_RATE = 0x13 + NL80211_EXT_FEATURE_OPERATING_CHANNEL_VALIDATION = 0x31 + NL80211_EXT_FEATURE_PROTECTED_TWT = 0x2b + NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE = 0x39 + NL80211_EXT_FEATURE_RRM = 0x1 + NL80211_EXT_FEATURE_SAE_OFFLOAD_AP = 0x33 + NL80211_EXT_FEATURE_SAE_OFFLOAD = 0x26 + NL80211_EXT_FEATURE_SCAN_FREQ_KHZ = 0x2f + NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT = 0x1e + NL80211_EXT_FEATURE_SCAN_RANDOM_SN = 0x1d + NL80211_EXT_FEATURE_SCAN_START_TIME = 0x3 + NL80211_EXT_FEATURE_SCHED_SCAN_BAND_SPECIFIC_RSSI_THOLD = 0x23 + NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI = 0xc + NL80211_EXT_FEATURE_SECURE_LTF = 0x37 + NL80211_EXT_FEATURE_SECURE_RTT = 0x38 + NL80211_EXT_FEATURE_SET_SCAN_DWELL = 0x5 + NL80211_EXT_FEATURE_STA_TX_PWR = 0x25 + NL80211_EXT_FEATURE_TXQS = 0x1c + NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP = 0x35 + NL80211_EXT_FEATURE_VHT_IBSS = 0x0 + NL80211_EXT_FEATURE_VLAN_OFFLOAD = 0x27 + NL80211_FEATURE_ACKTO_ESTIMATION = 0x800000 + NL80211_FEATURE_ACTIVE_MONITOR = 0x20000 + NL80211_FEATURE_ADVERTISE_CHAN_LIMITS = 0x4000 + NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE = 0x40000 + NL80211_FEATURE_AP_SCAN = 0x100 + NL80211_FEATURE_CELL_BASE_REG_HINTS = 0x8 + NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES = 0x80000 + NL80211_FEATURE_DYNAMIC_SMPS = 0x2000000 + NL80211_FEATURE_FULL_AP_CLIENT_STATE = 0x8000 + NL80211_FEATURE_HT_IBSS = 0x2 + NL80211_FEATURE_INACTIVITY_TIMER = 0x4 + NL80211_FEATURE_LOW_PRIORITY_SCAN = 0x40 + NL80211_FEATURE_MAC_ON_CREATE = 0x8000000 + NL80211_FEATURE_ND_RANDOM_MAC_ADDR = 0x80000000 + NL80211_FEATURE_NEED_OBSS_SCAN = 0x400 + NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL = 0x10 + NL80211_FEATURE_P2P_GO_CTWIN = 0x800 + NL80211_FEATURE_P2P_GO_OPPPS = 0x1000 + NL80211_FEATURE_QUIET = 0x200000 + NL80211_FEATURE_SAE = 0x20 + NL80211_FEATURE_SCAN_FLUSH = 0x80 + NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR = 0x20000000 + NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR = 0x40000000 + NL80211_FEATURE_SK_TX_STATUS = 0x1 + NL80211_FEATURE_STATIC_SMPS = 0x1000000 + NL80211_FEATURE_SUPPORTS_WMM_ADMISSION = 0x4000000 + NL80211_FEATURE_TDLS_CHANNEL_SWITCH = 0x10000000 + NL80211_FEATURE_TX_POWER_INSERTION = 0x400000 + NL80211_FEATURE_USERSPACE_MPM = 0x10000 + NL80211_FEATURE_VIF_TXPOWER = 0x200 + NL80211_FEATURE_WFA_TPC_IE_IN_PROBES = 0x100000 + NL80211_FILS_DISCOVERY_ATTR_INT_MAX = 0x2 + NL80211_FILS_DISCOVERY_ATTR_INT_MIN = 0x1 + NL80211_FILS_DISCOVERY_ATTR_MAX = 0x3 + NL80211_FILS_DISCOVERY_ATTR_TMPL = 0x3 + NL80211_FILS_DISCOVERY_TMPL_MIN_LEN = 0x2a + NL80211_FREQUENCY_ATTR_16MHZ = 0x19 + NL80211_FREQUENCY_ATTR_1MHZ = 0x15 + NL80211_FREQUENCY_ATTR_2MHZ = 0x16 + NL80211_FREQUENCY_ATTR_4MHZ = 0x17 + NL80211_FREQUENCY_ATTR_8MHZ = 0x18 + NL80211_FREQUENCY_ATTR_DFS_CAC_TIME = 0xd + NL80211_FREQUENCY_ATTR_DFS_STATE = 0x7 + NL80211_FREQUENCY_ATTR_DFS_TIME = 0x8 + NL80211_FREQUENCY_ATTR_DISABLED = 0x2 + NL80211_FREQUENCY_ATTR_FREQ = 0x1 + NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf + NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe + NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf + NL80211_FREQUENCY_ATTR_MAX = 0x19 + NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6 + NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11 + NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc + NL80211_FREQUENCY_ATTR_NO_20MHZ = 0x10 + NL80211_FREQUENCY_ATTR_NO_80MHZ = 0xb + NL80211_FREQUENCY_ATTR_NO_HE = 0x13 + NL80211_FREQUENCY_ATTR_NO_HT40_MINUS = 0x9 + NL80211_FREQUENCY_ATTR_NO_HT40_PLUS = 0xa + NL80211_FREQUENCY_ATTR_NO_IBSS = 0x3 + NL80211_FREQUENCY_ATTR_NO_IR = 0x3 + NL80211_FREQUENCY_ATTR_OFFSET = 0x14 + NL80211_FREQUENCY_ATTR_PASSIVE_SCAN = 0x3 + NL80211_FREQUENCY_ATTR_RADAR = 0x5 + NL80211_FREQUENCY_ATTR_WMM = 0x12 + NL80211_FTM_RESP_ATTR_CIVICLOC = 0x3 + NL80211_FTM_RESP_ATTR_ENABLED = 0x1 + NL80211_FTM_RESP_ATTR_LCI = 0x2 + NL80211_FTM_RESP_ATTR_MAX = 0x3 + NL80211_FTM_STATS_ASAP_NUM = 0x4 + NL80211_FTM_STATS_FAILED_NUM = 0x3 + NL80211_FTM_STATS_MAX = 0xa + NL80211_FTM_STATS_NON_ASAP_NUM = 0x5 + NL80211_FTM_STATS_OUT_OF_WINDOW_TRIGGERS_NUM = 0x9 + NL80211_FTM_STATS_PAD = 0xa + NL80211_FTM_STATS_PARTIAL_NUM = 0x2 + NL80211_FTM_STATS_RESCHEDULE_REQUESTS_NUM = 0x8 + NL80211_FTM_STATS_SUCCESS_NUM = 0x1 + NL80211_FTM_STATS_TOTAL_DURATION_MSEC = 0x6 + NL80211_FTM_STATS_UNKNOWN_TRIGGERS_NUM = 0x7 + NL80211_GENL_NAME = "nl80211" + NL80211_HE_BSS_COLOR_ATTR_COLOR = 0x1 + NL80211_HE_BSS_COLOR_ATTR_DISABLED = 0x2 + NL80211_HE_BSS_COLOR_ATTR_MAX = 0x3 + NL80211_HE_BSS_COLOR_ATTR_PARTIAL = 0x3 + NL80211_HE_MAX_CAPABILITY_LEN = 0x36 + NL80211_HE_MIN_CAPABILITY_LEN = 0x10 + NL80211_HE_NSS_MAX = 0x8 + NL80211_HE_OBSS_PD_ATTR_BSS_COLOR_BITMAP = 0x4 + NL80211_HE_OBSS_PD_ATTR_MAX = 0x6 + NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET = 0x2 + NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET = 0x1 + NL80211_HE_OBSS_PD_ATTR_NON_SRG_MAX_OFFSET = 0x3 + NL80211_HE_OBSS_PD_ATTR_PARTIAL_BSSID_BITMAP = 0x5 + NL80211_HE_OBSS_PD_ATTR_SR_CTRL = 0x6 + NL80211_HIDDEN_SSID_NOT_IN_USE = 0x0 + NL80211_HIDDEN_SSID_ZERO_CONTENTS = 0x2 + NL80211_HIDDEN_SSID_ZERO_LEN = 0x1 + NL80211_HT_CAPABILITY_LEN = 0x1a + NL80211_IFACE_COMB_BI_MIN_GCD = 0x7 + NL80211_IFACE_COMB_LIMITS = 0x1 + NL80211_IFACE_COMB_MAXNUM = 0x2 + NL80211_IFACE_COMB_NUM_CHANNELS = 0x4 + NL80211_IFACE_COMB_RADAR_DETECT_REGIONS = 0x6 + NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS = 0x5 + NL80211_IFACE_COMB_STA_AP_BI_MATCH = 0x3 + NL80211_IFACE_COMB_UNSPEC = 0x0 + NL80211_IFACE_LIMIT_MAX = 0x1 + NL80211_IFACE_LIMIT_TYPES = 0x2 + NL80211_IFACE_LIMIT_UNSPEC = 0x0 + NL80211_IFTYPE_ADHOC = 0x1 + NL80211_IFTYPE_AKM_ATTR_IFTYPES = 0x1 + NL80211_IFTYPE_AKM_ATTR_MAX = 0x2 + NL80211_IFTYPE_AKM_ATTR_SUITES = 0x2 + NL80211_IFTYPE_AP = 0x3 + NL80211_IFTYPE_AP_VLAN = 0x4 + NL80211_IFTYPE_MAX = 0xc + NL80211_IFTYPE_MESH_POINT = 0x7 + NL80211_IFTYPE_MONITOR = 0x6 + NL80211_IFTYPE_NAN = 0xc + NL80211_IFTYPE_OCB = 0xb + NL80211_IFTYPE_P2P_CLIENT = 0x8 + NL80211_IFTYPE_P2P_DEVICE = 0xa + NL80211_IFTYPE_P2P_GO = 0x9 + NL80211_IFTYPE_STATION = 0x2 + NL80211_IFTYPE_UNSPECIFIED = 0x0 + NL80211_IFTYPE_WDS = 0x5 + NL80211_KCK_EXT_LEN = 0x18 + NL80211_KCK_LEN = 0x10 + NL80211_KEK_EXT_LEN = 0x20 + NL80211_KEK_LEN = 0x10 + NL80211_KEY_CIPHER = 0x3 + NL80211_KEY_DATA = 0x1 + NL80211_KEY_DEFAULT_BEACON = 0xa + NL80211_KEY_DEFAULT = 0x5 + NL80211_KEY_DEFAULT_MGMT = 0x6 + NL80211_KEY_DEFAULT_TYPE_MULTICAST = 0x2 + NL80211_KEY_DEFAULT_TYPES = 0x8 + NL80211_KEY_DEFAULT_TYPE_UNICAST = 0x1 + NL80211_KEY_IDX = 0x2 + NL80211_KEY_MAX = 0xa + NL80211_KEY_MODE = 0x9 + NL80211_KEY_NO_TX = 0x1 + NL80211_KEY_RX_TX = 0x0 + NL80211_KEY_SEQ = 0x4 + NL80211_KEY_SET_TX = 0x2 + NL80211_KEY_TYPE = 0x7 + NL80211_KEYTYPE_GROUP = 0x0 + NL80211_KEYTYPE_PAIRWISE = 0x1 + NL80211_KEYTYPE_PEERKEY = 0x2 + NL80211_MAX_NR_AKM_SUITES = 0x2 + NL80211_MAX_NR_CIPHER_SUITES = 0x5 + NL80211_MAX_SUPP_HT_RATES = 0x4d + NL80211_MAX_SUPP_RATES = 0x20 + NL80211_MAX_SUPP_REG_RULES = 0x80 + NL80211_MESHCONF_ATTR_MAX = 0x1f + NL80211_MESHCONF_AUTO_OPEN_PLINKS = 0x7 + NL80211_MESHCONF_AWAKE_WINDOW = 0x1b + NL80211_MESHCONF_CONFIRM_TIMEOUT = 0x2 + NL80211_MESHCONF_CONNECTED_TO_AS = 0x1f + NL80211_MESHCONF_CONNECTED_TO_GATE = 0x1d + NL80211_MESHCONF_ELEMENT_TTL = 0xf + NL80211_MESHCONF_FORWARDING = 0x13 + NL80211_MESHCONF_GATE_ANNOUNCEMENTS = 0x11 + NL80211_MESHCONF_HOLDING_TIMEOUT = 0x3 + NL80211_MESHCONF_HT_OPMODE = 0x16 + NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT = 0xb + NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL = 0x19 + NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES = 0x8 + NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME = 0xd + NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT = 0x17 + NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL = 0x12 + NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL = 0xc + NL80211_MESHCONF_HWMP_RANN_INTERVAL = 0x10 + NL80211_MESHCONF_HWMP_ROOT_INTERVAL = 0x18 + NL80211_MESHCONF_HWMP_ROOTMODE = 0xe + NL80211_MESHCONF_MAX_PEER_LINKS = 0x4 + NL80211_MESHCONF_MAX_RETRIES = 0x5 + NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT = 0xa + NL80211_MESHCONF_NOLEARN = 0x1e + NL80211_MESHCONF_PATH_REFRESH_TIME = 0x9 + NL80211_MESHCONF_PLINK_TIMEOUT = 0x1c + NL80211_MESHCONF_POWER_MODE = 0x1a + NL80211_MESHCONF_RETRY_TIMEOUT = 0x1 + NL80211_MESHCONF_RSSI_THRESHOLD = 0x14 + NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR = 0x15 + NL80211_MESHCONF_TTL = 0x6 + NL80211_MESH_POWER_ACTIVE = 0x1 + NL80211_MESH_POWER_DEEP_SLEEP = 0x3 + NL80211_MESH_POWER_LIGHT_SLEEP = 0x2 + NL80211_MESH_POWER_MAX = 0x3 + NL80211_MESH_POWER_UNKNOWN = 0x0 + NL80211_MESH_SETUP_ATTR_MAX = 0x8 + NL80211_MESH_SETUP_AUTH_PROTOCOL = 0x8 + NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC = 0x2 + NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL = 0x1 + NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC = 0x6 + NL80211_MESH_SETUP_IE = 0x3 + NL80211_MESH_SETUP_USERSPACE_AMPE = 0x5 + NL80211_MESH_SETUP_USERSPACE_AUTH = 0x4 + NL80211_MESH_SETUP_USERSPACE_MPM = 0x7 + NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE = 0x3 + NL80211_MFP_NO = 0x0 + NL80211_MFP_OPTIONAL = 0x2 + NL80211_MFP_REQUIRED = 0x1 + NL80211_MIN_REMAIN_ON_CHANNEL_TIME = 0xa + NL80211_MNTR_FLAG_ACTIVE = 0x6 + NL80211_MNTR_FLAG_CONTROL = 0x3 + NL80211_MNTR_FLAG_COOK_FRAMES = 0x5 + NL80211_MNTR_FLAG_FCSFAIL = 0x1 + NL80211_MNTR_FLAG_MAX = 0x6 + NL80211_MNTR_FLAG_OTHER_BSS = 0x4 + NL80211_MNTR_FLAG_PLCPFAIL = 0x2 + NL80211_MPATH_FLAG_ACTIVE = 0x1 + NL80211_MPATH_FLAG_FIXED = 0x8 + NL80211_MPATH_FLAG_RESOLVED = 0x10 + NL80211_MPATH_FLAG_RESOLVING = 0x2 + NL80211_MPATH_FLAG_SN_VALID = 0x4 + NL80211_MPATH_INFO_DISCOVERY_RETRIES = 0x7 + NL80211_MPATH_INFO_DISCOVERY_TIMEOUT = 0x6 + NL80211_MPATH_INFO_EXPTIME = 0x4 + NL80211_MPATH_INFO_FLAGS = 0x5 + NL80211_MPATH_INFO_FRAME_QLEN = 0x1 + NL80211_MPATH_INFO_HOP_COUNT = 0x8 + NL80211_MPATH_INFO_MAX = 0x9 + NL80211_MPATH_INFO_METRIC = 0x3 + NL80211_MPATH_INFO_PATH_CHANGE = 0x9 + NL80211_MPATH_INFO_SN = 0x2 + NL80211_MULTICAST_GROUP_CONFIG = "config" + NL80211_MULTICAST_GROUP_MLME = "mlme" + NL80211_MULTICAST_GROUP_NAN = "nan" + NL80211_MULTICAST_GROUP_REG = "regulatory" + NL80211_MULTICAST_GROUP_SCAN = "scan" + NL80211_MULTICAST_GROUP_TESTMODE = "testmode" + NL80211_MULTICAST_GROUP_VENDOR = "vendor" + NL80211_NAN_FUNC_ATTR_MAX = 0x10 + NL80211_NAN_FUNC_CLOSE_RANGE = 0x9 + NL80211_NAN_FUNC_FOLLOW_UP = 0x2 + NL80211_NAN_FUNC_FOLLOW_UP_DEST = 0x8 + NL80211_NAN_FUNC_FOLLOW_UP_ID = 0x6 + NL80211_NAN_FUNC_FOLLOW_UP_REQ_ID = 0x7 + NL80211_NAN_FUNC_INSTANCE_ID = 0xf + NL80211_NAN_FUNC_MAX_TYPE = 0x2 + NL80211_NAN_FUNC_PUBLISH_BCAST = 0x4 + NL80211_NAN_FUNC_PUBLISH = 0x0 + NL80211_NAN_FUNC_PUBLISH_TYPE = 0x3 + NL80211_NAN_FUNC_RX_MATCH_FILTER = 0xd + NL80211_NAN_FUNC_SERVICE_ID = 0x2 + NL80211_NAN_FUNC_SERVICE_ID_LEN = 0x6 + NL80211_NAN_FUNC_SERVICE_INFO = 0xb + NL80211_NAN_FUNC_SERVICE_SPEC_INFO_MAX_LEN = 0xff + NL80211_NAN_FUNC_SRF = 0xc + NL80211_NAN_FUNC_SRF_MAX_LEN = 0xff + NL80211_NAN_FUNC_SUBSCRIBE_ACTIVE = 0x5 + NL80211_NAN_FUNC_SUBSCRIBE = 0x1 + NL80211_NAN_FUNC_TERM_REASON = 0x10 + NL80211_NAN_FUNC_TERM_REASON_ERROR = 0x2 + NL80211_NAN_FUNC_TERM_REASON_TTL_EXPIRED = 0x1 + NL80211_NAN_FUNC_TERM_REASON_USER_REQUEST = 0x0 + NL80211_NAN_FUNC_TTL = 0xa + NL80211_NAN_FUNC_TX_MATCH_FILTER = 0xe + NL80211_NAN_FUNC_TYPE = 0x1 + NL80211_NAN_MATCH_ATTR_MAX = 0x2 + NL80211_NAN_MATCH_FUNC_LOCAL = 0x1 + NL80211_NAN_MATCH_FUNC_PEER = 0x2 + NL80211_NAN_SOLICITED_PUBLISH = 0x1 + NL80211_NAN_SRF_ATTR_MAX = 0x4 + NL80211_NAN_SRF_BF = 0x2 + NL80211_NAN_SRF_BF_IDX = 0x3 + NL80211_NAN_SRF_INCLUDE = 0x1 + NL80211_NAN_SRF_MAC_ADDRS = 0x4 + NL80211_NAN_UNSOLICITED_PUBLISH = 0x2 + NL80211_NUM_ACS = 0x4 + NL80211_P2P_PS_SUPPORTED = 0x1 + NL80211_P2P_PS_UNSUPPORTED = 0x0 + NL80211_PKTPAT_MASK = 0x1 + NL80211_PKTPAT_OFFSET = 0x3 + NL80211_PKTPAT_PATTERN = 0x2 + NL80211_PLINK_ACTION_BLOCK = 0x2 + NL80211_PLINK_ACTION_NO_ACTION = 0x0 + NL80211_PLINK_ACTION_OPEN = 0x1 + NL80211_PLINK_BLOCKED = 0x6 + NL80211_PLINK_CNF_RCVD = 0x3 + NL80211_PLINK_ESTAB = 0x4 + NL80211_PLINK_HOLDING = 0x5 + NL80211_PLINK_LISTEN = 0x0 + NL80211_PLINK_OPN_RCVD = 0x2 + NL80211_PLINK_OPN_SNT = 0x1 + NL80211_PMKSA_CANDIDATE_BSSID = 0x2 + NL80211_PMKSA_CANDIDATE_INDEX = 0x1 + NL80211_PMKSA_CANDIDATE_PREAUTH = 0x3 + NL80211_PMSR_ATTR_MAX = 0x5 + NL80211_PMSR_ATTR_MAX_PEERS = 0x1 + NL80211_PMSR_ATTR_PEERS = 0x5 + NL80211_PMSR_ATTR_RANDOMIZE_MAC_ADDR = 0x3 + NL80211_PMSR_ATTR_REPORT_AP_TSF = 0x2 + NL80211_PMSR_ATTR_TYPE_CAPA = 0x4 + NL80211_PMSR_FTM_CAPA_ATTR_ASAP = 0x1 + NL80211_PMSR_FTM_CAPA_ATTR_BANDWIDTHS = 0x6 + NL80211_PMSR_FTM_CAPA_ATTR_MAX_BURSTS_EXPONENT = 0x7 + NL80211_PMSR_FTM_CAPA_ATTR_MAX = 0xa + NL80211_PMSR_FTM_CAPA_ATTR_MAX_FTMS_PER_BURST = 0x8 + NL80211_PMSR_FTM_CAPA_ATTR_NON_ASAP = 0x2 + NL80211_PMSR_FTM_CAPA_ATTR_NON_TRIGGER_BASED = 0xa + NL80211_PMSR_FTM_CAPA_ATTR_PREAMBLES = 0x5 + NL80211_PMSR_FTM_CAPA_ATTR_REQ_CIVICLOC = 0x4 + NL80211_PMSR_FTM_CAPA_ATTR_REQ_LCI = 0x3 + NL80211_PMSR_FTM_CAPA_ATTR_TRIGGER_BASED = 0x9 + NL80211_PMSR_FTM_FAILURE_BAD_CHANGED_PARAMS = 0x7 + NL80211_PMSR_FTM_FAILURE_INVALID_TIMESTAMP = 0x5 + NL80211_PMSR_FTM_FAILURE_NO_RESPONSE = 0x1 + NL80211_PMSR_FTM_FAILURE_PEER_BUSY = 0x6 + NL80211_PMSR_FTM_FAILURE_PEER_NOT_CAPABLE = 0x4 + NL80211_PMSR_FTM_FAILURE_REJECTED = 0x2 + NL80211_PMSR_FTM_FAILURE_UNSPECIFIED = 0x0 + NL80211_PMSR_FTM_FAILURE_WRONG_CHANNEL = 0x3 + NL80211_PMSR_FTM_REQ_ATTR_ASAP = 0x1 + NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION = 0x5 + NL80211_PMSR_FTM_REQ_ATTR_BURST_PERIOD = 0x4 + NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST = 0x6 + NL80211_PMSR_FTM_REQ_ATTR_LMR_FEEDBACK = 0xc + NL80211_PMSR_FTM_REQ_ATTR_MAX = 0xd + NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED = 0xb + NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP = 0x3 + NL80211_PMSR_FTM_REQ_ATTR_NUM_FTMR_RETRIES = 0x7 + NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE = 0x2 + NL80211_PMSR_FTM_REQ_ATTR_REQUEST_CIVICLOC = 0x9 + NL80211_PMSR_FTM_REQ_ATTR_REQUEST_LCI = 0x8 + NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED = 0xa + NL80211_PMSR_FTM_RESP_ATTR_BURST_DURATION = 0x7 + NL80211_PMSR_FTM_RESP_ATTR_BURST_INDEX = 0x2 + NL80211_PMSR_FTM_RESP_ATTR_BUSY_RETRY_TIME = 0x5 + NL80211_PMSR_FTM_RESP_ATTR_CIVICLOC = 0x14 + NL80211_PMSR_FTM_RESP_ATTR_DIST_AVG = 0x10 + NL80211_PMSR_FTM_RESP_ATTR_DIST_SPREAD = 0x12 + NL80211_PMSR_FTM_RESP_ATTR_DIST_VARIANCE = 0x11 + NL80211_PMSR_FTM_RESP_ATTR_FAIL_REASON = 0x1 + NL80211_PMSR_FTM_RESP_ATTR_FTMS_PER_BURST = 0x8 + NL80211_PMSR_FTM_RESP_ATTR_LCI = 0x13 + NL80211_PMSR_FTM_RESP_ATTR_MAX = 0x15 + NL80211_PMSR_FTM_RESP_ATTR_NUM_BURSTS_EXP = 0x6 + NL80211_PMSR_FTM_RESP_ATTR_NUM_FTMR_ATTEMPTS = 0x3 + NL80211_PMSR_FTM_RESP_ATTR_NUM_FTMR_SUCCESSES = 0x4 + NL80211_PMSR_FTM_RESP_ATTR_PAD = 0x15 + NL80211_PMSR_FTM_RESP_ATTR_RSSI_AVG = 0x9 + NL80211_PMSR_FTM_RESP_ATTR_RSSI_SPREAD = 0xa + NL80211_PMSR_FTM_RESP_ATTR_RTT_AVG = 0xd + NL80211_PMSR_FTM_RESP_ATTR_RTT_SPREAD = 0xf + NL80211_PMSR_FTM_RESP_ATTR_RTT_VARIANCE = 0xe + NL80211_PMSR_FTM_RESP_ATTR_RX_RATE = 0xc + NL80211_PMSR_FTM_RESP_ATTR_TX_RATE = 0xb + NL80211_PMSR_PEER_ATTR_ADDR = 0x1 + NL80211_PMSR_PEER_ATTR_CHAN = 0x2 + NL80211_PMSR_PEER_ATTR_MAX = 0x4 + NL80211_PMSR_PEER_ATTR_REQ = 0x3 + NL80211_PMSR_PEER_ATTR_RESP = 0x4 + NL80211_PMSR_REQ_ATTR_DATA = 0x1 + NL80211_PMSR_REQ_ATTR_GET_AP_TSF = 0x2 + NL80211_PMSR_REQ_ATTR_MAX = 0x2 + NL80211_PMSR_RESP_ATTR_AP_TSF = 0x4 + NL80211_PMSR_RESP_ATTR_DATA = 0x1 + NL80211_PMSR_RESP_ATTR_FINAL = 0x5 + NL80211_PMSR_RESP_ATTR_HOST_TIME = 0x3 + NL80211_PMSR_RESP_ATTR_MAX = 0x6 + NL80211_PMSR_RESP_ATTR_PAD = 0x6 + NL80211_PMSR_RESP_ATTR_STATUS = 0x2 + NL80211_PMSR_STATUS_FAILURE = 0x3 + NL80211_PMSR_STATUS_REFUSED = 0x1 + NL80211_PMSR_STATUS_SUCCESS = 0x0 + NL80211_PMSR_STATUS_TIMEOUT = 0x2 + NL80211_PMSR_TYPE_FTM = 0x1 + NL80211_PMSR_TYPE_INVALID = 0x0 + NL80211_PMSR_TYPE_MAX = 0x1 + NL80211_PREAMBLE_DMG = 0x3 + NL80211_PREAMBLE_HE = 0x4 + NL80211_PREAMBLE_HT = 0x1 + NL80211_PREAMBLE_LEGACY = 0x0 + NL80211_PREAMBLE_VHT = 0x2 + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 0x8 + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 0x4 + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 = 0x2 + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS = 0x1 + NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP = 0x1 + NL80211_PS_DISABLED = 0x0 + NL80211_PS_ENABLED = 0x1 + NL80211_RADAR_CAC_ABORTED = 0x2 + NL80211_RADAR_CAC_FINISHED = 0x1 + NL80211_RADAR_CAC_STARTED = 0x5 + NL80211_RADAR_DETECTED = 0x0 + NL80211_RADAR_NOP_FINISHED = 0x3 + NL80211_RADAR_PRE_CAC_EXPIRED = 0x4 + NL80211_RATE_INFO_10_MHZ_WIDTH = 0xb + NL80211_RATE_INFO_160_MHZ_WIDTH = 0xa + NL80211_RATE_INFO_40_MHZ_WIDTH = 0x3 + NL80211_RATE_INFO_5_MHZ_WIDTH = 0xc + NL80211_RATE_INFO_80_MHZ_WIDTH = 0x8 + NL80211_RATE_INFO_80P80_MHZ_WIDTH = 0x9 + NL80211_RATE_INFO_BITRATE32 = 0x5 + NL80211_RATE_INFO_BITRATE = 0x1 + NL80211_RATE_INFO_HE_1XLTF = 0x0 + NL80211_RATE_INFO_HE_2XLTF = 0x1 + NL80211_RATE_INFO_HE_4XLTF = 0x2 + NL80211_RATE_INFO_HE_DCM = 0x10 + NL80211_RATE_INFO_HE_GI_0_8 = 0x0 + NL80211_RATE_INFO_HE_GI_1_6 = 0x1 + NL80211_RATE_INFO_HE_GI_3_2 = 0x2 + NL80211_RATE_INFO_HE_GI = 0xf + NL80211_RATE_INFO_HE_MCS = 0xd + NL80211_RATE_INFO_HE_NSS = 0xe + NL80211_RATE_INFO_HE_RU_ALLOC_106 = 0x2 + NL80211_RATE_INFO_HE_RU_ALLOC_242 = 0x3 + NL80211_RATE_INFO_HE_RU_ALLOC_26 = 0x0 + NL80211_RATE_INFO_HE_RU_ALLOC_2x996 = 0x6 + NL80211_RATE_INFO_HE_RU_ALLOC_484 = 0x4 + NL80211_RATE_INFO_HE_RU_ALLOC_52 = 0x1 + NL80211_RATE_INFO_HE_RU_ALLOC_996 = 0x5 + NL80211_RATE_INFO_HE_RU_ALLOC = 0x11 + NL80211_RATE_INFO_MAX = 0x11 + NL80211_RATE_INFO_MCS = 0x2 + NL80211_RATE_INFO_SHORT_GI = 0x4 + NL80211_RATE_INFO_VHT_MCS = 0x6 + NL80211_RATE_INFO_VHT_NSS = 0x7 + NL80211_REGDOM_SET_BY_CORE = 0x0 + NL80211_REGDOM_SET_BY_COUNTRY_IE = 0x3 + NL80211_REGDOM_SET_BY_DRIVER = 0x2 + NL80211_REGDOM_SET_BY_USER = 0x1 + NL80211_REGDOM_TYPE_COUNTRY = 0x0 + NL80211_REGDOM_TYPE_CUSTOM_WORLD = 0x2 + NL80211_REGDOM_TYPE_INTERSECTION = 0x3 + NL80211_REGDOM_TYPE_WORLD = 0x1 + NL80211_REG_RULE_ATTR_MAX = 0x7 + NL80211_REKEY_DATA_AKM = 0x4 + NL80211_REKEY_DATA_KCK = 0x2 + NL80211_REKEY_DATA_KEK = 0x1 + NL80211_REKEY_DATA_REPLAY_CTR = 0x3 + NL80211_REPLAY_CTR_LEN = 0x8 + NL80211_RRF_AUTO_BW = 0x800 + NL80211_RRF_DFS = 0x10 + NL80211_RRF_GO_CONCURRENT = 0x1000 + NL80211_RRF_IR_CONCURRENT = 0x1000 + NL80211_RRF_NO_160MHZ = 0x10000 + NL80211_RRF_NO_80MHZ = 0x8000 + NL80211_RRF_NO_CCK = 0x2 + NL80211_RRF_NO_HE = 0x20000 + NL80211_RRF_NO_HT40 = 0x6000 + NL80211_RRF_NO_HT40MINUS = 0x2000 + NL80211_RRF_NO_HT40PLUS = 0x4000 + NL80211_RRF_NO_IBSS = 0x80 + NL80211_RRF_NO_INDOOR = 0x4 + NL80211_RRF_NO_IR_ALL = 0x180 + NL80211_RRF_NO_IR = 0x80 + NL80211_RRF_NO_OFDM = 0x1 + NL80211_RRF_NO_OUTDOOR = 0x8 + NL80211_RRF_PASSIVE_SCAN = 0x80 + NL80211_RRF_PTMP_ONLY = 0x40 + NL80211_RRF_PTP_ONLY = 0x20 + NL80211_RXMGMT_FLAG_ANSWERED = 0x1 + NL80211_RXMGMT_FLAG_EXTERNAL_AUTH = 0x2 + NL80211_SAE_PWE_BOTH = 0x3 + NL80211_SAE_PWE_HASH_TO_ELEMENT = 0x2 + NL80211_SAE_PWE_HUNT_AND_PECK = 0x1 + NL80211_SAE_PWE_UNSPECIFIED = 0x0 + NL80211_SAR_ATTR_MAX = 0x2 + NL80211_SAR_ATTR_SPECS = 0x2 + NL80211_SAR_ATTR_SPECS_END_FREQ = 0x4 + NL80211_SAR_ATTR_SPECS_MAX = 0x4 + NL80211_SAR_ATTR_SPECS_POWER = 0x1 + NL80211_SAR_ATTR_SPECS_RANGE_INDEX = 0x2 + NL80211_SAR_ATTR_SPECS_START_FREQ = 0x3 + NL80211_SAR_ATTR_TYPE = 0x1 + NL80211_SAR_TYPE_POWER = 0x0 + NL80211_SCAN_FLAG_ACCEPT_BCAST_PROBE_RESP = 0x20 + NL80211_SCAN_FLAG_AP = 0x4 + NL80211_SCAN_FLAG_COLOCATED_6GHZ = 0x4000 + NL80211_SCAN_FLAG_FILS_MAX_CHANNEL_TIME = 0x10 + NL80211_SCAN_FLAG_FLUSH = 0x2 + NL80211_SCAN_FLAG_FREQ_KHZ = 0x2000 + NL80211_SCAN_FLAG_HIGH_ACCURACY = 0x400 + NL80211_SCAN_FLAG_LOW_POWER = 0x200 + NL80211_SCAN_FLAG_LOW_PRIORITY = 0x1 + NL80211_SCAN_FLAG_LOW_SPAN = 0x100 + NL80211_SCAN_FLAG_MIN_PREQ_CONTENT = 0x1000 + NL80211_SCAN_FLAG_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION = 0x80 + NL80211_SCAN_FLAG_OCE_PROBE_REQ_HIGH_TX_RATE = 0x40 + NL80211_SCAN_FLAG_RANDOM_ADDR = 0x8 + NL80211_SCAN_FLAG_RANDOM_SN = 0x800 + NL80211_SCAN_RSSI_THOLD_OFF = -0x12c + NL80211_SCHED_SCAN_MATCH_ATTR_BSSID = 0x5 + NL80211_SCHED_SCAN_MATCH_ATTR_MAX = 0x6 + NL80211_SCHED_SCAN_MATCH_ATTR_RELATIVE_RSSI = 0x3 + NL80211_SCHED_SCAN_MATCH_ATTR_RSSI_ADJUST = 0x4 + NL80211_SCHED_SCAN_MATCH_ATTR_RSSI = 0x2 + NL80211_SCHED_SCAN_MATCH_ATTR_SSID = 0x1 + NL80211_SCHED_SCAN_MATCH_PER_BAND_RSSI = 0x6 + NL80211_SCHED_SCAN_PLAN_INTERVAL = 0x1 + NL80211_SCHED_SCAN_PLAN_ITERATIONS = 0x2 + NL80211_SCHED_SCAN_PLAN_MAX = 0x2 + NL80211_SMPS_DYNAMIC = 0x2 + NL80211_SMPS_MAX = 0x2 + NL80211_SMPS_OFF = 0x0 + NL80211_SMPS_STATIC = 0x1 + NL80211_STA_BSS_PARAM_BEACON_INTERVAL = 0x5 + NL80211_STA_BSS_PARAM_CTS_PROT = 0x1 + NL80211_STA_BSS_PARAM_DTIM_PERIOD = 0x4 + NL80211_STA_BSS_PARAM_MAX = 0x5 + NL80211_STA_BSS_PARAM_SHORT_PREAMBLE = 0x2 + NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME = 0x3 + NL80211_STA_FLAG_ASSOCIATED = 0x7 + NL80211_STA_FLAG_AUTHENTICATED = 0x5 + NL80211_STA_FLAG_AUTHORIZED = 0x1 + NL80211_STA_FLAG_MAX = 0x7 + NL80211_STA_FLAG_MAX_OLD_API = 0x6 + NL80211_STA_FLAG_MFP = 0x4 + NL80211_STA_FLAG_SHORT_PREAMBLE = 0x2 + NL80211_STA_FLAG_TDLS_PEER = 0x6 + NL80211_STA_FLAG_WME = 0x3 + NL80211_STA_INFO_ACK_SIGNAL_AVG = 0x23 + NL80211_STA_INFO_ACK_SIGNAL = 0x22 + NL80211_STA_INFO_AIRTIME_LINK_METRIC = 0x29 + NL80211_STA_INFO_AIRTIME_WEIGHT = 0x28 + NL80211_STA_INFO_ASSOC_AT_BOOTTIME = 0x2a + NL80211_STA_INFO_BEACON_LOSS = 0x12 + NL80211_STA_INFO_BEACON_RX = 0x1d + NL80211_STA_INFO_BEACON_SIGNAL_AVG = 0x1e + NL80211_STA_INFO_BSS_PARAM = 0xf + NL80211_STA_INFO_CHAIN_SIGNAL_AVG = 0x1a + NL80211_STA_INFO_CHAIN_SIGNAL = 0x19 + NL80211_STA_INFO_CONNECTED_TIME = 0x10 + NL80211_STA_INFO_CONNECTED_TO_AS = 0x2b + NL80211_STA_INFO_CONNECTED_TO_GATE = 0x26 + NL80211_STA_INFO_DATA_ACK_SIGNAL_AVG = 0x23 + NL80211_STA_INFO_EXPECTED_THROUGHPUT = 0x1b + NL80211_STA_INFO_FCS_ERROR_COUNT = 0x25 + NL80211_STA_INFO_INACTIVE_TIME = 0x1 + NL80211_STA_INFO_LLID = 0x4 + NL80211_STA_INFO_LOCAL_PM = 0x14 + NL80211_STA_INFO_MAX = 0x2b + NL80211_STA_INFO_NONPEER_PM = 0x16 + NL80211_STA_INFO_PAD = 0x21 + NL80211_STA_INFO_PEER_PM = 0x15 + NL80211_STA_INFO_PLID = 0x5 + NL80211_STA_INFO_PLINK_STATE = 0x6 + NL80211_STA_INFO_RX_BITRATE = 0xe + NL80211_STA_INFO_RX_BYTES64 = 0x17 + NL80211_STA_INFO_RX_BYTES = 0x2 + NL80211_STA_INFO_RX_DROP_MISC = 0x1c + NL80211_STA_INFO_RX_DURATION = 0x20 + NL80211_STA_INFO_RX_MPDUS = 0x24 + NL80211_STA_INFO_RX_PACKETS = 0x9 + NL80211_STA_INFO_SIGNAL_AVG = 0xd + NL80211_STA_INFO_SIGNAL = 0x7 + NL80211_STA_INFO_STA_FLAGS = 0x11 + NL80211_STA_INFO_TID_STATS = 0x1f + NL80211_STA_INFO_T_OFFSET = 0x13 + NL80211_STA_INFO_TX_BITRATE = 0x8 + NL80211_STA_INFO_TX_BYTES64 = 0x18 + NL80211_STA_INFO_TX_BYTES = 0x3 + NL80211_STA_INFO_TX_DURATION = 0x27 + NL80211_STA_INFO_TX_FAILED = 0xc + NL80211_STA_INFO_TX_PACKETS = 0xa + NL80211_STA_INFO_TX_RETRIES = 0xb + NL80211_STA_WME_MAX = 0x2 + NL80211_STA_WME_MAX_SP = 0x2 + NL80211_STA_WME_UAPSD_QUEUES = 0x1 + NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY = 0x5 + NL80211_SURVEY_INFO_CHANNEL_TIME = 0x4 + NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY = 0x6 + NL80211_SURVEY_INFO_CHANNEL_TIME_RX = 0x7 + NL80211_SURVEY_INFO_CHANNEL_TIME_TX = 0x8 + NL80211_SURVEY_INFO_FREQUENCY = 0x1 + NL80211_SURVEY_INFO_FREQUENCY_OFFSET = 0xc + NL80211_SURVEY_INFO_IN_USE = 0x3 + NL80211_SURVEY_INFO_MAX = 0xc + NL80211_SURVEY_INFO_NOISE = 0x2 + NL80211_SURVEY_INFO_PAD = 0xa + NL80211_SURVEY_INFO_TIME_BSS_RX = 0xb + NL80211_SURVEY_INFO_TIME_BUSY = 0x5 + NL80211_SURVEY_INFO_TIME = 0x4 + NL80211_SURVEY_INFO_TIME_EXT_BUSY = 0x6 + NL80211_SURVEY_INFO_TIME_RX = 0x7 + NL80211_SURVEY_INFO_TIME_SCAN = 0x9 + NL80211_SURVEY_INFO_TIME_TX = 0x8 + NL80211_TDLS_DISABLE_LINK = 0x4 + NL80211_TDLS_DISCOVERY_REQ = 0x0 + NL80211_TDLS_ENABLE_LINK = 0x3 + NL80211_TDLS_PEER_HE = 0x8 + NL80211_TDLS_PEER_HT = 0x1 + NL80211_TDLS_PEER_VHT = 0x2 + NL80211_TDLS_PEER_WMM = 0x4 + NL80211_TDLS_SETUP = 0x1 + NL80211_TDLS_TEARDOWN = 0x2 + NL80211_TID_CONFIG_ATTR_AMPDU_CTRL = 0x9 + NL80211_TID_CONFIG_ATTR_AMSDU_CTRL = 0xb + NL80211_TID_CONFIG_ATTR_MAX = 0xd + NL80211_TID_CONFIG_ATTR_NOACK = 0x6 + NL80211_TID_CONFIG_ATTR_OVERRIDE = 0x4 + NL80211_TID_CONFIG_ATTR_PAD = 0x1 + NL80211_TID_CONFIG_ATTR_PEER_SUPP = 0x3 + NL80211_TID_CONFIG_ATTR_RETRY_LONG = 0x8 + NL80211_TID_CONFIG_ATTR_RETRY_SHORT = 0x7 + NL80211_TID_CONFIG_ATTR_RTSCTS_CTRL = 0xa + NL80211_TID_CONFIG_ATTR_TIDS = 0x5 + NL80211_TID_CONFIG_ATTR_TX_RATE = 0xd + NL80211_TID_CONFIG_ATTR_TX_RATE_TYPE = 0xc + NL80211_TID_CONFIG_ATTR_VIF_SUPP = 0x2 + NL80211_TID_CONFIG_DISABLE = 0x1 + NL80211_TID_CONFIG_ENABLE = 0x0 + NL80211_TID_STATS_MAX = 0x6 + NL80211_TID_STATS_PAD = 0x5 + NL80211_TID_STATS_RX_MSDU = 0x1 + NL80211_TID_STATS_TX_MSDU = 0x2 + NL80211_TID_STATS_TX_MSDU_FAILED = 0x4 + NL80211_TID_STATS_TX_MSDU_RETRIES = 0x3 + NL80211_TID_STATS_TXQ_STATS = 0x6 + NL80211_TIMEOUT_ASSOC = 0x3 + NL80211_TIMEOUT_AUTH = 0x2 + NL80211_TIMEOUT_SCAN = 0x1 + NL80211_TIMEOUT_UNSPECIFIED = 0x0 + NL80211_TKIP_DATA_OFFSET_ENCR_KEY = 0x0 + NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY = 0x18 + NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY = 0x10 + NL80211_TX_POWER_AUTOMATIC = 0x0 + NL80211_TX_POWER_FIXED = 0x2 + NL80211_TX_POWER_LIMITED = 0x1 + NL80211_TXQ_ATTR_AC = 0x1 + NL80211_TXQ_ATTR_AIFS = 0x5 + NL80211_TXQ_ATTR_CWMAX = 0x4 + NL80211_TXQ_ATTR_CWMIN = 0x3 + NL80211_TXQ_ATTR_MAX = 0x5 + NL80211_TXQ_ATTR_QUEUE = 0x1 + NL80211_TXQ_ATTR_TXOP = 0x2 + NL80211_TXQ_Q_BE = 0x2 + NL80211_TXQ_Q_BK = 0x3 + NL80211_TXQ_Q_VI = 0x1 + NL80211_TXQ_Q_VO = 0x0 + NL80211_TXQ_STATS_BACKLOG_BYTES = 0x1 + NL80211_TXQ_STATS_BACKLOG_PACKETS = 0x2 + NL80211_TXQ_STATS_COLLISIONS = 0x8 + NL80211_TXQ_STATS_DROPS = 0x4 + NL80211_TXQ_STATS_ECN_MARKS = 0x5 + NL80211_TXQ_STATS_FLOWS = 0x3 + NL80211_TXQ_STATS_MAX = 0xb + NL80211_TXQ_STATS_MAX_FLOWS = 0xb + NL80211_TXQ_STATS_OVERLIMIT = 0x6 + NL80211_TXQ_STATS_OVERMEMORY = 0x7 + NL80211_TXQ_STATS_TX_BYTES = 0x9 + NL80211_TXQ_STATS_TX_PACKETS = 0xa + NL80211_TX_RATE_AUTOMATIC = 0x0 + NL80211_TXRATE_DEFAULT_GI = 0x0 + NL80211_TX_RATE_FIXED = 0x2 + NL80211_TXRATE_FORCE_LGI = 0x2 + NL80211_TXRATE_FORCE_SGI = 0x1 + NL80211_TXRATE_GI = 0x4 + NL80211_TXRATE_HE = 0x5 + NL80211_TXRATE_HE_GI = 0x6 + NL80211_TXRATE_HE_LTF = 0x7 + NL80211_TXRATE_HT = 0x2 + NL80211_TXRATE_LEGACY = 0x1 + NL80211_TX_RATE_LIMITED = 0x1 + NL80211_TXRATE_MAX = 0x7 + NL80211_TXRATE_MCS = 0x2 + NL80211_TXRATE_VHT = 0x3 + NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INT = 0x1 + NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_MAX = 0x2 + NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_TMPL = 0x2 + NL80211_USER_REG_HINT_CELL_BASE = 0x1 + NL80211_USER_REG_HINT_INDOOR = 0x2 + NL80211_USER_REG_HINT_USER = 0x0 + NL80211_VENDOR_ID_IS_LINUX = 0x80000000 + NL80211_VHT_CAPABILITY_LEN = 0xc + NL80211_VHT_NSS_MAX = 0x8 + NL80211_WIPHY_NAME_MAXLEN = 0x40 + NL80211_WMMR_AIFSN = 0x3 + NL80211_WMMR_CW_MAX = 0x2 + NL80211_WMMR_CW_MIN = 0x1 + NL80211_WMMR_MAX = 0x4 + NL80211_WMMR_TXOP = 0x4 + NL80211_WOWLAN_PKTPAT_MASK = 0x1 + NL80211_WOWLAN_PKTPAT_OFFSET = 0x3 + NL80211_WOWLAN_PKTPAT_PATTERN = 0x2 + NL80211_WOWLAN_TCP_DATA_INTERVAL = 0x9 + NL80211_WOWLAN_TCP_DATA_PAYLOAD = 0x6 + NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ = 0x7 + NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN = 0x8 + NL80211_WOWLAN_TCP_DST_IPV4 = 0x2 + NL80211_WOWLAN_TCP_DST_MAC = 0x3 + NL80211_WOWLAN_TCP_DST_PORT = 0x5 + NL80211_WOWLAN_TCP_SRC_IPV4 = 0x1 + NL80211_WOWLAN_TCP_SRC_PORT = 0x4 + NL80211_WOWLAN_TCP_WAKE_MASK = 0xb + NL80211_WOWLAN_TCP_WAKE_PAYLOAD = 0xa + NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE = 0x8 + NL80211_WOWLAN_TRIG_ANY = 0x1 + NL80211_WOWLAN_TRIG_DISCONNECT = 0x2 + NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST = 0x7 + NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE = 0x6 + NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED = 0x5 + NL80211_WOWLAN_TRIG_MAGIC_PKT = 0x3 + NL80211_WOWLAN_TRIG_NET_DETECT = 0x12 + NL80211_WOWLAN_TRIG_NET_DETECT_RESULTS = 0x13 + NL80211_WOWLAN_TRIG_PKT_PATTERN = 0x4 + NL80211_WOWLAN_TRIG_RFKILL_RELEASE = 0x9 + NL80211_WOWLAN_TRIG_TCP_CONNECTION = 0xe + NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211 = 0xa + NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN = 0xb + NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023 = 0xc + NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN = 0xd + NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST = 0x10 + NL80211_WOWLAN_TRIG_WAKEUP_TCP_MATCH = 0xf + NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS = 0x11 + NL80211_WPA_VERSION_1 = 0x1 + NL80211_WPA_VERSION_2 = 0x2 + NL80211_WPA_VERSION_3 = 0x4 +) + +const ( + FRA_UNSPEC = 0x0 + FRA_DST = 0x1 + FRA_SRC = 0x2 + FRA_IIFNAME = 0x3 + FRA_GOTO = 0x4 + FRA_UNUSED2 = 0x5 + FRA_PRIORITY = 0x6 + FRA_UNUSED3 = 0x7 + FRA_UNUSED4 = 0x8 + FRA_UNUSED5 = 0x9 + FRA_FWMARK = 0xa + FRA_FLOW = 0xb + FRA_TUN_ID = 0xc + FRA_SUPPRESS_IFGROUP = 0xd + FRA_SUPPRESS_PREFIXLEN = 0xe + FRA_TABLE = 0xf + FRA_FWMASK = 0x10 + FRA_OIFNAME = 0x11 + FRA_PAD = 0x12 + FRA_L3MDEV = 0x13 + FRA_UID_RANGE = 0x14 + FRA_PROTOCOL = 0x15 + FRA_IP_PROTO = 0x16 + FRA_SPORT_RANGE = 0x17 + FRA_DPORT_RANGE = 0x18 + FR_ACT_UNSPEC = 0x0 + FR_ACT_TO_TBL = 0x1 + FR_ACT_GOTO = 0x2 + FR_ACT_NOP = 0x3 + FR_ACT_RES3 = 0x4 + FR_ACT_RES4 = 0x5 + FR_ACT_BLACKHOLE = 0x6 + FR_ACT_UNREACHABLE = 0x7 + FR_ACT_PROHIBIT = 0x8 +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index bea25494..53140925 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -240,6 +240,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -250,6 +254,13 @@ type Sigset_t struct { const _C__NSIG = 0x41 +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ [116]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -311,6 +322,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index b8c8f289..b02ab83d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -255,6 +255,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -265,6 +269,14 @@ type Sigset_t struct { const _C__NSIG = 0x41 +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ int32 + _ [112]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -324,6 +336,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint64 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index 4db44301..9e6871d2 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -231,6 +231,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -241,6 +245,13 @@ type Sigset_t struct { const _C__NSIG = 0x41 +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ [116]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -302,6 +313,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index 3ebcad8a..b732d125 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -234,6 +234,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -244,6 +248,14 @@ type Sigset_t struct { const _C__NSIG = 0x41 +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ int32 + _ [112]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -303,6 +315,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint64 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go new file mode 100644 index 00000000..61fbb24f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go @@ -0,0 +1,679 @@ +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build loong64 && linux +// +build loong64,linux + +package unix + +const ( + SizeofPtr = 0x8 + SizeofLong = 0x8 +) + +type ( + _C_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + _ [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Stat_t struct { + Dev uint64 + Ino uint64 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint64 + _ uint64 + Size int64 + Blksize int32 + _ int32 + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + _ [2]int32 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + _ [5]byte +} + +type Flock_t struct { + Type int16 + Whence int16 + Start int64 + Len int64 + Pid int32 + _ [4]byte +} + +type DmNameList struct { + Dev uint64 + Next uint32 + Name [0]byte + _ [4]byte +} + +const ( + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrNFCLLCP struct { + Sa_family uint16 + Dev_idx uint32 + Target_idx uint32 + Nfc_protocol uint32 + Dsap uint8 + Ssap uint8 + Service_name [63]uint8 + Service_name_len uint64 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + _ [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 +} + +type ifreq struct { + Ifrn [16]byte + Ifru [24]byte +} + +const ( + SizeofSockaddrNFCLLCP = 0x60 + SizeofIovec = 0x10 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 +) + +const ( + SizeofSockFprog = 0x10 +) + +type PtraceRegs struct { + Regs [32]uint64 + Orig_a0 uint64 + Era uint64 + Badv uint64 + Reserved [10]uint64 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + _ [0]int8 + _ [4]byte +} + +type Ustat_t struct { + Tfree int32 + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + _ [4]byte +} + +type EpollEvent struct { + Events uint32 + _ int32 + Fd int32 + Pad int32 +} + +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + +const ( + POLLRDHUP = 0x2000 +) + +type Sigset_t struct { + Val [16]uint64 +} + +const _C__NSIG = 0x41 + +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ int32 + _ [112]byte +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 +} + +type Taskstats struct { + Version uint16 + Ac_exitcode uint32 + Ac_flag uint8 + Ac_nice uint8 + Cpu_count uint64 + Cpu_delay_total uint64 + Blkio_count uint64 + Blkio_delay_total uint64 + Swapin_count uint64 + Swapin_delay_total uint64 + Cpu_run_real_total uint64 + Cpu_run_virtual_total uint64 + Ac_comm [32]int8 + Ac_sched uint8 + Ac_pad [3]uint8 + _ [4]byte + Ac_uid uint32 + Ac_gid uint32 + Ac_pid uint32 + Ac_ppid uint32 + Ac_btime uint32 + Ac_etime uint64 + Ac_utime uint64 + Ac_stime uint64 + Ac_minflt uint64 + Ac_majflt uint64 + Coremem uint64 + Virtmem uint64 + Hiwater_rss uint64 + Hiwater_vm uint64 + Read_char uint64 + Write_char uint64 + Read_syscalls uint64 + Write_syscalls uint64 + Read_bytes uint64 + Write_bytes uint64 + Cancelled_write_bytes uint64 + Nvcsw uint64 + Nivcsw uint64 + Ac_utimescaled uint64 + Ac_stimescaled uint64 + Cpu_scaled_run_real_total uint64 + Freepages_count uint64 + Freepages_delay_total uint64 + Thrashing_count uint64 + Thrashing_delay_total uint64 + Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 +} + +type cpuMask uint64 + +const ( + _NCPUBITS = 0x40 +) + +const ( + CBitFieldMaskBit0 = 0x1 + CBitFieldMaskBit1 = 0x2 + CBitFieldMaskBit2 = 0x4 + CBitFieldMaskBit3 = 0x8 + CBitFieldMaskBit4 = 0x10 + CBitFieldMaskBit5 = 0x20 + CBitFieldMaskBit6 = 0x40 + CBitFieldMaskBit7 = 0x80 + CBitFieldMaskBit8 = 0x100 + CBitFieldMaskBit9 = 0x200 + CBitFieldMaskBit10 = 0x400 + CBitFieldMaskBit11 = 0x800 + CBitFieldMaskBit12 = 0x1000 + CBitFieldMaskBit13 = 0x2000 + CBitFieldMaskBit14 = 0x4000 + CBitFieldMaskBit15 = 0x8000 + CBitFieldMaskBit16 = 0x10000 + CBitFieldMaskBit17 = 0x20000 + CBitFieldMaskBit18 = 0x40000 + CBitFieldMaskBit19 = 0x80000 + CBitFieldMaskBit20 = 0x100000 + CBitFieldMaskBit21 = 0x200000 + CBitFieldMaskBit22 = 0x400000 + CBitFieldMaskBit23 = 0x800000 + CBitFieldMaskBit24 = 0x1000000 + CBitFieldMaskBit25 = 0x2000000 + CBitFieldMaskBit26 = 0x4000000 + CBitFieldMaskBit27 = 0x8000000 + CBitFieldMaskBit28 = 0x10000000 + CBitFieldMaskBit29 = 0x20000000 + CBitFieldMaskBit30 = 0x40000000 + CBitFieldMaskBit31 = 0x80000000 + CBitFieldMaskBit32 = 0x100000000 + CBitFieldMaskBit33 = 0x200000000 + CBitFieldMaskBit34 = 0x400000000 + CBitFieldMaskBit35 = 0x800000000 + CBitFieldMaskBit36 = 0x1000000000 + CBitFieldMaskBit37 = 0x2000000000 + CBitFieldMaskBit38 = 0x4000000000 + CBitFieldMaskBit39 = 0x8000000000 + CBitFieldMaskBit40 = 0x10000000000 + CBitFieldMaskBit41 = 0x20000000000 + CBitFieldMaskBit42 = 0x40000000000 + CBitFieldMaskBit43 = 0x80000000000 + CBitFieldMaskBit44 = 0x100000000000 + CBitFieldMaskBit45 = 0x200000000000 + CBitFieldMaskBit46 = 0x400000000000 + CBitFieldMaskBit47 = 0x800000000000 + CBitFieldMaskBit48 = 0x1000000000000 + CBitFieldMaskBit49 = 0x2000000000000 + CBitFieldMaskBit50 = 0x4000000000000 + CBitFieldMaskBit51 = 0x8000000000000 + CBitFieldMaskBit52 = 0x10000000000000 + CBitFieldMaskBit53 = 0x20000000000000 + CBitFieldMaskBit54 = 0x40000000000000 + CBitFieldMaskBit55 = 0x80000000000000 + CBitFieldMaskBit56 = 0x100000000000000 + CBitFieldMaskBit57 = 0x200000000000000 + CBitFieldMaskBit58 = 0x400000000000000 + CBitFieldMaskBit59 = 0x800000000000000 + CBitFieldMaskBit60 = 0x1000000000000000 + CBitFieldMaskBit61 = 0x2000000000000000 + CBitFieldMaskBit62 = 0x4000000000000000 + CBitFieldMaskBit63 = 0x8000000000000000 +) + +type SockaddrStorage struct { + Family uint16 + _ [118]int8 + _ uint64 +} + +type HDGeometry struct { + Heads uint8 + Sectors uint8 + Cylinders uint16 + Start uint64 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen int64 + Frsize int64 + Flags int64 + Spare [4]int64 +} + +type TpacketHdr struct { + Status uint64 + Len uint32 + Snaplen uint32 + Mac uint16 + Net uint16 + Sec uint32 + Usec uint32 + _ [4]byte +} + +const ( + SizeofTpacketHdr = 0x20 +) + +type RTCPLLInfo struct { + Ctrl int32 + Value int32 + Max int32 + Min int32 + Posmult int32 + Negmult int32 + Clock int64 +} + +type BlkpgPartition struct { + Start int64 + Length int64 + Pno int32 + Devname [64]uint8 + Volname [64]uint8 + _ [4]byte +} + +const ( + BLKPG = 0x1269 +) + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 + Flags uint32 + _ [4]byte +} + +type CryptoUserAlg struct { + Name [64]int8 + Driver_name [64]int8 + Module_name [64]int8 + Type uint32 + Mask uint32 + Refcnt uint32 + Flags uint32 +} + +type CryptoStatAEAD struct { + Type [64]int8 + Encrypt_cnt uint64 + Encrypt_tlen uint64 + Decrypt_cnt uint64 + Decrypt_tlen uint64 + Err_cnt uint64 +} + +type CryptoStatAKCipher struct { + Type [64]int8 + Encrypt_cnt uint64 + Encrypt_tlen uint64 + Decrypt_cnt uint64 + Decrypt_tlen uint64 + Verify_cnt uint64 + Sign_cnt uint64 + Err_cnt uint64 +} + +type CryptoStatCipher struct { + Type [64]int8 + Encrypt_cnt uint64 + Encrypt_tlen uint64 + Decrypt_cnt uint64 + Decrypt_tlen uint64 + Err_cnt uint64 +} + +type CryptoStatCompress struct { + Type [64]int8 + Compress_cnt uint64 + Compress_tlen uint64 + Decompress_cnt uint64 + Decompress_tlen uint64 + Err_cnt uint64 +} + +type CryptoStatHash struct { + Type [64]int8 + Hash_cnt uint64 + Hash_tlen uint64 + Err_cnt uint64 +} + +type CryptoStatKPP struct { + Type [64]int8 + Setsecret_cnt uint64 + Generate_public_key_cnt uint64 + Compute_shared_secret_cnt uint64 + Err_cnt uint64 +} + +type CryptoStatRNG struct { + Type [64]int8 + Generate_cnt uint64 + Generate_tlen uint64 + Seed_cnt uint64 + Err_cnt uint64 +} + +type CryptoStatLarval struct { + Type [64]int8 +} + +type CryptoReportLarval struct { + Type [64]int8 +} + +type CryptoReportHash struct { + Type [64]int8 + Blocksize uint32 + Digestsize uint32 +} + +type CryptoReportCipher struct { + Type [64]int8 + Blocksize uint32 + Min_keysize uint32 + Max_keysize uint32 +} + +type CryptoReportBlkCipher struct { + Type [64]int8 + Geniv [64]int8 + Blocksize uint32 + Min_keysize uint32 + Max_keysize uint32 + Ivsize uint32 +} + +type CryptoReportAEAD struct { + Type [64]int8 + Geniv [64]int8 + Blocksize uint32 + Maxauthsize uint32 + Ivsize uint32 +} + +type CryptoReportComp struct { + Type [64]int8 +} + +type CryptoReportRNG struct { + Type [64]int8 + Seedsize uint32 +} + +type CryptoReportAKCipher struct { + Type [64]int8 +} + +type CryptoReportKPP struct { + Type [64]int8 +} + +type CryptoReportAcomp struct { + Type [64]int8 +} + +type LoopInfo struct { + Number int32 + Device uint32 + Inode uint64 + Rdevice uint32 + Offset int32 + Encrypt_type int32 + Encrypt_key_size int32 + Flags int32 + Name [64]int8 + Encrypt_key [32]uint8 + Init [2]uint64 + Reserved [4]int8 + _ [4]byte +} + +type TIPCSubscr struct { + Seq TIPCServiceRange + Timeout uint32 + Filter uint32 + Handle [8]int8 +} + +type TIPCSIOCLNReq struct { + Peer uint32 + Id uint32 + Linkname [68]int8 +} + +type TIPCSIOCNodeIDReq struct { + Peer uint32 + Id [16]int8 +} + +type PPSKInfo struct { + Assert_sequence uint32 + Clear_sequence uint32 + Assert_tu PPSKTime + Clear_tu PPSKTime + Current_mode int32 + _ [4]byte +} + +const ( + PPS_GETPARAMS = 0x800870a1 + PPS_SETPARAMS = 0x400870a2 + PPS_GETCAP = 0x800870a3 + PPS_FETCH = 0xc00870a4 +) + +const ( + PIDFD_NONBLOCK = 0x800 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + _ [0]uint8 + Seq uint16 + _ uint16 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint64 + Atime int64 + Dtime int64 + Ctime int64 + Cpid int32 + Lpid int32 + Nattch uint64 + _ uint64 + _ uint64 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index 3eb33e48..5310f71e 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -236,6 +236,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -246,6 +250,13 @@ type Sigset_t struct { const _C__NSIG = 0x80 +type Siginfo struct { + Signo int32 + Code int32 + Errno int32 + _ [116]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -307,6 +318,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index 79a94467..219bbb12 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -237,6 +237,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -247,6 +251,14 @@ type Sigset_t struct { const _C__NSIG = 0x80 +type Siginfo struct { + Signo int32 + Code int32 + Errno int32 + _ int32 + _ [112]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -306,6 +318,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint64 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index 8f4b107c..be9432da 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -237,6 +237,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -247,6 +251,14 @@ type Sigset_t struct { const _C__NSIG = 0x80 +type Siginfo struct { + Signo int32 + Code int32 + Errno int32 + _ int32 + _ [112]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -306,6 +318,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint64 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index e4eb2179..d0155a42 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -236,6 +236,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -246,6 +250,13 @@ type Sigset_t struct { const _C__NSIG = 0x80 +type Siginfo struct { + Signo int32 + Code int32 + Errno int32 + _ [116]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -307,6 +318,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go index d5b21f0f..01c17bcc 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go @@ -243,6 +243,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -253,6 +257,13 @@ type Sigset_t struct { const _C__NSIG = 0x41 +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ [116]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -314,6 +325,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index 5188d142..944a9c3c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -244,6 +244,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -254,6 +258,14 @@ type Sigset_t struct { const _C__NSIG = 0x41 +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ int32 + _ [112]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -313,6 +325,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint64 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index de4dd4c7..5d2c90e1 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -244,6 +244,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -254,6 +258,14 @@ type Sigset_t struct { const _C__NSIG = 0x41 +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ int32 + _ [112]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -313,6 +325,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint64 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index dccbf9b0..e173cb51 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -262,6 +262,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -272,6 +276,14 @@ type Sigset_t struct { const _C__NSIG = 0x41 +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ int32 + _ [112]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -331,6 +343,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint64 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index 63588061..6106715d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -210,8 +210,8 @@ type PtraceFpregs struct { } type PtracePer struct { - _ [0]uint64 - _ [32]byte + Control_regs [3]uint64 + _ [8]byte Starting_addr uint64 Ending_addr uint64 Perc_atmid uint16 @@ -257,6 +257,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + const ( POLLRDHUP = 0x2000 ) @@ -267,6 +271,14 @@ type Sigset_t struct { const _C__NSIG = 0x41 +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ int32 + _ [112]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -326,6 +338,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint64 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go index 765edc13..ca7b37b4 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go @@ -239,6 +239,10 @@ type EpollEvent struct { Pad int32 } +const ( + OPEN_TREE_CLOEXEC = 0x400000 +) + const ( POLLRDHUP = 0x800 ) @@ -249,6 +253,14 @@ type Sigset_t struct { const _C__NSIG = 0x41 +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ int32 + _ [112]byte +} + type Termios struct { Iflag uint32 Oflag uint32 @@ -308,6 +320,8 @@ type Taskstats struct { Thrashing_count uint64 Thrashing_delay_total uint64 Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 } type cpuMask uint64 diff --git a/vendor/golang.org/x/sys/windows/exec_windows.go b/vendor/golang.org/x/sys/windows/exec_windows.go index 855698bb..75980fd4 100644 --- a/vendor/golang.org/x/sys/windows/exec_windows.go +++ b/vendor/golang.org/x/sys/windows/exec_windows.go @@ -15,11 +15,11 @@ import ( // in http://msdn.microsoft.com/en-us/library/ms880421. // This function returns "" (2 double quotes) if s is empty. // Alternatively, these transformations are done: -// - every back slash (\) is doubled, but only if immediately -// followed by double quote ("); -// - every double quote (") is escaped by back slash (\); -// - finally, s is wrapped with double quotes (arg -> "arg"), -// but only if there is space or tab inside s. +// - every back slash (\) is doubled, but only if immediately +// followed by double quote ("); +// - every double quote (") is escaped by back slash (\); +// - finally, s is wrapped with double quotes (arg -> "arg"), +// but only if there is space or tab inside s. func EscapeArg(s string) string { if len(s) == 0 { return "\"\"" diff --git a/vendor/golang.org/x/sys/windows/registry/key.go b/vendor/golang.org/x/sys/windows/registry/key.go index 906325e0..6c8d97b6 100644 --- a/vendor/golang.org/x/sys/windows/registry/key.go +++ b/vendor/golang.org/x/sys/windows/registry/key.go @@ -20,7 +20,6 @@ // log.Fatal(err) // } // fmt.Printf("Windows system root is %q\n", s) -// package registry import ( diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index cf44e693..636e5de6 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -10,6 +10,7 @@ import ( errorspkg "errors" "fmt" "runtime" + "strings" "sync" "syscall" "time" @@ -86,10 +87,8 @@ func StringToUTF16(s string) []uint16 { // s, with a terminating NUL added. If s contains a NUL byte at any // location, it returns (nil, syscall.EINVAL). func UTF16FromString(s string) ([]uint16, error) { - for i := 0; i < len(s); i++ { - if s[i] == 0 { - return nil, syscall.EINVAL - } + if strings.IndexByte(s, 0) != -1 { + return nil, syscall.EINVAL } return utf16.Encode([]rune(s + "\x00")), nil } @@ -186,8 +185,8 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) //sys GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW //sys SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) = SetNamedPipeHandleState -//sys ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) -//sys WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) +//sys readFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) = ReadFile +//sys writeFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) = WriteFile //sys GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) //sys SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) [failretval==0xffffffff] //sys CloseHandle(handle Handle) (err error) @@ -549,12 +548,6 @@ func Read(fd Handle, p []byte) (n int, err error) { } return 0, e } - if raceenabled { - if done > 0 { - raceWriteRange(unsafe.Pointer(&p[0]), int(done)) - } - raceAcquire(unsafe.Pointer(&ioSync)) - } return int(done), nil } @@ -567,12 +560,31 @@ func Write(fd Handle, p []byte) (n int, err error) { if e != nil { return 0, e } - if raceenabled && done > 0 { - raceReadRange(unsafe.Pointer(&p[0]), int(done)) - } return int(done), nil } +func ReadFile(fd Handle, p []byte, done *uint32, overlapped *Overlapped) error { + err := readFile(fd, p, done, overlapped) + if raceenabled { + if *done > 0 { + raceWriteRange(unsafe.Pointer(&p[0]), int(*done)) + } + raceAcquire(unsafe.Pointer(&ioSync)) + } + return err +} + +func WriteFile(fd Handle, p []byte, done *uint32, overlapped *Overlapped) error { + if raceenabled { + raceReleaseMerge(unsafe.Pointer(&ioSync)) + } + err := writeFile(fd, p, done, overlapped) + if raceenabled && *done > 0 { + raceReadRange(unsafe.Pointer(&p[0]), int(*done)) + } + return err +} + var ioSync int64 func Seek(fd Handle, offset int64, whence int) (newoffset int64, err error) { @@ -611,7 +623,6 @@ var ( func getStdHandle(stdhandle uint32) (fd Handle) { r, _ := GetStdHandle(stdhandle) - CloseOnExec(r) return r } diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 9ea1a44f..68f52c1e 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -2761,7 +2761,7 @@ func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree return } -func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { +func readFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { var _p0 *byte if len(buf) > 0 { _p0 = &buf[0] @@ -3203,7 +3203,7 @@ func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, return } -func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { +func writeFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { var _p0 *byte if len(buf) > 0 { _p0 = &buf[0] diff --git a/vendor/modules.txt b/vendor/modules.txt index c6f971c5..6d17471f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -4,16 +4,21 @@ github.com/Azure/azure-pipeline-go/pipeline # github.com/Azure/azure-storage-blob-go v0.14.0 ## explicit; go 1.15 github.com/Azure/azure-storage-blob-go/azblob -# github.com/ClickHouse/clickhouse-go v1.5.2 +# github.com/ClickHouse/clickhouse-go v1.5.4 ## explicit; go 1.12 -github.com/ClickHouse/clickhouse-go -github.com/ClickHouse/clickhouse-go/lib/binary -github.com/ClickHouse/clickhouse-go/lib/cityhash102 -github.com/ClickHouse/clickhouse-go/lib/column -github.com/ClickHouse/clickhouse-go/lib/data -github.com/ClickHouse/clickhouse-go/lib/lz4 -github.com/ClickHouse/clickhouse-go/lib/protocol -github.com/ClickHouse/clickhouse-go/lib/types +# github.com/ClickHouse/clickhouse-go/v2 v2.0.14 +## explicit; go 1.16 +github.com/ClickHouse/clickhouse-go/v2 +github.com/ClickHouse/clickhouse-go/v2/contributors +github.com/ClickHouse/clickhouse-go/v2/ext +github.com/ClickHouse/clickhouse-go/v2/lib/binary +github.com/ClickHouse/clickhouse-go/v2/lib/cityhash102 +github.com/ClickHouse/clickhouse-go/v2/lib/column +github.com/ClickHouse/clickhouse-go/v2/lib/compress +github.com/ClickHouse/clickhouse-go/v2/lib/driver +github.com/ClickHouse/clickhouse-go/v2/lib/io +github.com/ClickHouse/clickhouse-go/v2/lib/proto +github.com/ClickHouse/clickhouse-go/v2/lib/timezone # github.com/apache/arrow/go/arrow v0.0.0-20211112161151-bc219186db40 ## explicit; go 1.15 github.com/apache/arrow/go/arrow @@ -156,7 +161,6 @@ github.com/cenkalti/backoff github.com/cespare/xxhash/v2 # github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 ## explicit -github.com/cloudflare/golz4 # github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73 ## explicit; go 1.11 github.com/denisenkom/go-mssqldb @@ -226,7 +230,10 @@ github.com/mattn/go-ieproxy # github.com/matttproud/golang_protobuf_extensions v1.0.1 ## explicit github.com/matttproud/golang_protobuf_extensions/pbutil -# github.com/pierrec/lz4/v4 v4.1.11 +# github.com/paulmach/orb v0.7.1 +## explicit; go 1.15 +github.com/paulmach/orb +# github.com/pierrec/lz4/v4 v4.1.14 ## explicit; go 1.14 github.com/pierrec/lz4/v4 github.com/pierrec/lz4/v4/internal/lz4block @@ -263,6 +270,9 @@ github.com/robfig/cron/v3 # github.com/segmentio/go-athena v0.0.0-20181208004937-dfa5f1818930 ## explicit github.com/segmentio/go-athena +# github.com/shopspring/decimal v1.3.1 +## explicit; go 1.13 +github.com/shopspring/decimal # github.com/sirupsen/logrus v1.8.1 ## explicit; go 1.13 github.com/sirupsen/logrus @@ -277,6 +287,14 @@ github.com/vertica/vertica-sql-go/logger github.com/vertica/vertica-sql-go/msgs github.com/vertica/vertica-sql-go/parse github.com/vertica/vertica-sql-go/rowcache +# go.opentelemetry.io/otel v1.7.0 +## explicit; go 1.16 +go.opentelemetry.io/otel/attribute +go.opentelemetry.io/otel/codes +go.opentelemetry.io/otel/internal +# go.opentelemetry.io/otel/trace v1.7.0 +## explicit; go 1.16 +go.opentelemetry.io/otel/trace # golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 ## explicit; go 1.17 golang.org/x/crypto/md4 @@ -287,7 +305,7 @@ golang.org/x/net/html golang.org/x/net/html/atom golang.org/x/net/http/httpproxy golang.org/x/net/idna -# golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 +# golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 ## explicit; go 1.17 golang.org/x/sys/internal/unsafeheader golang.org/x/sys/unix