go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/sqlannotation Index | Files

package sqlannotation

import "gopkg.in/src-d/go-vitess.v1/vt/sqlannotation"

Package sqlannotation provides functions for annotating DML statements with keyspace-id comments and parsing them. These annotations are used during filtered-replication to route the DML statement to the correct shard. TOOD(erez): Move the code for the "_stream" annotations from vttablet to here.


Package Files



const (
    ExtractKeySpaceIDParseError                 = iota
    ExtractKeySpaceIDReplicationUnfriendlyError = iota

Possible values for ExtractKeySpaceIDError.Kind

func AddKeyspaceIDs Uses

func AddKeyspaceIDs(sql string, keyspaceIDs [][]byte, marginComments string) string

AddKeyspaceIDs returns a copy of 'sql' annotated with the given keyspace id. It also appends the additional marginComments, if any.

func AnnotateIfDML Uses

func AnnotateIfDML(sql string, keyspaceIDs [][]byte) string

AnnotateIfDML annotates 'sql' based on 'keyspaceIDs'

If 'sql' is not a DML statement no annotation is added. If 'sql' is a DML statement and contains exactly one keyspaceID

it is used to annotate 'sql'

Otherwise 'sql' is annotated as replication-unfriendly.

func ExtractKeyspaceIDS Uses

func ExtractKeyspaceIDS(sql string) (keyspaceIDs [][]byte, err error)

ExtractKeyspaceIDS parses the annotation of the given statement and tries to extract the keyspace id. If a keyspace-id comment exists 'keyspaceID' is set to the parsed keyspace id and err is set to nil; otherwise, if a filtered-replication-unfriendly comment exists or some other parsing error occured, keyspaceID is set to nil and err is set to a non-nil error value.

type ExtractKeySpaceIDError Uses

type ExtractKeySpaceIDError struct {
    Kind    int
    Message string

ExtractKeySpaceIDError is the error type returned from ExtractKeySpaceID Kind is a numeric code for the error (see constants below) and Message is an error message string.

func (ExtractKeySpaceIDError) Error Uses

func (err ExtractKeySpaceIDError) Error() string

Package sqlannotation imports 7 packages (graph) and is imported by 6 packages. Updated 2019-06-13. Refresh now. Tools for package owners.