Compare commits

...

9 Commits

Author SHA1 Message Date
Carlos Salguero
c874287220 Fixed merge conflicts with 3.x branch 2021-08-27 14:00:33 -03:00
Carlos Salguero
f8683b76fa Merge branch '3.x' into PT-1900 2021-08-27 13:57:10 -03:00
Carlos Salguero
b309b23222 PT-1900 Fixed query rewriter to properly handle quoted text 2021-08-27 09:14:05 -03:00
Carlos Salguero
3f20158067 Fixed quoted strings regexes 2021-08-27 07:12:05 -03:00
Sergey Pronin
ee6a9da438 Update installation.rst (#508)
1. the list of operation systems is outdated
2. not on any installation page we have the list of supported OSes
3. we have supported OSes in our lifecycle doc - why add it here?
2021-08-20 11:22:54 +03:00
Paul Jacobs
e71fc0376b Spelling 2021-08-20 08:21:18 +03:00
Carlos Salguero
4b8ae0563f PMM-8489 Cluster ID for standalone server (#507)
* PMM-8489 Cluster ID for standalone server

* Updated error type

* Updated MyState to ignore errors on standalone servers

* Deleted dep files

* Revert "Deleted dep files"

This reverts commit 236303196b.

* Removed go.mod &^ updated lock

* Updated mongodb driver

* PMM-8489 Updated errors list
2021-08-18 11:22:47 -03:00
Roma Novikov
7eaca8a98e versions update (#505)
* versions update 

according to https://www.percona.com/services/policies/percona-software-support-lifecycle#pt

* correcting Debian versions (forgot to change them)

according to https://www.percona.com/services/policies/percona-software-support-lifecycle#pt
2021-08-10 07:50:41 -03:00
Carlos Salguero
af0f6db9f2 PT-1900 WIP 2020-12-29 10:17:34 -03:00
14 changed files with 170 additions and 144 deletions

122
Gopkg.lock generated
View File

@@ -79,6 +79,14 @@
revision = "97b6244175ae18ea6eef668034fd6565847501c9"
version = "v1.2.4"
[[projects]]
digest = "1:a01080d20c45c031c13f3828c56e58f4f51d926a482ad10cc0316225097eb7ea"
name = "github.com/go-stack/stack"
packages = ["."]
pruneopts = ""
revision = "2fee6af1a9795aafbe0253a0cfbdf668e1fb8a9a"
version = "v1.8.0"
[[projects]]
digest = "1:d69d2ba23955582a64e367ff2b0808cdbd048458c178cea48f11ab8c40bd7aea"
name = "github.com/gogo/protobuf"
@@ -91,15 +99,7 @@
version = "v1.3.1"
[[projects]]
digest = "1:a01080d20c45c031c13f3828c56e58f4f51d926a482ad10cc0316225097eb7ea"
name = "github.com/go-stack/stack"
packages = ["."]
pruneopts = ""
revision = "2fee6af1a9795aafbe0253a0cfbdf668e1fb8a9a"
version = "v1.8.0"
[[projects]]
digest = "1:530233672f656641b365f8efb38ed9fba80e420baff2ce87633813ab3755ed6d"
digest = "1:68c64bb61d55dcd17c82ca0b871ddddb5ae18b30cfe26f6bfd4b6df6287dc2e0"
name = "github.com/golang/mock"
packages = ["gomock"]
pruneopts = ""
@@ -114,14 +114,6 @@
pruneopts = ""
revision = "ff6b7dc882cf4cfba7ee0b9f7dcc1ac096c554aa"
[[projects]]
digest = "1:ad92aa49f34cbc3546063c7eb2cabb55ee2278b72842eda80e2a20a8a06a8d73"
name = "github.com/google/uuid"
packages = ["."]
pruneopts = ""
revision = "0cd6bf5da1e1c83f8b45653022c74f71af0538a4"
version = "v1.1.1"
[[projects]]
digest = "1:16ecf9e89b8b1310d9566a53484c31c5241bb47c32162eba780b46c0dfb58fef"
name = "github.com/google/gofuzz"
@@ -130,6 +122,14 @@
revision = "db92cf7ae75e4a7a28abc005addab2b394362888"
version = "v1.1.0"
[[projects]]
digest = "1:ad92aa49f34cbc3546063c7eb2cabb55ee2278b72842eda80e2a20a8a06a8d73"
name = "github.com/google/uuid"
packages = ["."]
pruneopts = ""
revision = "0cd6bf5da1e1c83f8b45653022c74f71af0538a4"
version = "v1.1.1"
[[projects]]
branch = "master"
digest = "1:4fbfcfe715329e2f09ea644657aa791b81e73a0c835a4f79b9a0dfff0513e2b8"
@@ -270,23 +270,39 @@
version = "v1.6.1"
[[projects]]
branch = "master"
digest = "1:ad74f33a69bd6ab0bd7287003b7c1069b94cfb5213eb5597005fe2963d7dfca9"
name = "github.com/xdg/scram"
digest = "1:e3c192bbd32961c2aa86ac067d695fda6dcaa27c14d5b334ba5e1e8e1caf0d02"
name = "github.com/xdg-go/pbkdf2"
packages = ["."]
pruneopts = ""
revision = "7eeb5667e42c09cb51bf7b7c28aea8c56767da90"
revision = "7f452ef1dac88350356f1bb84a23748205e64b96"
version = "v1.0.0"
[[projects]]
branch = "master"
digest = "1:62f6eb06f6f39d18fc961956116a50a0e52b89961ed8a83bbb950b4cfb09fe67"
name = "github.com/xdg/stringprep"
digest = "1:c690666fc473c441d92d0765c1f773825b34086d1148e357e7b5ea8ae0925e8c"
name = "github.com/xdg-go/scram"
packages = ["."]
pruneopts = ""
revision = "73f8eece6fdcd902c185bf651de50f3828bed5ed"
revision = "2ad501880a7f7bcc9af290278baa3658c9a2f2cd"
version = "v1.0.2"
[[projects]]
digest = "1:6085253f6bc0d9e4761ce971e02849b626de51735b35f362a34dbe5dbc3a2168"
digest = "1:371e44514be249a0554857dbed1f36f0632a3c95703c2287215eb951ffd27ff7"
name = "github.com/xdg-go/stringprep"
packages = ["."]
pruneopts = ""
revision = "4fcaaf19bc2a8e388ba275a82eb34c29abcd0bc9"
version = "v1.0.2"
[[projects]]
digest = "1:96a6e88dae5c6c3e9540fa4069a7112427de946ed7f6ecec851ecb425a585aeb"
name = "github.com/youmark/pkcs8"
packages = ["."]
pruneopts = ""
revision = "1be2e3e5546da8a58903ff4adcfab015022538ea"
version = "v1.1"
[[projects]]
digest = "1:3770bc03c28f87e5aedc27f3a668f3578d37087187b149641131ca98ae447356"
name = "go.mongodb.org/mongo-driver"
packages = [
"bson",
@@ -298,6 +314,8 @@
"event",
"internal",
"mongo",
"mongo/address",
"mongo/description",
"mongo/options",
"mongo/readconcern",
"mongo/readpref",
@@ -307,14 +325,14 @@
"x/bsonx",
"x/bsonx/bsoncore",
"x/mongo/driver",
"x/mongo/driver/address",
"x/mongo/driver/auth",
"x/mongo/driver/auth/internal/awsv4",
"x/mongo/driver/auth/internal/gssapi",
"x/mongo/driver/connstring",
"x/mongo/driver/description",
"x/mongo/driver/dns",
"x/mongo/driver/mongocrypt",
"x/mongo/driver/mongocrypt/options",
"x/mongo/driver/ocsp",
"x/mongo/driver/operation",
"x/mongo/driver/session",
"x/mongo/driver/topology",
@@ -322,14 +340,15 @@
"x/mongo/driver/wiremessage",
]
pruneopts = ""
revision = "4ce2db174a8ec022f504b9bc0e768e284e44708f"
version = "v1.3.4"
revision = "9e49b5bdd709ca89dad07357876ee04871074f62"
version = "v1.7.1"
[[projects]]
branch = "master"
digest = "1:2f8d339c3b89d5abf9a78aafe1e9fbe548f3b1fb9be5c3117036940904d39527"
name = "golang.org/x/crypto"
packages = [
"ocsp",
"pbkdf2",
"ssh/terminal",
]
@@ -338,23 +357,25 @@
[[projects]]
branch = "master"
digest = "1:adcb9e84ce154ef1d45851b57c40f8a211db3e36373a65b7c4f10c79b7428718"
digest = "1:2f0f30e07781039c6be667da33716cb1b11ca7999a3fac00271cd998618eff29"
name = "golang.org/x/net"
packages = [
"context",
"http/httpguts",
"http2",
"http2/hpack",
"idna",
]
pruneopts = ""
revision = "112230192c580c3556b8cee6403af37a4fc5f28c"
revision = "aaa1db679c0d7765d2b1cb1f92cac8ebf4d94c53"
[[projects]]
branch = "master"
digest = "1:9f6efefb4e401a4f699a295d14518871368eb89403f2dd23ec11dfcd2c0836ba"
name = "golang.org/x/sync"
packages = ["semaphore"]
packages = [
"errgroup",
"semaphore",
]
pruneopts = ""
revision = "112230192c580c3556b8cee6403af37a4fc5f28c"
@@ -371,29 +392,6 @@
pruneopts = ""
revision = "749cb33beabd9aa6d3178e3de05bcc914f70b2bf"
[[projects]]
digest = "1:740b51a55815493a8d0f2b1e0d0ae48fe48953bf7eaf3fcc4198823bf67768c0"
name = "golang.org/x/text"
packages = [
"internal/gen",
"internal/triegen",
"internal/ucd",
"transform",
"unicode/cldr",
"unicode/norm",
]
pruneopts = ""
revision = "342b2e1fbaa52c93f31447ad2c6abc048c63e475"
version = "v0.3.2"
[[projects]]
digest = "1:15d017551627c8bb091bde628215b2861bed128855343fdd570c62d08871f6e1"
name = "gopkg.in/alecthomas/kingpin.v2"
packages = ["."]
pruneopts = ""
revision = "947dcec5ba9c011838740e680966fd7087a71d0d"
version = "v2.2.6"
[[projects]]
digest = "1:fccda34e4c58111b1908d8d69bf8d57c41c8e2542bc18ec8cd38c4fa21057f71"
name = "golang.org/x/text"
@@ -419,6 +417,14 @@
revision = "23ae387dee1f90d29a23c0e87ee0b46038fbed0e"
version = "v0.3.3"
[[projects]]
digest = "1:15d017551627c8bb091bde628215b2861bed128855343fdd570c62d08871f6e1"
name = "gopkg.in/alecthomas/kingpin.v2"
packages = ["."]
pruneopts = ""
revision = "947dcec5ba9c011838740e680966fd7087a71d0d"
version = "v2.2.6"
[[projects]]
digest = "1:75fb3fcfc73a8c723efde7777b40e8e8ff9babf30d8c56160d01beffea8a95a6"
name = "gopkg.in/inf.v0"
@@ -518,9 +524,9 @@
"go.mongodb.org/mongo-driver/bson/primitive",
"go.mongodb.org/mongo-driver/mongo",
"go.mongodb.org/mongo-driver/mongo/options",
"go.mongodb.org/mongo-driver/x/mongo/driver/topology",
"golang.org/x/crypto/ssh/terminal",
"gopkg.in/mgo.v2/bson",
"gopkg.in/mgo.v2/dbtest",
"k8s.io/api/core/v1",
]
solver-name = "gps-cdcl"

View File

@@ -1565,8 +1565,8 @@ $bal = qr/
my $olc_re = qr/(?:--|#)[^'"\r\n]*(?=[\r\n]|\Z)/; # One-line comments
my $mlc_re = qr#/\*[^!].*?\*/#sm; # But not /*!version */
my $vlc_re = qr#/\*.*?[0-9+].*?\*/#sm; # For SHOW + /*!version */
my $vlc_rf = qr#^(SHOW).*?/\*![0-9+].*?\*/#sm; # Variation for SHOW
my $vlc_re = qr#/\*.*?[0-9]+.*?\*/#sm; # For SHOW + /*!version */
my $vlc_rf = qr#^(?:SHOW).*?/\*![0-9]+(.*?)\*/#sm; # Variation for SHOW
sub new {
@@ -1581,7 +1581,8 @@ sub strip_comments {
$query =~ s/$mlc_re//go;
$query =~ s/$olc_re//go;
if ( $query =~ m/$vlc_rf/i ) { # contains show + version
$query =~ s/$vlc_re//go;
my $qualifier = $1 || '';
$query =~ s/$vlc_re/$qualifier/go;
}
return $query;
}
@@ -1652,9 +1653,15 @@ sub fingerprint {
$query =~ s/\Ause \S+\Z/use ?/i # Abstract the DB in USE
&& return $query;
$query =~ s/\\["']//g; # quoted strings
$query =~ s/".*?"/?/sg; # quoted strings
$query =~ s/'.*?'/?/sg; # quoted strings
$query =~ s/([^\\])(\\')/$1/sg;
$query =~ s/([^\\])(\\")/$1/sg;
$query =~ s/\\\\//sg;
$query =~ s/\\'//sg;
$query =~ s/\\"//sg;
$query =~ s/([^\\])(".*?[^\\]?")/$1?/sg;
$query =~ s/([^\\])('.*?[^\\]?')/$1?/sg;
$query =~ s/\bfalse\b|\btrue\b/?/isg; # boolean values
if ( $self->{match_md5_checksums} ) {
$query =~ s/([._-])[a-f0-9]{32}/$1?/g;
@@ -1704,6 +1711,13 @@ sub distill_verbs {
$query =~ m/\A\s*UNLOCK TABLES/i && return "UNLOCK";
$query =~ m/\A\s*xa\s+(\S+)/i && return "XA_$1";
if ( $query =~ m/\A\s*LOAD/i ) {
my ($tbl) = $query =~ m/INTO TABLE\s+(\S+)/i;
$tbl ||= '';
$tbl =~ s/`//g;
return "LOAD DATA $tbl";
}
if ( $query =~ m/\Aadministrator command:/ ) {
$query =~ s/administrator command:/ADMIN/;
$query = uc $query;
@@ -1716,7 +1730,7 @@ sub distill_verbs {
PTDEBUG && _d($query);
$query = uc $query;
$query =~ s/\s+(?:GLOBAL|SESSION|FULL|STORAGE|ENGINE)\b/ /g;
$query =~ s/\s+(?:SESSION|FULL|STORAGE|ENGINE)\b/ /g;
$query =~ s/\s+COUNT[^)]+\)//g;
$query =~ s/\s+(?:FOR|FROM|LIKE|WHERE|LIMIT|IN)\b.+//ms;
@@ -1731,6 +1745,7 @@ sub distill_verbs {
eval $QueryParser::tbl_ident;
my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
if ( $dds) {
$query =~ s/\s+IF(?:\s+NOT)?\s+EXISTS/ /i;
my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;
$obj = uc $obj if $obj;
PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);
@@ -1797,6 +1812,9 @@ sub distill {
map { $verbs =~ s/$_/$alias_for{$_}/ } keys %alias_for;
$query = $verbs;
}
elsif ( $verbs && $verbs =~ m/^LOAD DATA/ ) {
return $verbs;
}
else {
my @tables = $self->__distill_tables($query, $table, %args);
$query = join(q{ }, $verbs, @tables);

View File

@@ -2520,9 +2520,13 @@ sub fingerprint {
$query =~ s/\Ause \S+\Z/use ?/i # Abstract the DB in USE
&& return $query;
$query =~ s/\\["']//g; # quoted strings
$query =~ s/".*?"/?/sg; # quoted strings
$query =~ s/'.*?'/?/sg; # quoted strings
$query =~ s/([^\\])(\\')/$1/sg;
$query =~ s/([^\\])(\\")/$1/sg;
$query =~ s/\\\\//sg;
$query =~ s/\\'//sg;
$query =~ s/\\"//sg;
$query =~ s/([^\\])(".*?[^\\]?")/$1?/sg;
$query =~ s/([^\\])('.*?[^\\]?')/$1?/sg;
$query =~ s/\bfalse\b|\btrue\b/?/isg; # boolean values

View File

@@ -4911,9 +4911,13 @@ sub fingerprint {
$query =~ s/\Ause \S+\Z/use ?/i # Abstract the DB in USE
&& return $query;
$query =~ s/\\["']//g; # quoted strings
$query =~ s/".*?"/?/sg; # quoted strings
$query =~ s/'.*?'/?/sg; # quoted strings
$query =~ s/([^\\])(\\')/$1/sg;
$query =~ s/([^\\])(\\")/$1/sg;
$query =~ s/\\\\//sg;
$query =~ s/\\'//sg;
$query =~ s/\\"//sg;
$query =~ s/([^\\])(".*?[^\\]?")/$1?/sg;
$query =~ s/([^\\])('.*?[^\\]?')/$1?/sg;
$query =~ s/\bfalse\b|\btrue\b/?/isg; # boolean values

View File

@@ -2945,9 +2945,13 @@ sub fingerprint {
$query =~ s/\Ause \S+\Z/use ?/i # Abstract the DB in USE
&& return $query;
$query =~ s/\\["']//g; # quoted strings
$query =~ s/".*?"/?/sg; # quoted strings
$query =~ s/'.*?'/?/sg; # quoted strings
$query =~ s/([^\\])(\\')/$1/sg;
$query =~ s/([^\\])(\\")/$1/sg;
$query =~ s/\\\\//sg;
$query =~ s/\\'//sg;
$query =~ s/\\"//sg;
$query =~ s/([^\\])(".*?[^\\]?")/$1?/sg;
$query =~ s/([^\\])('.*?[^\\]?')/$1?/sg;
$query =~ s/\bfalse\b|\btrue\b/?/isg; # boolean values

View File

@@ -2946,9 +2946,13 @@ sub fingerprint {
$query =~ s/\Ause \S+\Z/use ?/i # Abstract the DB in USE
&& return $query;
$query =~ s/\\["']//g; # quoted strings
$query =~ s/".*?"/?/sg; # quoted strings
$query =~ s/'.*?'/?/sg; # quoted strings
$query =~ s/([^\\])(\\')/$1/sg;
$query =~ s/([^\\])(\\")/$1/sg;
$query =~ s/\\\\//sg;
$query =~ s/\\'//sg;
$query =~ s/\\"//sg;
$query =~ s/([^\\])(".*?[^\\]?")/$1?/sg;
$query =~ s/([^\\])('.*?[^\\]?')/$1?/sg;
$query =~ s/\bfalse\b|\btrue\b/?/isg; # boolean values

View File

@@ -4818,9 +4818,13 @@ sub fingerprint {
$query =~ s/\Ause \S+\Z/use ?/i # Abstract the DB in USE
&& return $query;
$query =~ s/\\["']//g; # quoted strings
$query =~ s/".*?"/?/sg; # quoted strings
$query =~ s/'.*?'/?/sg; # quoted strings
$query =~ s/([^\\])(\\')/$1/sg;
$query =~ s/([^\\])(\\")/$1/sg;
$query =~ s/\\\\//sg;
$query =~ s/\\'//sg;
$query =~ s/\\"//sg;
$query =~ s/([^\\])(".*?[^\\]?")/$1?/sg;
$query =~ s/([^\\])('.*?[^\\]?')/$1?/sg;
$query =~ s/\bfalse\b|\btrue\b/?/isg; # boolean values

View File

@@ -4,21 +4,6 @@
Installing Percona Toolkit
==========================
Percona provides packages for most popular 64-bit Linux distributions:
* Debian 7 ("wheezy")
* Debian 8 ("jessie")
* Ubuntu 14.04 LTS (Trusty Tahr)
* Ubuntu 16.04 LTS (Xenial Xerus)
* Ubuntu 16.10 (Yakkety Yak)
* Ubuntu 17.04 (Zesty Zapus)
* Red Hat Enterprise Linux or CentOS 6 (Santiago)
* Red Hat Enterprise Linux or CentOS 7 (Maipo)
.. note:: Percona Toolkit should work on other DEB-based and RPM-based systems
(for example, Oracle Linux and Amazon Linux AMI),
but it is tested only on those listed above.
It is recommended to install Percona software from official repositories:
1. Configure Percona repositories as described in
@@ -36,8 +21,8 @@ It is recommended to install Percona software from official repositories:
sudo yum install percona-toolkit
.. rubric:: Generating an instance UUID for statistics
During the installating process, the percona-toolkit installer records a unique
During the installation process, the percona-toolkit installer records a unique
identifier specific to the given percona-toolkit instance. This ID is a the
product UUID stored in |product-uuid|. The installer copies the product_uuid to
|toolkit-uuid|.
@@ -48,7 +33,7 @@ percona-toolkit. Note that no other information is gathered for this purpose.
In cases when the installer is not able to read the contents of
|product-uuid|, a random UUID is generated. A random UUID is
also generated if percona-toolkit is run from the binary in the *tar.gz* file.
Alternative Install Methods
===========================

34
go.mod
View File

@@ -1,34 +0,0 @@
module github.com/percona/percona-toolkit
go 1.14
require (
github.com/Masterminds/semver v1.4.2
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/alecthomas/kingpin v2.2.6+incompatible
github.com/go-ini/ini v1.46.0
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129
github.com/golang/snappy v0.0.2-0.20190904063534-ff6b7dc882cf // indirect
github.com/google/uuid v1.1.2
github.com/hashicorp/go-version v1.2.1-0.20190424083514-192140e6f3e6
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c
github.com/klauspost/compress v1.10.10 // indirect
github.com/lib/pq v1.2.0
github.com/mattn/go-shellwords v1.0.6
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe
github.com/pborman/getopt v0.0.0-20190409184431-ee0cd42419d3
github.com/percona/go-mysql v0.0.0-20190903141930-197f4ad8db8d
github.com/pkg/errors v0.9.1
github.com/prometheus/common v0.13.0
github.com/shirou/gopsutil v2.20.8+incompatible
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.6.1
go.mongodb.org/mongo-driver v1.5.1
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect
gopkg.in/ini.v1 v1.61.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
k8s.io/api v0.20.1
)

View File

@@ -173,9 +173,17 @@ sub fingerprint {
$query =~ s/\Ause \S+\Z/use ?/i # Abstract the DB in USE
&& return $query;
$query =~ s/\\["']//g; # quoted strings
$query =~ s/".*?"/?/sg; # quoted strings
$query =~ s/'.*?'/?/sg; # quoted strings
# -----------------------------------------------------------
# Remove quoted strings
# -----------------------------------------------------------
$query =~ s/([^\\])(\\')/$1/sg;
$query =~ s/([^\\])(\\")/$1/sg;
$query =~ s/\\\\//sg;
$query =~ s/\\'//sg;
$query =~ s/\\"//sg;
$query =~ s/([^\\])(".*?[^\\]?")/$1?/sg;
$query =~ s/([^\\])('.*?[^\\]?')/$1?/sg;
# -----------------------------------------------------------
$query =~ s/\bfalse\b|\btrue\b/?/isg; # boolean values
@@ -218,8 +226,8 @@ sub fingerprint {
$query =~ s/\blimit \?(?:, ?\?| offset \?)?/limit ?/; # LIMIT
# The following are disabled because of speed issues. Should we try to
# normalize whitespace between and around operators? My gut feeling is no.
# $query =~ s/ , | ,|, /,/g; # Normalize commas
# $query =~ s/ = | =|= /=/g; # Normalize equals
# $query =~ s/ , | ,|, /,/g; # Normalize commas
# $query =~ s/ = | =|= /=/g; # Normalize equals
# $query =~ s# [,=+*/-] ?|[,=+*/-] #+#g; # Normalize operators
# Remove ASC keywords from ORDER BY clause so these queries fingerprint

View File

@@ -14,6 +14,7 @@ import (
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/x/mongo/driver/topology"
"gopkg.in/mgo.v2/bson"
)
@@ -27,6 +28,7 @@ const (
shardingNotEnabledErrorCode = 203
ErrNotYetInitialized = int32(94)
ErrNoReplicationEnabled = int32(76)
ErrNotPrimaryOrSecondary = int32(13436)
)
var (
@@ -460,7 +462,9 @@ func ClusterID(ctx context.Context, client *mongo.Client) (string, error) {
if e, ok := err.(mongo.CommandError); ok && IsReplicationNotEnabledError(e) {
return "", nil
}
if _, ok := err.(topology.ServerSelectionError); ok {
return "", nil
}
return "", err
}
@@ -468,12 +472,18 @@ func ClusterID(ctx context.Context, client *mongo.Client) (string, error) {
}
func IsReplicationNotEnabledError(err mongo.CommandError) bool {
return err.Code == ErrNotYetInitialized || err.Code == ErrNoReplicationEnabled
return err.Code == ErrNotYetInitialized || err.Code == ErrNoReplicationEnabled ||
err.Code == ErrNotPrimaryOrSecondary
}
func MyState(ctx context.Context, client *mongo.Client) (int, error) {
var ms proto.MyState
if err := client.Database("admin").RunCommand(ctx, bson.M{"getDiagnosticData": 1}).Decode(&ms); err != nil {
err := client.Database("admin").RunCommand(ctx, bson.M{"getDiagnosticData": 1}).Decode(&ms)
if _, ok := err.(topology.ServerSelectionError); ok {
return 0, nil
}
if err != nil {
return 0, err
}

View File

@@ -162,7 +162,7 @@ is(
# This is a known deficiency, fixes seem to be expensive though.
is(
$qr->fingerprint("select '\\\\' from foo"),
"select '\\ from foo",
"select ? from foo",
"Does not handle all quoted strings",
);
@@ -1478,6 +1478,19 @@ is(
"Fingerprint db.tbl<number>name (preserve number)"
);
is(
$qr->fingerprint(
"SELECT i FROM d.t WHERE i=\"3\""
),
"select i from d.t where i=?",
"Fingerprint db.tbl<number>name (preserve number)"
);
is(
$qr->fingerprint("CALL foo(1, 2, 3)"),
"call foo",
'Fingerprints stored procedure calls specially',
);
# #############################################################################
# Done.
# #############################################################################

View File

@@ -259,7 +259,7 @@ SELECT `SCHEMA_NAME` FROM `INFORMATION_SCHEMA`.`SCHEMATA`, (SELECT DB_first_leve
# EXPLAIN /*!50100 PARTITIONS*/
SELECT USER()\G
# Query 12: 0 QPS, 0x concurrency, ID 0x75A885FE43F31908754B91A2F3BD1E20 at byte 1082
# Query 12: 0 QPS, 0x concurrency, ID 0x15BF4DCE0B364CE831C14D6853A472B7 at byte 1082
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2016-06-07T19:07:02.565999Z
@@ -303,4 +303,4 @@ SELECT 1 FROM (SELECT `GRANTEE`, `IS_GRANTABLE` FROM `INFORMATION_SCHEMA`.`COLUM
# 9 0xDDABDE67AC3044CAED549F59FFFA541B 0.0000 0.0% 1 0.0000 0.00 SELECT phpmyadmin.pma__navigationhiding
# 10 0x35CCC630581DCD5AA46100310F18DEB9 0.0000 0.0% 1 0.0000 0.00 SELECT INFORMATION_SCHEMA.SCHEMATA
# 11 0x7B48FAA9C951DD8A389FF9DA2DF3DF62 0.0000 0.0% 1 0.0000 0.00 SELECT
# 12 0x75A885FE43F31908754B91A2F3BD1E20 0.0000 0.0% 1 0.0000 0.00 SELECT UNION INFORMATION_SCHEMA.COLUMN_PRIVILEGES INFORMATION_SCHEMA.TABLE_PRIVILEGES INFORMATION_SCHEMA.SCHEMA_PRIVILEGES INFORMATION_SCHEMA.USER_PRIVILEGES
# 12 0x15BF4DCE0B364CE831C14D6853A472B7 0.0000 0.0% 1 0.0000 0.00 SELECT UNION INFORMATION_SCHEMA.COLUMN_PRIVILEGES INFORMATION_SCHEMA.TABLE_PRIVILEGES INFORMATION_SCHEMA.SCHEMA_PRIVILEGES INFORMATION_SCHEMA.USER_PRIVILEGES

View File

@@ -1 +1 @@
# Exec time 100 10s 1s 3s 2s 3s 896ms 2s
# Exec time 100 9s 2s 4s 3s 4s 786ms 3s