Documentation ¶
Index ¶
- Constants
- Variables
- func NewListener(listenerCfg mysql.ListenerConfig) (server.ProtocolListener, error)
- func NewListenerWithOpts(listenerCfg mysql.ListenerConfig, opts ...ListenerOpt) (server.ProtocolListener, error)
- func RunInMemory(cfg *servercfg.DoltgresConfig) (*svcs.Controller, error)
- func RunOnDisk(ctx context.Context, cfg *servercfg.DoltgresConfig, dEnv *env.DoltEnv) (*svcs.Controller, error)
- func VitessTypeToObjectID(typ query.Type) (uint32, error)
- type ConnectionHandler
- type ConvertedQuery
- type DoltgresHandler
- func (h *DoltgresHandler) ComBind(ctx context.Context, c *mysql.Conn, query string, ...) (mysql.BoundQuery, []pgproto3.FieldDescription, error)
- func (h *DoltgresHandler) ComExecuteBound(ctx context.Context, conn *mysql.Conn, query string, ...) error
- func (h *DoltgresHandler) ComPrepareParsed(ctx context.Context, c *mysql.Conn, query string, parsed sqlparser.Statement) (mysql.ParsedQuery, []pgproto3.FieldDescription, error)
- func (h *DoltgresHandler) ComQuery(ctx context.Context, c *mysql.Conn, query string, parsed sqlparser.Statement, ...) error
- func (h *DoltgresHandler) ComResetConnection(c *mysql.Conn) error
- func (h *DoltgresHandler) ConnectionClosed(c *mysql.Conn)
- func (h *DoltgresHandler) NewConnection(c *mysql.Conn)
- func (h *DoltgresHandler) NewContext(ctx context.Context, c *mysql.Conn, query string) (*sql.Context, error)
- type ErrorResponseSeverity
- type Handler
- type Listener
- type ListenerOpt
- type PortalData
- type PreparedStatementData
- type QueryExecutor
- type ReadyForQueryTransactionIndicator
- type Result
- type Row
- type SASLBindingFlag
- type SASLContinue
- type SASLInitial
- type SASLResponse
Constants ¶
const ( SASLMechanism_SCRAM_SHA_256 = "SCRAM-SHA-256" SASLMechanism_SCRAM_SHA_256_PLUS = "SCRAM-SHA-256-PLUS" )
These are mechanisms that are used for SASL authentication.
const ( Version = "0.12.0" DefUserName = "postres" DefUserEmail = "postgres@somewhere.com" DoltgresDir = "doltgres" )
Variables ¶
var HandlePanics = true
HandlePanics determines whether panics should be handled in the connection handler. See |disablePanicHandlingEnvVar|.
var OidToDoltgresType = map[uint32]pgtypes.DoltgresType{}/* 167 elements not displayed */
OidToDoltgresType is map of oid to Doltgres type.
Functions ¶
func NewListener ¶
func NewListener(listenerCfg mysql.ListenerConfig) (server.ProtocolListener, error)
NewListener creates a new Listener.
func NewListenerWithOpts ¶ added in v0.5.0
func NewListenerWithOpts(listenerCfg mysql.ListenerConfig, opts ...ListenerOpt) (server.ProtocolListener, error)
func RunInMemory ¶
func RunInMemory(cfg *servercfg.DoltgresConfig) (*svcs.Controller, error)
RunInMemory starts the server based on the given args, while also using RAM as the backing store. The returned WaitGroup may be used to wait for the server to close.
func RunOnDisk ¶
func RunOnDisk(ctx context.Context, cfg *servercfg.DoltgresConfig, dEnv *env.DoltEnv) (*svcs.Controller, error)
RunOnDisk starts the server based on the given args, while also using the local disk as the backing store. The returned WaitGroup may be used to wait for the server to close.
Types ¶
type ConnectionHandler ¶ added in v0.4.0
type ConnectionHandler struct {
// contains filtered or unexported fields
}
ConnectionHandler is responsible for the entire lifecycle of a user connection: receiving messages they send, executing queries, sending the correct messages in return, and terminating the connection when appropriate.
func NewConnectionHandler ¶ added in v0.4.0
func NewConnectionHandler(conn net.Conn, handler mysql.Handler) *ConnectionHandler
NewConnectionHandler returns a new ConnectionHandler for the connection provided
func (*ConnectionHandler) Conn ¶ added in v0.4.0
func (h *ConnectionHandler) Conn() net.Conn
Conn returns the underlying net.Conn for this connection.
func (*ConnectionHandler) HandleConnection ¶ added in v0.4.0
func (h *ConnectionHandler) HandleConnection()
HandleConnection handles a connection's session, reading messages, executing queries, and sending responses. Expected to run in a goroutine per connection.
type ConvertedQuery ¶ added in v0.2.0
ConvertedQuery represents a query that has been converted from the Postgres representation to the Vitess representation. String may contain the string version of the converted query. AST will contain the tree version of the converted query, and is the recommended form to use. If AST is nil, then use the String version, otherwise always prefer to AST.
type DoltgresHandler ¶ added in v0.12.0
type DoltgresHandler struct {
// contains filtered or unexported fields
}
DoltgresHandler is a handler uses SQLe engine directly running Doltgres specific queries.
func (*DoltgresHandler) ComBind ¶ added in v0.12.0
func (h *DoltgresHandler) ComBind(ctx context.Context, c *mysql.Conn, query string, parsedQuery mysql.ParsedQuery, bindVars map[string]sqlparser.Expr) (mysql.BoundQuery, []pgproto3.FieldDescription, error)
ComBind implements the Handler interface.
func (*DoltgresHandler) ComExecuteBound ¶ added in v0.12.0
func (h *DoltgresHandler) ComExecuteBound(ctx context.Context, conn *mysql.Conn, query string, boundQuery mysql.BoundQuery, callback func(*Result) error) error
ComExecuteBound implements the Handler interface.
func (*DoltgresHandler) ComPrepareParsed ¶ added in v0.12.0
func (h *DoltgresHandler) ComPrepareParsed(ctx context.Context, c *mysql.Conn, query string, parsed sqlparser.Statement) (mysql.ParsedQuery, []pgproto3.FieldDescription, error)
ComPrepareParsed implements the Handler interface.
func (*DoltgresHandler) ComQuery ¶ added in v0.12.0
func (h *DoltgresHandler) ComQuery(ctx context.Context, c *mysql.Conn, query string, parsed sqlparser.Statement, callback func(*Result) error) error
ComQuery implements the Handler interface.
func (*DoltgresHandler) ComResetConnection ¶ added in v0.12.0
func (h *DoltgresHandler) ComResetConnection(c *mysql.Conn) error
ComResetConnection implements the Handler interface.
func (*DoltgresHandler) ConnectionClosed ¶ added in v0.12.0
func (h *DoltgresHandler) ConnectionClosed(c *mysql.Conn)
ConnectionClosed implements the Handler interface.
func (*DoltgresHandler) NewConnection ¶ added in v0.12.0
func (h *DoltgresHandler) NewConnection(c *mysql.Conn)
NewConnection implements the Handler interface.
type ErrorResponseSeverity ¶ added in v0.12.0
type ErrorResponseSeverity string
ErrorResponseSeverity represents the severity of an ErrorResponse message.
const ( ErrorResponseSeverity_Error ErrorResponseSeverity = "ERROR" ErrorResponseSeverity_Fatal ErrorResponseSeverity = "FATAL" ErrorResponseSeverity_Panic ErrorResponseSeverity = "PANIC" ErrorResponseSeverity_Warning ErrorResponseSeverity = "WARNING" ErrorResponseSeverity_Notice ErrorResponseSeverity = "NOTICE" ErrorResponseSeverity_Debug ErrorResponseSeverity = "DEBUG" ErrorResponseSeverity_Info ErrorResponseSeverity = "INFO" ErrorResponseSeverity_Log ErrorResponseSeverity = "LOG" )
type Handler ¶ added in v0.12.0
type Handler interface { // ComBind is called when a connection receives a request to bind a prepared statement to a set of values. ComBind(ctx context.Context, c *mysql.Conn, query string, parsedQuery mysql.ParsedQuery, bindVars map[string]sqlparser.Expr) (mysql.BoundQuery, []pgproto3.FieldDescription, error) // ComExecuteBound is called when a connection receives a request to execute a prepared statement that has already bound to a set of values. ComExecuteBound(ctx context.Context, conn *mysql.Conn, query string, boundQuery mysql.BoundQuery, callback func(*Result) error) error // ComPrepareParsed is called when a connection receives a prepared statement query that has already been parsed. ComPrepareParsed(ctx context.Context, c *mysql.Conn, query string, parsed sqlparser.Statement) (mysql.ParsedQuery, []pgproto3.FieldDescription, error) // ComQuery is called when a connection receives a query. Note the contents of the query slice may change // after the first call to callback. So the DoltgresHandler should not hang on to the byte slice. ComQuery(ctx context.Context, c *mysql.Conn, query string, parsed sqlparser.Statement, callback func(*Result) error) error // ComResetConnection resets the connection's session, clearing out any cached prepared statements, locks, user and // session variables. The currently selected database is preserved. ComResetConnection(c *mysql.Conn) error // ConnectionClosed reports that a connection has been closed. ConnectionClosed(c *mysql.Conn) // NewConnection reports that a new connection has been established. NewConnection(c *mysql.Conn) // NewContext creates a new sql.Context instance for the connection |c|. The // optional |query| can be specified to populate the sql.Context's query field. NewContext(ctx context.Context, c *mysql.Conn, query string) (*sql.Context, error) }
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener listens for connections to process PostgreSQL requests into Dolt requests.
type ListenerOpt ¶ added in v0.5.0
type ListenerOpt func(*Listener)
func WithCertificate ¶ added in v0.5.0
func WithCertificate(cert tls.Certificate) ListenerOpt
type PortalData ¶ added in v0.4.0
type PortalData struct { Query ConvertedQuery IsEmptyQuery bool Fields []pgproto3.FieldDescription BoundPlan sql.Node }
type PreparedStatementData ¶ added in v0.4.0
type PreparedStatementData struct { Query ConvertedQuery ReturnFields []pgproto3.FieldDescription BindVarTypes []uint32 }
type QueryExecutor ¶ added in v0.12.0
type QueryExecutor func(ctx *sql.Context, query string, parsed sqlparser.Statement, analyzed sql.Node) (sql.Schema, sql.RowIter, *sql.QueryFlags, error)
QueryExecutor is a function that executes a query and returns the result as a schema and iterator. Either of |parsed| or |analyzed| can be nil depending on the use case
type ReadyForQueryTransactionIndicator ¶ added in v0.12.0
type ReadyForQueryTransactionIndicator byte
ReadyForQueryTransactionIndicator indicates the state of the transaction related to the query.
const ( ReadyForQueryTransactionIndicator_Idle ReadyForQueryTransactionIndicator = 'I' ReadyForQueryTransactionIndicator_TransactionBlock ReadyForQueryTransactionIndicator = 'T' ReadyForQueryTransactionIndicator_FailedTransactionBlock ReadyForQueryTransactionIndicator = 'E' )
type Result ¶ added in v0.12.0
type Result struct { Fields []pgproto3.FieldDescription `json:"fields"` Rows []Row `json:"rows"` RowsAffected uint64 `json:"rows_affected"` }
Result represents a query result.
type Row ¶ added in v0.12.0
type Row struct {
// contains filtered or unexported fields
}
Row represents a single row value in bytes format. |val| represents array of a single row elements, which each element value is in byte array format.
type SASLBindingFlag ¶ added in v0.12.0
type SASLBindingFlag string
SASLBindingFlag are the flags for gs2-cbind-flag, used in SASL authentication.
const ( SASLBindingFlag_NoClientSupport SASLBindingFlag = "n" SASLBindingFlag_AssumedNoServerSupport SASLBindingFlag = "y" SASLBindingFlag_Used SASLBindingFlag = "p" )
type SASLContinue ¶ added in v0.12.0
SASLContinue is the structured form of the output for *pgproto3.SASLInitialResponse.
func (SASLContinue) Encode ¶ added in v0.12.0
func (sc SASLContinue) Encode() *pgproto3.AuthenticationSASLContinue
Encode returns the struct as an AuthenticationSASLContinue message.
type SASLInitial ¶ added in v0.12.0
type SASLInitial struct { Flag SASLBindingFlag BindName string // Only set when Flag is SASLBindingFlag_Used Binding string // Base64 encoding of cbind-input Authzid string // Authorization ID, currently ignored in favor of the startup message's username Username string // Prepared using SASLprep, currently ignored in favor of the startup message's username Nonce string RawData []byte // The bytes that were received in the message }
SASLInitial is the structured form of the input given by *pgproto3.SASLInitialResponse.
func (SASLInitial) Base64Header ¶ added in v0.12.0
func (si SASLInitial) Base64Header() string
Base64Header returns the base64-encoded GS2 header and channel binding data.