my2any

package
v0.0.0-...-75657e5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

README

my2any

A MySQL to PostgreSQL/Insert-Any-Other-RDBMS Gateway. The Goal is to allow (almost) any MySQL client Software (like PHP application) to use PostgreSQL (or other RDBMSes), without intrusive modifications, such as switching from the mysql or mysqli PHP-library to the PostgreSQL client library.

What this software does.

The software serves the MySQL wire protocol using the excelent go-vitess framework (well, vitess is a product and not a library, but who cares) and go-mysql-server.

The SQL statements are parsed with the vitess-parser and then translated from the MySQL dialect into the PostgreSQL dialect (other dialects can be implemented as plugins).

Documentation

Index

Constants

View Source
const (
	StmtxInsertReturning = 128 + iota
)

Variables

This section is empty.

Functions

func Qualify

func Qualify(stmt sqlparser.Statement, schema string) error

Types

type ClientData

type ClientData struct {
	Tx *sql.Tx
}

func (*ClientData) Destroy

func (c *ClientData) Destroy()

type Converter

type Converter interface {
	Convert(nct *sql.ColumnType) (col *sqlv.Column, scan interface{})
}
var DefaultConverter Converter = DefaultConverterClass{}

type DefaultConverterClass

type DefaultConverterClass struct{}

func (DefaultConverterClass) Convert

func (DefaultConverterClass) Convert(nct *sql.ColumnType) (col *sqlv.Column, scan interface{})

type DefaultSpecialFeaturesClass

type DefaultSpecialFeaturesClass struct{}

func (DefaultSpecialFeaturesClass) Perform

func (DefaultSpecialFeaturesClass) Perform(db GenericDB, cmd string, args ...string) (*sql.Rows, error)

func (DefaultSpecialFeaturesClass) Rewrite

type DefaultSyntaxerClass

type DefaultSyntaxerClass struct{}

func (DefaultSyntaxerClass) EncodeAny

func (DefaultSyntaxerClass) EncodeInsert

func (DefaultSyntaxerClass) EncodeInsert(ast sqlparser.Statement) string

func (DefaultSyntaxerClass) Preprocess

func (DefaultSyntaxerClass) Preprocess(ast sqlparser.Statement, schema string)

type Gateway

type Gateway struct {
	DB  *sql.DB
	CC  Converter
	Syn Syntaxer
	SF  SpecialFeatures
}

func (*Gateway) ComQuery

func (g *Gateway) ComQuery(c *mysql.Conn, query string, callback func(*sqltypes.Result) error) error

func (*Gateway) ConnectionClosed

func (g *Gateway) ConnectionClosed(c *mysql.Conn)

func (*Gateway) NewConnection

func (g *Gateway) NewConnection(c *mysql.Conn)

type GenericDB

type GenericDB interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

Generic common subset of *sql.DB and *sql.Tx

type SpecialFeatures

type SpecialFeatures interface {
	Perform(db GenericDB, cmd string, args ...string) (*sql.Rows, error)
	Rewrite(db GenericDB, ast sqlparser.Statement, pvp *int) (string, bool)
}
var DefaultSpecialFeatures SpecialFeatures = DefaultSpecialFeaturesClass{}

type Syntaxer

type Syntaxer interface {
	Preprocess(ast sqlparser.Statement, schema string)
	/* This method is used if no other case matches. */
	EncodeAny(ast sqlparser.Statement) string
}
var DefaultSyntaxer Syntaxer = DefaultSyntaxerClass{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL