Skip to content

go-mysql/query

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

Transform MySQL Queries

Go Report Card Build Status GoDoc

This package provides functions for transforming MySQL queries. Most important is query.Fingerprint:

package main

import (
    "fmt"
    "github.com/go-mysql/query"
)

func main() {
    f := query.Fingerprint(
        "SELECT c FROM t WHERE id IN (1,2,3) AND ts < '2017-01-01 00:00:00'",
    )
    fmt.Println(f)
}

Output: select c from t where id in(?+) and ts < ?

That fingerprint can be transformed into a unique ID:

id := query.Id(f) // return "EA2376FD2AFF00BA"

Fingerprints and IDs are used to parse and aggregate queries from the MySQL slow log.

Acknowledgement

This code was originally copied from percona/go-mysql @ 2a6037d7d809b18ebd6d735b397f2321879af611. See that project for original contributors and copyright.

This project is a fork to continue development of percona/go-mysql as separate packages. GitHub only allows forking a project once, which is why the code has been copied.

About

Query transformations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages