-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PMM-10385 API. * PMM-10385 Gen. * Revert "Bump github.com/ClickHouse/clickhouse-go/v2 from 2.2.0 to 2.3.0 (#1176)" This reverts commit f2e63af. * PMM-10385 Gen. * PMM-10385 Gen. * PMM-10385 Gen. * PMM-10385 Gen. * PMM-10385 Gen. * PMM-10385 Gen. * PMM-10385 Gen and changes. * PMM-10385 Changes. * PMM-10385 Gen. * PMM-10385 Gen. * PMM-10385 Gen. * PMM-10385 Changes. * PMM-10385 Changes. * PMM-10385 Gen. * PMM-10385 Changes. * PMM-10385 Changes. * PMM-10385 Gen. * PMM-10385 Gen. * PMM-10385 Mod. * PMM-10385 Mod. * PMM-10385 Mod. * PMM-10385 Tidy. * PMM-10385 Changes. * PMM-10385 Gen. * PMM-10385 Gen. * PMM-10385 Add new fields. * PMM-10385 Add license. * PMM-10385 Fix tests. * PMM-10385 Move package. * PMM-10385 Typo. * PMM-10385 Lint. * PMM-10385 Fix another test. * PMM-10385 Fix agent tests. * PMM-10385 Fix test. * PMM-10385 Fix. * PMM-10385 Add debug logging when cannot parse query. * PMM-10385 Merge QAN PR. * PMM-10385 Sync object details test. * PMM-10385 Sync reporter. * PMM-10385 Sync metrics. * PMM-10385 Sync slowlog. * PMM-10385 Sync slowlog. * Revert "PMM-10385 Sync slowlog." This reverts commit 3c92520. * PMM-10385 Format. * PMM-10385 Mod. * PMM-10385 Fix. * PMM-10385 Fix. * PMM-10385 Mod. * PMM-10385 Lint. * PMM-10385 Lint. * PMM-10385 Fix. * PMM-10385 Workaround for defect. * PMM-10385 Fix.
- Loading branch information
1 parent
f6a6ad3
commit 404aa71
Showing
45 changed files
with
3,097 additions
and
1,375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2019 Percona LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package queryparser | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
"vitess.io/vitess/go/vt/proto/query" | ||
"vitess.io/vitess/go/vt/sqlparser" | ||
) | ||
|
||
// MySQL parse query and return fingeprint and placeholders. | ||
func MySQL(q string) (string, uint32, error) { | ||
normalizedQuery, _, err := sqlparser.Parse2(q) | ||
if err != nil { | ||
return "", 0, errors.Wrap(err, "cannot parse query") | ||
} | ||
|
||
bv := make(map[string]*query.BindVariable) | ||
err = sqlparser.Normalize(normalizedQuery, sqlparser.NewReservedVars("", sqlparser.GetBindvars(normalizedQuery)), bv) | ||
if err != nil { | ||
return "", 0, errors.Wrap(err, "cannot normalize query") | ||
} | ||
|
||
parsedQuery := sqlparser.NewParsedQuery(normalizedQuery) | ||
bindVars := sqlparser.GetBindvars(normalizedQuery) | ||
|
||
return parsedQuery.Query, uint32(len(bindVars)), nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.