Documentation ¶
Overview ¶
Example ¶
package main import ( "context" "fmt" "io" sqle "github.com/dolthub/go-mysql-server" "github.com/dolthub/go-mysql-server/memory" "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/types" ) func main() { // Create a test memory database and register it to the default engine. pro := createTestDatabase() e := sqle.NewDefault(pro) session := memory.NewSession(sql.NewBaseSession(), pro) ctx := sql.NewContext(context.Background(), sql.WithSession(session)) ctx.SetCurrentDatabase("mydb") _, r, _, err := e.Query(ctx, `SELECT name, count(*) FROM mytable WHERE name = 'John Doe' GROUP BY name`) checkIfError(err) // Iterate results and print them. for { row, err := r.Next(ctx) if err == io.EOF { break } checkIfError(err) name := row[0] count := row[1] fmt.Println(name, count) } } func checkIfError(err error) { if err != nil { panic(err) } } func createTestDatabase() *memory.DbProvider { db := memory.NewDatabase("mydb") pro := memory.NewDBProvider(db) session := memory.NewSession(sql.NewBaseSession(), pro) ctx := sql.NewContext(context.Background(), sql.WithSession(session)) table := memory.NewTable(db.BaseDatabase, "mytable", sql.NewPrimaryKeySchema(sql.Schema{ {Name: "name", Type: types.Text, Source: "mytable"}, {Name: "email", Type: types.Text, Source: "mytable"}, }), db.GetForeignKeyCollection()) db.AddTable("mytable", table) rows := []sql.Row{ sql.NewRow("John Doe", "john@doe.com"), sql.NewRow("John Doe", "johnalt@doe.com"), sql.NewRow("Jane Doe", "jane@doe.com"), sql.NewRow("Evil Bob", "evilbob@gmail.com"), } for _, row := range rows { table.Insert(ctx, row) } return pro }
Output: John Doe 2
Index ¶
- Variables
- func AddColumn(t *testing.T, ctx *sql.Context, table sql.AlterableTable, column *sql.Column)
- func AssertErr(t *testing.T, e QueryEngine, harness Harness, query string, ...)
- func AssertErrPrepared(t *testing.T, e QueryEngine, harness Harness, query string, ...)
- func AssertErrPreparedWithCtx(t *testing.T, e QueryEngine, harness Harness, ctx *sql.Context, query string, ...)
- func AssertErrWithBindings(t *testing.T, e QueryEngine, h Harness, query string, ...)
- func AssertErrWithCtx(t *testing.T, e QueryEngine, harness Harness, ctx *sql.Context, query string, ...)
- func AssertWarningAndTestQuery(t *testing.T, e QueryEngine, ctx *sql.Context, harness Harness, query string, ...)
- func CheckIndexedAccess(n sql.Node) bool
- func CheckResults(t *testing.T, h Harness, expected []sql.Row, expectedCols []*sql.Column, ...)
- func CreateNewConnectionForServerEngine(ctx *sql.Context, e QueryEngine) error
- func CreateVersionedTestData(t *testing.T, harness VersionedDBHarness) []sql.Database
- func DeleteRows(t *testing.T, ctx *sql.Context, table sql.DeletableTable, rows ...sql.Row)
- func DrainIterator(ctx *sql.Context, iter sql.RowIter) error
- func DrainIteratorIgnoreErrors(ctx *sql.Context, iter sql.RowIter)
- func ExecuteNode(ctx *sql.Context, engine QueryEngine, node sql.Node) error
- func ExtractQueryNode(node sql.Node) sql.Node
- func GetFilterIndex(n sql.Node) sql.IndexLookup
- func InsertRows(t *testing.T, ctx *sql.Context, table sql.InsertableTable, rows ...sql.Row)
- func IsServerEngine(e QueryEngine) bool
- func MustQuery(ctx *sql.Context, e QueryEngine, q string) (sql.Schema, []sql.Row)
- func NewBaseSession() *sql.BaseSession
- func NewColumnDefaultValue(expr sql.Expression, outType sql.Type, ...) *sql.ColumnDefaultValue
- func NewContext(harness Harness) *sql.Context
- func NewContextWithClient(harness ClientHarness, client sql.Client) *sql.Context
- func NewEngine(t *testing.T, harness Harness, dbProvider sql.DatabaseProvider, ...) (*sqle.Engine, error)
- func NewEngineWithProvider(_ *testing.T, harness Harness, provider sql.DatabaseProvider) *sqle.Engine
- func NewSession(harness Harness) *sql.Context
- func RunQueryTests(t *testing.T, harness Harness, queries []queries.QueryTest)
- func RunQueryWithContext(t *testing.T, e QueryEngine, harness Harness, ctx *sql.Context, query string)
- func RunSetupScripts(ctx *sql.Context, e *sqle.Engine, scripts []setup.SetupScript, ...) (*sqle.Engine, error)
- func RunWriteQueryTest(t *testing.T, harness Harness, tt queries.WriteQueryTest)
- func RunWriteQueryTestWithEngine(t *testing.T, harness Harness, e QueryEngine, tt queries.WriteQueryTest)
- func TestAddColumn(t *testing.T, harness Harness)
- func TestAddDropPks(t *testing.T, harness Harness)
- func TestAlterTable(t *testing.T, harness Harness)
- func TestAmbiguousColumnResolution(t *testing.T, harness Harness)
- func TestAnsiQuotesSqlMode(t *testing.T, harness Harness)
- func TestAnsiQuotesSqlModePrepared(t *testing.T, harness Harness)
- func TestBlobs(t *testing.T, h Harness)
- func TestBrokenInsertScripts(t *testing.T, harness Harness)
- func TestBrokenJSONTableScripts(t *testing.T, harness Harness)
- func TestBrokenQueries(t *testing.T, harness Harness)
- func TestCharsetCollationEngine(t *testing.T, harness Harness)
- func TestCharsetCollationWire(t *testing.T, h Harness, sessionBuilder server.SessionBuilder)
- func TestChecksOnInsert(t *testing.T, harness Harness)
- func TestChecksOnUpdate(t *testing.T, harness Harness)
- func TestClearWarnings(t *testing.T, harness Harness)
- func TestColumnAliases(t *testing.T, harness Harness)
- func TestColumnDefaults(t *testing.T, harness Harness)
- func TestComplexIndexQueries(t *testing.T, harness Harness)
- func TestComplexIndexQueriesPrepared(t *testing.T, harness Harness)
- func TestConcurrentProcessList(t *testing.T, harness Harness)
- func TestConcurrentTransactions(t *testing.T, harness Harness)
- func TestConvert(t *testing.T, harness Harness)
- func TestConvertPrepared(t *testing.T, harness Harness)
- func TestCreateCheckConstraints(t *testing.T, harness Harness)
- func TestCreateCheckConstraintsScriptsPrepared(t *testing.T, harness Harness)
- func TestCreateDatabase(t *testing.T, harness Harness)
- func TestCreateForeignKeys(t *testing.T, harness Harness)
- func TestCreateTable(t *testing.T, harness Harness)
- func TestCurrentTimestamp(t *testing.T, harness Harness)
- func TestDatabaseCollationWire(t *testing.T, h Harness, sessionBuilder server.SessionBuilder)
- func TestDateParse(t *testing.T, harness Harness)
- func TestDelete(t *testing.T, harness Harness)
- func TestDeleteErrors(t *testing.T, harness Harness)
- func TestDeleteQueriesPrepared(t *testing.T, harness Harness)
- func TestDerivedTableOuterScopeVisibility(t *testing.T, harness Harness)
- func TestDisallowedCheckConstraints(t *testing.T, harness Harness)
- func TestDropCheckConstraints(t *testing.T, harness Harness)
- func TestDropColumn(t *testing.T, harness Harness)
- func TestDropColumnKeylessTables(t *testing.T, harness Harness)
- func TestDropDatabase(t *testing.T, harness Harness)
- func TestDropForeignKeys(t *testing.T, harness Harness)
- func TestDropTable(t *testing.T, harness Harness)
- func TestEvents(t *testing.T, h Harness)
- func TestForeignKeys(t *testing.T, harness Harness)
- func TestFulltextIndexes(t *testing.T, harness Harness)
- func TestGeneratedColumnPlans(t *testing.T, harness Harness)
- func TestGeneratedColumns(t *testing.T, harness Harness)
- func TestIgnoreIntoWithDuplicateUniqueKeyKeyless(t *testing.T, harness Harness)
- func TestIgnoreIntoWithDuplicateUniqueKeyKeylessPrepared(t *testing.T, harness Harness)
- func TestImdbPlans(t *testing.T, harness Harness)
- func TestIndexPrefix(t *testing.T, h Harness)
- func TestIndexQueryPlans(t *testing.T, harness Harness)
- func TestIndexes(t *testing.T, h Harness)
- func TestInfoSchema(t *testing.T, h Harness)
- func TestInfoSchemaPrepared(t *testing.T, harness Harness)
- func TestInnerNestedInNaturalJoins(t *testing.T, harness Harness)
- func TestInsertDuplicateKeyKeyless(t *testing.T, harness Harness)
- func TestInsertDuplicateKeyKeylessPrepared(t *testing.T, harness Harness)
- func TestInsertErrorScriptsPrepared(t *testing.T, harness Harness)
- func TestInsertIgnoreInto(t *testing.T, harness Harness)
- func TestInsertIgnoreScriptsPrepared(t *testing.T, harness Harness)
- func TestInsertInto(t *testing.T, harness Harness)
- func TestInsertIntoErrors(t *testing.T, harness Harness)
- func TestInsertQueriesPrepared(t *testing.T, harness Harness)
- func TestInsertScriptsPrepared(t *testing.T, harness Harness)
- func TestIntegrationPlans(t *testing.T, harness Harness)
- func TestJSONTableQueries(t *testing.T, harness Harness)
- func TestJSONTableQueriesPrepared(t *testing.T, harness Harness)
- func TestJSONTableScripts(t *testing.T, harness Harness)
- func TestJSONTableScriptsPrepared(t *testing.T, harness Harness)
- func TestJoinOps(t *testing.T, harness Harness, tests []joinOpTest)
- func TestJoinPlanning(t *testing.T, harness Harness)
- func TestJoinQueries(t *testing.T, harness Harness)
- func TestJoinQueriesPrepared(t *testing.T, harness Harness)
- func TestJoinStats(t *testing.T, harness Harness)
- func TestJsonScripts(t *testing.T, harness Harness, skippedTests []string)
- func TestJsonScriptsPrepared(t *testing.T, harness Harness, skippedTests []string)
- func TestLateralJoinQueries(t *testing.T, harness Harness)
- func TestLoadData(t *testing.T, harness Harness)
- func TestLoadDataErrors(t *testing.T, harness Harness)
- func TestLoadDataFailing(t *testing.T, harness Harness)
- func TestLoadDataPrepared(t *testing.T, harness Harness)
- func TestModifyColumn(t *testing.T, harness Harness)
- func TestMySqlDb(t *testing.T, harness Harness)
- func TestMySqlDbPrepared(t *testing.T, harness Harness)
- func TestNamedWindows(t *testing.T, harness Harness)
- func TestNaturalJoin(t *testing.T, harness Harness)
- func TestNaturalJoinDisjoint(t *testing.T, harness Harness)
- func TestNaturalJoinEqual(t *testing.T, harness Harness)
- func TestNoDatabaseSelected(t *testing.T, harness Harness)
- func TestNullRanges(t *testing.T, harness Harness)
- func TestNumericErrorScripts(t *testing.T, harness Harness)
- func TestOnUpdateExprScripts(t *testing.T, harness Harness)
- func TestOrderByGroupBy(t *testing.T, harness Harness)
- func TestPersist(t *testing.T, harness Harness, ...)
- func TestPkOrdinalsDDL(t *testing.T, harness Harness)
- func TestPkOrdinalsDML(t *testing.T, harness Harness)
- func TestPrepared(t *testing.T, harness Harness)
- func TestPreparedInsert(t *testing.T, harness Harness)
- func TestPreparedQuery(t *testing.T, harness Harness, q string, expected []sql.Row, ...)
- func TestPreparedQueryWithContext(t *testing.T, ctx *sql.Context, e QueryEngine, h Harness, q string, ...)
- func TestPreparedQueryWithEngine(t *testing.T, harness Harness, e QueryEngine, tt queries.QueryTest)
- func TestPreparedStatements(t *testing.T, harness Harness)
- func TestPrivilegePersistence(t *testing.T, h Harness)
- func TestQueries(t *testing.T, harness Harness)
- func TestQueriesPrepared(t *testing.T, harness Harness)
- func TestQuery(t *testing.T, harness Harness, q string, expected []sql.Row, ...)
- func TestQuery2(t *testing.T, harness Harness, e QueryEngine, q string, expected []sql.Row, ...)
- func TestQueryErrors(t *testing.T, harness Harness)
- func TestQueryPlan(t *testing.T, harness Harness, e QueryEngine, tt queries.QueryPlanTest)
- func TestQueryPlanWithEngine(t *testing.T, harness Harness, e QueryEngine, tt queries.QueryPlanTest, ...)
- func TestQueryPlanWithName(t *testing.T, name string, harness Harness, e QueryEngine, ...)
- func TestQueryPlans(t *testing.T, harness Harness, planTests []queries.QueryPlanTest)
- func TestQueryWithContext(t *testing.T, ctx *sql.Context, e QueryEngine, harness Harness, q string, ...)
- func TestQueryWithEngine(t *testing.T, harness Harness, e QueryEngine, tt queries.QueryTest)
- func TestQueryWithIndexCheck(t *testing.T, ctx *sql.Context, e QueryEngine, harness Harness, q string, ...)
- func TestReadOnly(t *testing.T, harness Harness, testStoredProcedures bool)
- func TestReadOnlyDatabases(t *testing.T, harness ReadOnlyDatabaseHarness)
- func TestReadOnlyVersionedQueries(t *testing.T, harness Harness)
- func TestRecursiveViewDefinition(t *testing.T, harness Harness)
- func TestRenameColumn(t *testing.T, harness Harness)
- func TestRenameTable(t *testing.T, harness Harness)
- func TestReplaceInto(t *testing.T, harness Harness)
- func TestReplaceIntoErrors(t *testing.T, harness Harness)
- func TestReplaceQueriesPrepared(t *testing.T, harness Harness)
- func TestRollbackTriggers(t *testing.T, harness Harness)
- func TestRowLimit(t *testing.T, harness Harness)
- func TestSQLLogicTests(t *testing.T, harness Harness)
- func TestScript(t *testing.T, harness Harness, script queries.ScriptTest)
- func TestScriptPrepared(t *testing.T, harness Harness, script queries.ScriptTest) bool
- func TestScriptWithEngine(t *testing.T, e QueryEngine, harness Harness, script queries.ScriptTest)
- func TestScriptWithEnginePrepared(t *testing.T, e QueryEngine, harness Harness, script queries.ScriptTest)
- func TestScripts(t *testing.T, harness Harness)
- func TestScriptsPrepared(t *testing.T, harness Harness)
- func TestSelectIntoFile(t *testing.T, harness Harness)
- func TestSessionSelectLimit(t *testing.T, harness Harness)
- func TestShowTableStatus(t *testing.T, harness Harness)
- func TestShowTableStatusPrepared(t *testing.T, harness Harness)
- func TestShowTriggers(t *testing.T, harness Harness)
- func TestSpatialDelete(t *testing.T, harness Harness)
- func TestSpatialIndexPlans(t *testing.T, harness Harness)
- func TestSpatialIndexScripts(t *testing.T, harness Harness)
- func TestSpatialIndexScriptsPrepared(t *testing.T, harness Harness)
- func TestSpatialInsertInto(t *testing.T, harness Harness)
- func TestSpatialQueries(t *testing.T, harness Harness)
- func TestSpatialQueriesPrepared(t *testing.T, harness Harness)
- func TestSpatialScripts(t *testing.T, harness Harness)
- func TestSpatialScriptsPrepared(t *testing.T, harness Harness)
- func TestSpatialUpdate(t *testing.T, harness Harness)
- func TestStatisticIndexFilters(t *testing.T, harness Harness)
- func TestStatistics(t *testing.T, harness Harness)
- func TestStatisticsPrepared(t *testing.T, harness Harness)
- func TestStoredProcedures(t *testing.T, harness Harness)
- func TestSysbenchPlans(t *testing.T, harness Harness)
- func TestTpccPlans(t *testing.T, harness Harness)
- func TestTpcdsPlans(t *testing.T, harness Harness)
- func TestTpchPlans(t *testing.T, harness Harness)
- func TestTracing(t *testing.T, harness Harness)
- func TestTransactionScript(t *testing.T, harness Harness, script queries.TransactionTest) bool
- func TestTransactionScriptWithEngine(t *testing.T, e QueryEngine, harness Harness, script queries.TransactionTest)
- func TestTransactionScripts(t *testing.T, harness Harness)
- func TestTriggerErrors(t *testing.T, harness Harness)
- func TestTriggers(t *testing.T, harness Harness)
- func TestTruncate(t *testing.T, harness Harness)
- func TestTypesOverWire(t *testing.T, harness ClientHarness, sessionBuilder server.SessionBuilder)
- func TestUpdate(t *testing.T, harness Harness)
- func TestUpdateErrors(t *testing.T, harness Harness)
- func TestUpdateIgnore(t *testing.T, harness Harness)
- func TestUpdateQueriesPrepared(t *testing.T, harness Harness)
- func TestUse(t *testing.T, harness Harness)
- func TestUserAuthentication(t *testing.T, h Harness)
- func TestUserPrivileges(t *testing.T, harness ClientHarness)
- func TestValidateSession(t *testing.T, harness Harness, ...)
- func TestVariableErrors(t *testing.T, harness Harness)
- func TestVariables(t *testing.T, harness Harness)
- func TestVectorFunctions(t *testing.T, h Harness)
- func TestVectorIndexes(t *testing.T, h Harness)
- func TestVersionedQueries(t *testing.T, harness VersionedDBHarness)
- func TestVersionedQueriesPrepared(t *testing.T, harness VersionedDBHarness)
- func TestVersionedViews(t *testing.T, harness VersionedDBHarness)
- func TestVersionedViewsPrepared(t *testing.T, harness VersionedDBHarness)
- func TestViews(t *testing.T, harness Harness)
- func TestViewsPrepared(t *testing.T, harness Harness)
- func TestWarnings(t *testing.T, harness Harness)
- func TestWindowFunctions(t *testing.T, harness Harness)
- func TestWindowRangeFrames(t *testing.T, harness Harness)
- func TestWindowRowFrames(t *testing.T, harness Harness)
- func WidenRow(sch sql.Schema, row sql.Row) sql.Row
- func WidenRows(sch sql.Schema, rows []sql.Row) []sql.Row
- type ClientHarness
- type CustomValueValidator
- type DialectHarness
- type ForeignKeyHarness
- type Harness
- type IndexDriverHarness
- type IndexDriverInitializer
- type IndexHarness
- type JoinOpTests
- type JoinPlanTest
- type KeylessTableHarness
- type MemoryHarness
- func (m *MemoryHarness) ExternalStoredProcedure(_ *sql.Context, name string, numOfParams int) (*sql.ExternalStoredProcedureDetails, error)
- func (m *MemoryHarness) ExternalStoredProcedures(_ *sql.Context, name string) ([]sql.ExternalStoredProcedureDetails, error)
- func (m *MemoryHarness) IndexDriver(dbs []sql.Database) sql.IndexDriver
- func (m *MemoryHarness) InitializeIndexDriver(dbs []sql.Database)
- func (m *MemoryHarness) IsUsingServer() bool
- func (m *MemoryHarness) NewContext() *sql.Context
- func (m *MemoryHarness) NewContextWithClient(client sql.Client) *sql.Context
- func (m *MemoryHarness) NewDatabaseProvider() sql.MutableDatabaseProvider
- func (m *MemoryHarness) NewDatabases(names ...string) []sql.Database
- func (m *MemoryHarness) NewEngine(t *testing.T) (QueryEngine, error)
- func (m *MemoryHarness) NewReadOnlyEngine(provider sql.DatabaseProvider) (QueryEngine, error)
- func (m *MemoryHarness) NewSession() *sql.Context
- func (m *MemoryHarness) NewTableAsOf(db sql.VersionedDatabase, name string, schema sql.PrimaryKeySchema, ...) sql.Table
- func (m *MemoryHarness) Parallelism() int
- func (m *MemoryHarness) Provider() *memory.DbProvider
- func (m *MemoryHarness) QueriesToSkip(queries ...string)
- func (m MemoryHarness) RetainSessionAfterSetup() *MemoryHarness
- func (m *MemoryHarness) SessionBuilder() server.SessionBuilder
- func (m *MemoryHarness) Setup(setupData ...[]setup.SetupScript)
- func (m *MemoryHarness) SkipQueryTest(query string) bool
- func (m *MemoryHarness) SnapshotTable(db sql.VersionedDatabase, name string, asOf interface{}) error
- func (m *MemoryHarness) SupportsForeignKeys() bool
- func (m *MemoryHarness) SupportsKeylessTables() bool
- func (m *MemoryHarness) SupportsNativeIndexCreation() bool
- func (m *MemoryHarness) UseServer()
- func (m *MemoryHarness) ValidateEngine(ctx *sql.Context, e *sqle.Engine) error
- func (m *MemoryHarness) WithProvider(provider sql.DatabaseProvider) *MemoryHarness
- type MySQLPersister
- type QueryEngine
- type ReadOnlyDatabaseHarness
- type ResultEvaluationHarness
- type ServerHarness
- type ServerQueryEngine
- func (s *ServerQueryEngine) AnalyzeQuery(ctx *sql.Context, query string) (sql.Node, error)
- func (s *ServerQueryEngine) Close() error
- func (s *ServerQueryEngine) CloseSession(connID uint32)
- func (s *ServerQueryEngine) EngineAnalyzer() *analyzer.Analyzer
- func (s *ServerQueryEngine) EngineEventScheduler() sql.EventScheduler
- func (s *ServerQueryEngine) EnginePreparedDataCache() *sqle.PreparedDataCache
- func (s *ServerQueryEngine) NewConnection(ctx *sql.Context) error
- func (s *ServerQueryEngine) PrepareQuery(ctx *sql.Context, query string) (sql.Node, error)
- func (s *ServerQueryEngine) Query(ctx *sql.Context, query string) (sql.Schema, sql.RowIter, *sql.QueryFlags, error)
- func (s *ServerQueryEngine) QueryWithBindings(ctx *sql.Context, query string, parsed sqlparser.Statement, ...) (sql.Schema, sql.RowIter, *sql.QueryFlags, error)
- type SkippingHarness
- type SkippingMemoryHarness
- type SpatialIndexPlanTest
- type SpatialIndexPlanTestAssertion
- type TestProvider
- type TransactionHarness
- type ValidatingHarness
- type VersionedDBHarness
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DebugQueryPlan = sql.DescribeOptions{ Analyze: false, Estimates: false, Debug: true, }
var DefaultJoinOpTests = []joinOpTest{ { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, }
var EngineOnlyJoinOpTests = []joinOpTest{ { // contains filtered or unexported fields }, }
var JoinPlanningTests = []struct { name string setup []string tests []JoinPlanTest }{ { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, }
var JoinStatTests = []struct { name string setup []string tests []JoinPlanTest }{ { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, }
var SpatialIndexTests = []SpatialIndexPlanTest{ { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, { // contains filtered or unexported fields }, }
Functions ¶
func AssertErr ¶
func AssertErr(t *testing.T, e QueryEngine, harness Harness, query string, bindings map[string]sqlparser.Expr, expectedErrKind *errors.Kind, errStrs ...string)
AssertErr asserts that the given query returns an error during its execution, optionally specifying a type of error.
func AssertErrPrepared ¶ added in v0.15.0
func AssertErrPrepared(t *testing.T, e QueryEngine, harness Harness, query string, expectedErrKind *errors.Kind, errStrs ...string)
AssertErrPrepared asserts that the given query returns an error during its execution, optionally specifying a type of error.
func AssertErrPreparedWithCtx ¶ added in v0.15.0
func AssertErrPreparedWithCtx(t *testing.T, e QueryEngine, harness Harness, ctx *sql.Context, query string, expectedErrKind *errors.Kind, errStrs ...string)
AssertErrPreparedWithCtx is the same as AssertErr, but uses the context given instead of creating one from a harness
func AssertErrWithBindings ¶ added in v0.10.0
func AssertErrWithBindings(t *testing.T, e QueryEngine, h Harness, query string, bindings map[string]sqlparser.Expr, expectedErrKind *errors.Kind, errStr ...string)
AssertErrWithBindings asserts that the given query returns an error during its execution, optionally specifying a type of error.
func AssertErrWithCtx ¶ added in v0.10.0
func AssertErrWithCtx(t *testing.T, e QueryEngine, harness Harness, ctx *sql.Context, query string, bindings map[string]sqlparser.Expr, expectedErrKind *errors.Kind, errStr ...string)
AssertErrWithCtx is the same as AssertErr, but uses the context given instead of creating one from a harness
func AssertWarningAndTestQuery ¶ added in v0.10.0
func AssertWarningAndTestQuery( t *testing.T, e QueryEngine, ctx *sql.Context, harness Harness, query string, expected []sql.Row, expectedCols []*sql.Column, expectedCode int, expectedWarningsCount int, expectedWarningMessageSubstring string, skipResultsCheck bool, )
AssertWarningAndTestQuery tests the query and asserts an expected warning code. If |ctx| is provided, it will be used. Otherwise the harness will be used to create a fresh context.
func CheckIndexedAccess ¶ added in v0.18.0
func CheckResults ¶ added in v0.19.0
func CheckResults( t *testing.T, h Harness, expected []sql.Row, expectedCols []*sql.Column, sch sql.Schema, rows []sql.Row, q string, e QueryEngine, )
CheckResults compares the
func CreateNewConnectionForServerEngine ¶ added in v0.18.0
func CreateNewConnectionForServerEngine(ctx *sql.Context, e QueryEngine) error
CreateNewConnectionForServerEngine creates a new connection in the server engine. If there was an existing one, it gets closed before the new gets created. This function should be called when needing to use new session for the server.
func CreateVersionedTestData ¶ added in v0.15.0
func CreateVersionedTestData(t *testing.T, harness VersionedDBHarness) []sql.Database
CreateVersionedTestData uses the provided harness to create test tables and data for many of the other tests.
func DeleteRows ¶
func DrainIteratorIgnoreErrors ¶ added in v0.18.0
This shouldn't be necessary -- the fact that an iterator can return an error but not clean up after itself in all cases is a bug.
func ExecuteNode ¶ added in v0.18.0
ExecuteNode builds an iterator and then drains it. This is useful for populating actual row counts for `DESCRIBE ANALYZE`.
func GetFilterIndex ¶ added in v0.18.0
func GetFilterIndex(n sql.Node) sql.IndexLookup
func InsertRows ¶
func IsServerEngine ¶ added in v0.18.0
func IsServerEngine(e QueryEngine) bool
func NewBaseSession ¶
func NewBaseSession() *sql.BaseSession
NewBaseSession returns a new BaseSession compatible with these tests. Most tests will work with any session implementation, but for full compatibility use a session based on this one.
func NewColumnDefaultValue ¶ added in v0.12.0
func NewColumnDefaultValue(expr sql.Expression, outType sql.Type, representsLiteral, isParenthesized, mayReturnNil bool) *sql.ColumnDefaultValue
func NewContext ¶
func NewContextWithClient ¶ added in v0.12.0
func NewContextWithClient(harness ClientHarness, client sql.Client) *sql.Context
func NewEngine ¶
func NewEngine(t *testing.T, harness Harness, dbProvider sql.DatabaseProvider, setupData []setup.SetupScript, statsProvider sql.StatsProvider) (*sqle.Engine, error)
NewEngine creates an engine and sets it up for testing using harness, provider, and setup data given.
func NewEngineWithProvider ¶ added in v0.12.0
func NewEngineWithProvider(_ *testing.T, harness Harness, provider sql.DatabaseProvider) *sqle.Engine
NewEngineWithProvider returns a new engine with the specified provider
func NewSession ¶ added in v0.10.0
func RunQueryTests ¶
RunQueryTests runs the query tests given after setting up the engine. Useful for testing out a smaller subset of queries during debugging.
func RunQueryWithContext ¶ added in v0.10.0
func RunQueryWithContext(t *testing.T, e QueryEngine, harness Harness, ctx *sql.Context, query string)
RunQueryWithContext runs the query given and asserts that it doesn't result in an error. If |ctx| is nil, this function creates new context using `NewContext()` method on given harness.
func RunSetupScripts ¶ added in v0.15.0
func RunSetupScripts(ctx *sql.Context, e *sqle.Engine, scripts []setup.SetupScript, createIndexes bool) (*sqle.Engine, error)
RunSetupScripts runs the given setup scripts on the given engine, returning any error
func RunWriteQueryTest ¶ added in v0.14.0
func RunWriteQueryTest(t *testing.T, harness Harness, tt queries.WriteQueryTest)
RunWriteQueryTest runs the specified |tt| WriteQueryTest using the specified harness.
func RunWriteQueryTestWithEngine ¶ added in v0.15.0
func RunWriteQueryTestWithEngine(t *testing.T, harness Harness, e QueryEngine, tt queries.WriteQueryTest)
RunWriteQueryTestWithEngine runs the specified |tt| WriteQueryTest, using the specified harness and engine. Callers are still responsible for closing the engine.
func TestAddColumn ¶
func TestAddDropPks ¶ added in v0.11.0
func TestAlterTable ¶ added in v0.12.0
func TestAnsiQuotesSqlMode ¶ added in v0.17.0
func TestAnsiQuotesSqlModePrepared ¶ added in v0.17.0
func TestBrokenInsertScripts ¶ added in v0.12.0
func TestBrokenJSONTableScripts ¶ added in v0.14.0
func TestBrokenQueries ¶ added in v0.12.0
func TestCharsetCollationEngine ¶ added in v0.14.0
func TestCharsetCollationWire ¶ added in v0.14.0
func TestCharsetCollationWire(t *testing.T, h Harness, sessionBuilder server.SessionBuilder)
func TestChecksOnInsert ¶ added in v0.9.0
func TestChecksOnUpdate ¶ added in v0.10.0
func TestClearWarnings ¶
func TestColumnAliases ¶
TestColumnAliases exercises the logic for naming and referring to column aliases, and unlike other tests in this file checks that the name of the columns in the result schema is correct.
func TestColumnDefaults ¶
func TestComplexIndexQueries ¶ added in v0.12.0
func TestComplexIndexQueriesPrepared ¶ added in v0.12.0
func TestConcurrentProcessList ¶ added in v0.17.0
func TestConcurrentTransactions ¶ added in v0.12.0
TestConcurrentTransactions tests that two concurrent processes/transactions can successfully execute without early cancellation.
func TestConvert ¶ added in v0.15.0
func TestConvertPrepared ¶ added in v0.15.0
func TestCreateCheckConstraints ¶ added in v0.9.0
func TestCreateCheckConstraintsScriptsPrepared ¶ added in v0.12.0
func TestCreateDatabase ¶ added in v0.9.0
func TestCreateForeignKeys ¶
func TestCreateTable ¶
func TestCurrentTimestamp ¶ added in v0.12.0
func TestDatabaseCollationWire ¶ added in v0.14.0
func TestDatabaseCollationWire(t *testing.T, h Harness, sessionBuilder server.SessionBuilder)
func TestDateParse ¶ added in v0.11.0
func TestDelete ¶
func TestDeleteErrors ¶
func TestDeleteQueriesPrepared ¶ added in v0.12.0
func TestDerivedTableOuterScopeVisibility ¶ added in v0.14.0
func TestDisallowedCheckConstraints ¶ added in v0.9.0
func TestDropCheckConstraints ¶ added in v0.9.0
func TestDropColumn ¶
func TestDropColumnKeylessTables ¶ added in v0.12.0
func TestDropDatabase ¶ added in v0.9.0
func TestDropForeignKeys ¶
func TestDropTable ¶
func TestEvents ¶ added in v0.15.0
func TestForeignKeys ¶ added in v0.12.0
func TestFulltextIndexes ¶ added in v0.17.0
func TestGeneratedColumnPlans ¶ added in v0.18.0
func TestGeneratedColumns ¶ added in v0.17.0
func TestIgnoreIntoWithDuplicateUniqueKeyKeyless ¶ added in v0.14.0
func TestIgnoreIntoWithDuplicateUniqueKeyKeylessPrepared ¶ added in v0.15.0
func TestImdbPlans ¶ added in v0.18.0
func TestIndexPrefix ¶ added in v0.15.0
func TestIndexQueryPlans ¶ added in v0.12.0
func TestIndexes ¶ added in v0.15.0
func TestInfoSchema ¶
TestInfoSchema runs tests of the information_schema database
func TestInfoSchemaPrepared ¶ added in v0.12.0
TestInfoSchemaPrepared runs tests of the information_schema database
func TestInsertDuplicateKeyKeyless ¶ added in v0.15.0
func TestInsertDuplicateKeyKeylessPrepared ¶ added in v0.15.0
func TestInsertErrorScriptsPrepared ¶ added in v0.12.0
func TestInsertIgnoreInto ¶ added in v0.10.0
func TestInsertIgnoreScriptsPrepared ¶ added in v0.12.0
func TestInsertInto ¶
func TestInsertIntoErrors ¶
func TestInsertQueriesPrepared ¶ added in v0.12.0
func TestInsertScriptsPrepared ¶ added in v0.12.0
func TestIntegrationPlans ¶ added in v0.14.0
func TestJSONTableQueries ¶ added in v0.14.0
func TestJSONTableQueriesPrepared ¶ added in v0.16.0
func TestJSONTableScripts ¶ added in v0.14.0
func TestJSONTableScriptsPrepared ¶ added in v0.16.0
func TestJoinOps ¶ added in v0.15.0
func TestJoinPlanning ¶ added in v0.15.0
func TestJoinQueries ¶ added in v0.12.0
TestJoinQueries tests join queries against a provided harness.
func TestJoinQueriesPrepared ¶ added in v0.15.0
TestJoinQueriesPrepared tests join queries as prepared statements against a provided harness.
func TestJoinStats ¶ added in v0.18.0
func TestJsonScripts ¶ added in v0.9.0
func TestJsonScriptsPrepared ¶ added in v0.12.0
func TestLateralJoinQueries ¶ added in v0.17.0
func TestLoadData ¶ added in v0.9.0
func TestLoadDataErrors ¶ added in v0.9.0
func TestLoadDataFailing ¶ added in v0.9.0
func TestLoadDataPrepared ¶ added in v0.12.0
func TestModifyColumn ¶
func TestMySqlDb ¶ added in v0.17.0
func TestMySqlDbPrepared ¶ added in v0.17.0
func TestNamedWindows ¶ added in v0.12.0
func TestNaturalJoin ¶
func TestNaturalJoinDisjoint ¶
func TestNaturalJoinEqual ¶
func TestNoDatabaseSelected ¶ added in v0.12.0
func TestNullRanges ¶ added in v0.12.0
func TestNumericErrorScripts ¶ added in v0.19.0
func TestOnUpdateExprScripts ¶ added in v0.18.0
func TestOrderByGroupBy ¶
func TestPersist ¶ added in v0.12.0
func TestPkOrdinalsDDL ¶ added in v0.12.0
func TestPkOrdinalsDML ¶ added in v0.12.0
func TestPrepared ¶ added in v0.12.0
func TestPreparedInsert ¶ added in v0.12.0
func TestPreparedQuery ¶ added in v0.12.0
func TestPreparedQuery(t *testing.T, harness Harness, q string, expected []sql.Row, expectedCols []*sql.Column)
TestPreparedQuery runs a prepared query on the engine given and asserts that results are as expected.
func TestPreparedQueryWithContext ¶ added in v0.12.0
func TestPreparedQueryWithEngine ¶ added in v0.12.0
func TestPreparedStatements ¶ added in v0.15.0
func TestPrivilegePersistence ¶ added in v0.12.0
func TestQueries ¶
TestQueries tests a variety of queries against databases and tables provided by the given harness.
func TestQueriesPrepared ¶ added in v0.12.0
func TestQuery ¶
func TestQuery(t *testing.T, harness Harness, q string, expected []sql.Row, expectedCols []*sql.Column, bindings map[string]sqlparser.Expr)
TestQuery runs a query on the engine given and asserts that results are as expected. TODO: this should take en engine
func TestQuery2 ¶ added in v0.15.0
func TestQuery2(t *testing.T, harness Harness, e QueryEngine, q string, expected []sql.Row, expectedCols []*sql.Column, bindings map[string]sqlparser.Expr)
TestQuery runs a query on the engine given and asserts that results are as expected.
func TestQueryErrors ¶
func TestQueryPlan ¶
func TestQueryPlan(t *testing.T, harness Harness, e QueryEngine, tt queries.QueryPlanTest)
TestQueryPlan analyzes the query given and asserts that its printed plan matches the expected one.
func TestQueryPlanWithEngine ¶ added in v0.12.0
func TestQueryPlanWithEngine(t *testing.T, harness Harness, e QueryEngine, tt queries.QueryPlanTest, verbose bool)
func TestQueryPlanWithName ¶ added in v0.18.0
func TestQueryPlanWithName(t *testing.T, name string, harness Harness, e QueryEngine, query, expectedPlan string, options sql.DescribeOptions)
func TestQueryPlans ¶
func TestQueryPlans(t *testing.T, harness Harness, planTests []queries.QueryPlanTest)
TestQueryPlans tests generating the correct query plans for various queries using databases and tables provided by the given harness.
func TestQueryWithContext ¶
func TestQueryWithEngine ¶ added in v0.12.0
TODO: collapse into TestQuery
func TestQueryWithIndexCheck ¶ added in v0.18.0
func TestReadOnlyDatabases ¶ added in v0.11.0
func TestReadOnlyDatabases(t *testing.T, harness ReadOnlyDatabaseHarness)
func TestReadOnlyVersionedQueries ¶ added in v0.15.0
func TestRecursiveViewDefinition ¶ added in v0.14.0
func TestRenameColumn ¶
func TestRenameTable ¶
func TestReplaceInto ¶
func TestReplaceIntoErrors ¶
func TestReplaceQueriesPrepared ¶ added in v0.12.0
func TestRollbackTriggers ¶ added in v0.12.0
func TestRowLimit ¶ added in v0.18.0
func TestSQLLogicTests ¶ added in v0.18.0
func TestScript ¶
func TestScript(t *testing.T, harness Harness, script queries.ScriptTest)
TestScript runs the test script given, making any assertions given
func TestScriptPrepared ¶ added in v0.12.0
TestScriptPrepared substitutes literals for bindvars, runs the test script given, and makes any assertions given
func TestScriptWithEngine ¶
func TestScriptWithEngine(t *testing.T, e QueryEngine, harness Harness, script queries.ScriptTest)
TestScriptWithEngine runs the test script given with the engine provided.
func TestScriptWithEnginePrepared ¶ added in v0.12.0
func TestScriptWithEnginePrepared(t *testing.T, e QueryEngine, harness Harness, script queries.ScriptTest)
TestScriptWithEnginePrepared runs the test script with bindvars substituted for literals using the engine provided.
func TestScripts ¶
func TestScriptsPrepared ¶ added in v0.12.0
func TestSelectIntoFile ¶ added in v0.18.0
func TestSessionSelectLimit ¶
func TestShowTableStatus ¶ added in v0.9.0
Runs tests on SHOW TABLE STATUS queries.
func TestShowTableStatusPrepared ¶ added in v0.12.0
func TestShowTriggers ¶ added in v0.12.0
func TestSpatialDelete ¶ added in v0.12.0
func TestSpatialIndexPlans ¶ added in v0.15.0
func TestSpatialIndexScripts ¶ added in v0.15.0
func TestSpatialIndexScriptsPrepared ¶ added in v0.15.0
func TestSpatialInsertInto ¶ added in v0.12.0
func TestSpatialQueries ¶ added in v0.12.0
TestSpatialQueries tests a variety of geometry queries against databases and tables provided by the given harness.
func TestSpatialQueriesPrepared ¶ added in v0.12.0
TestSpatialQueriesPrepared tests a variety of geometry queries against databases and tables provided by the given harness.
func TestSpatialScripts ¶ added in v0.12.0
func TestSpatialScriptsPrepared ¶ added in v0.15.0
func TestSpatialUpdate ¶ added in v0.12.0
func TestStatisticIndexFilters ¶ added in v0.18.0
TestStatisticIndexFilters tests index histogram costing
func TestStatistics ¶ added in v0.14.0
TestStatistics tests the statistics from ANALYZE TABLE
func TestStatisticsPrepared ¶ added in v0.14.0
TestStatisticsPrepared tests the statistics from ANALYZE TABLE
func TestStoredProcedures ¶ added in v0.9.0
func TestSysbenchPlans ¶ added in v0.18.0
func TestTpccPlans ¶ added in v0.18.0
func TestTpcdsPlans ¶ added in v0.18.0
func TestTpchPlans ¶ added in v0.18.0
func TestTracing ¶
func TestTransactionScript ¶ added in v0.10.0
TestTransactionScript runs the test script given, making any assertions given
func TestTransactionScriptWithEngine ¶ added in v0.10.0
func TestTransactionScriptWithEngine(t *testing.T, e QueryEngine, harness Harness, script queries.TransactionTest)
TestTransactionScriptWithEngine runs the transaction test script given with the engine provided.
func TestTransactionScripts ¶ added in v0.10.0
func TestTriggerErrors ¶
func TestTriggers ¶
func TestTruncate ¶
func TestTypesOverWire ¶ added in v0.12.0
func TestTypesOverWire(t *testing.T, harness ClientHarness, sessionBuilder server.SessionBuilder)
func TestUpdate ¶
func TestUpdateErrors ¶
func TestUpdateIgnore ¶ added in v0.14.0
func TestUpdateQueriesPrepared ¶ added in v0.12.0
func TestUserAuthentication ¶ added in v0.12.0
func TestUserPrivileges ¶ added in v0.12.0
func TestUserPrivileges(t *testing.T, harness ClientHarness)
func TestValidateSession ¶ added in v0.14.0
func TestVariableErrors ¶
func TestVariables ¶
func TestVectorFunctions ¶ added in v0.19.0
func TestVectorIndexes ¶ added in v0.19.0
func TestVersionedQueries ¶
func TestVersionedQueries(t *testing.T, harness VersionedDBHarness)
TestVersionedQueries tests a variety of versioned queries
func TestVersionedQueriesPrepared ¶ added in v0.12.0
func TestVersionedQueriesPrepared(t *testing.T, harness VersionedDBHarness)
TestVersionedQueriesPrepared tests a variety of queries against databases and tables provided by the given harness.
func TestVersionedViews ¶
func TestVersionedViews(t *testing.T, harness VersionedDBHarness)
func TestVersionedViewsPrepared ¶ added in v0.12.0
func TestVersionedViewsPrepared(t *testing.T, harness VersionedDBHarness)
func TestViewsPrepared ¶ added in v0.12.0
func TestWarnings ¶
func TestWindowFunctions ¶ added in v0.12.0
func TestWindowRangeFrames ¶ added in v0.12.0
func TestWindowRowFrames ¶ added in v0.12.0
func WidenRows ¶
WidenRows returns a slice of rows with all values widened to their widest type. For a variety of reasons, the widths of various primitive types can vary when passed through different SQL queries (and different database implementations). We may eventually decide that this undefined behavior is a problem, but for now it's mostly just an issue when comparing results in tests. To get around this, we widen every type to its widest value in actual and expected results.
Types ¶
type ClientHarness ¶ added in v0.12.0
type ClientHarness interface { Harness // NewContextWithClient returns a context that will return the given client when requested from the session. NewContextWithClient(client sql.Client) *sql.Context }
ClientHarness allows for integrators to test user privileges, as mock clients are used to test functionality.
type CustomValueValidator ¶ added in v0.17.0
CustomValueValidator is an interface for custom validation of values in the result set
type DialectHarness ¶ added in v0.19.0
type ForeignKeyHarness ¶
type ForeignKeyHarness interface { Harness // SupportsForeignKeys returns whether this harness should accept CREATE FOREIGN KEY statements as part of test // setup. SupportsForeignKeys() bool }
ForeignKeyHarness is an extension to Harness that lets an integrator test their implementation with foreign keys. Integrator tables must implement sql.ForeignKeyTable.
type Harness ¶
type Harness interface { // NewContext allows a harness to specify any sessions or context variables necessary for the proper functioning of // their engine implementation. Every harnessed engine test uses the context created by this method, with some // additional information (e.g. current DB) set uniformly. To replicate the behavior of tests during setup, // harnesses should generally dispatch to enginetest.NewContext(harness), rather than calling this method themselves. NewContext() *sql.Context // Setup supplies a test suite's setup scripts, which must be stored and used to create a new Engine on demand via // calls to the NewEngine method. Setup(...[]setup.SetupScript) // NewEngine creates a new sqle.Engine. The state of the engine returned must match what was previous specified // by Setup, with no other data. See enginetest.NewEngine for help creating an engine suitable in tests. NewEngine(*testing.T) (QueryEngine, error) }
Harness provides a way for database integrators to validate their implementation against the standard set of queries used to develop and test the engine itself. See memory_engine_test.go for an example. The typical harness lifecycle during test setup looks like this: 1) Harness is instantiated, which should create a sql.MutableDatabaseProvider to use for the rest of setup 2) Harness.NewDatabase or Harness.NewTable is called to create the database and tables that will be used for the test 3) For some tests, harness.Setup() is called instead of Harness.NewDatabase and Harness.NewTable 4) Harness.NewEngine() is called to create an engine with the setup data provided prior. It can be called multiple times during a single test run, and must return a "fresh" engine instance each time, i.e. an instance that contains exactly the test data provided via other setup methods.
type IndexDriverHarness ¶
type IndexDriverHarness interface { Harness // InitializeIndexDriver initializes the index driver for this test run with the databases given InitializeIndexDriver(dbs []sql.Database) }
IndexDriverHarness is an extension to Harness that lets an integrator test their implementation alongside an index driver they provide.
type IndexDriverInitializer ¶ added in v0.15.0
type IndexDriverInitializer func([]sql.Database) sql.IndexDriver
type IndexHarness ¶
type IndexHarness interface { Harness // SupportsNativeIndexCreation returns whether this harness should accept CREATE INDEX statements as part of test // setup. SupportsNativeIndexCreation() bool }
IndexHarness is an extension to Harness that lets an integrator test their implementation with native (table-supplied) indexes. Integrator tables must implement sql.IndexAlterableTable.
type JoinOpTests ¶ added in v0.15.0
type JoinPlanTest ¶ added in v0.15.0
type JoinPlanTest struct {
// contains filtered or unexported fields
}
type KeylessTableHarness ¶
type KeylessTableHarness interface { Harness // SupportsKeylessTables indicates integrator support for keyless tables. SupportsKeylessTables() bool }
KeylessTableHarness is an extension to Harness that lets an integrator test their implementation with keyless tables.
type MemoryHarness ¶
type MemoryHarness struct {
// contains filtered or unexported fields
}
func NewDefaultMemoryHarness ¶
func NewDefaultMemoryHarness() *MemoryHarness
func NewMemoryHarness ¶
func NewMemoryHarness(name string, parallelism int, numTablePartitions int, useNativeIndexes bool, driverInitializer IndexDriverInitializer) *MemoryHarness
func NewReadOnlyMemoryHarness ¶ added in v0.15.0
func NewReadOnlyMemoryHarness() *MemoryHarness
func (*MemoryHarness) ExternalStoredProcedure ¶ added in v0.14.0
func (m *MemoryHarness) ExternalStoredProcedure(_ *sql.Context, name string, numOfParams int) (*sql.ExternalStoredProcedureDetails, error)
ExternalStoredProcedure implements the sql.ExternalStoredProcedureProvider interface
func (*MemoryHarness) ExternalStoredProcedures ¶ added in v0.14.0
func (m *MemoryHarness) ExternalStoredProcedures(_ *sql.Context, name string) ([]sql.ExternalStoredProcedureDetails, error)
ExternalStoredProcedures implements the sql.ExternalStoredProcedureProvider interface
func (*MemoryHarness) IndexDriver ¶
func (m *MemoryHarness) IndexDriver(dbs []sql.Database) sql.IndexDriver
func (*MemoryHarness) InitializeIndexDriver ¶ added in v0.11.0
func (m *MemoryHarness) InitializeIndexDriver(dbs []sql.Database)
func (*MemoryHarness) IsUsingServer ¶ added in v0.18.0
func (m *MemoryHarness) IsUsingServer() bool
func (*MemoryHarness) NewContext ¶
func (m *MemoryHarness) NewContext() *sql.Context
func (*MemoryHarness) NewContextWithClient ¶ added in v0.12.0
func (m *MemoryHarness) NewContextWithClient(client sql.Client) *sql.Context
func (*MemoryHarness) NewDatabaseProvider ¶ added in v0.11.0
func (m *MemoryHarness) NewDatabaseProvider() sql.MutableDatabaseProvider
func (*MemoryHarness) NewDatabases ¶ added in v0.10.0
func (m *MemoryHarness) NewDatabases(names ...string) []sql.Database
func (*MemoryHarness) NewEngine ¶ added in v0.12.0
func (m *MemoryHarness) NewEngine(t *testing.T) (QueryEngine, error)
func (*MemoryHarness) NewReadOnlyEngine ¶ added in v0.15.0
func (m *MemoryHarness) NewReadOnlyEngine(provider sql.DatabaseProvider) (QueryEngine, error)
func (*MemoryHarness) NewSession ¶ added in v0.10.0
func (m *MemoryHarness) NewSession() *sql.Context
func (*MemoryHarness) NewTableAsOf ¶
func (m *MemoryHarness) NewTableAsOf(db sql.VersionedDatabase, name string, schema sql.PrimaryKeySchema, asOf interface{}) sql.Table
func (*MemoryHarness) Parallelism ¶
func (m *MemoryHarness) Parallelism() int
func (*MemoryHarness) Provider ¶ added in v0.18.0
func (m *MemoryHarness) Provider() *memory.DbProvider
func (*MemoryHarness) QueriesToSkip ¶ added in v0.12.0
func (m *MemoryHarness) QueriesToSkip(queries ...string)
func (MemoryHarness) RetainSessionAfterSetup ¶ added in v0.19.0
func (m MemoryHarness) RetainSessionAfterSetup() *MemoryHarness
func (*MemoryHarness) SessionBuilder ¶ added in v0.18.0
func (m *MemoryHarness) SessionBuilder() server.SessionBuilder
func (*MemoryHarness) Setup ¶ added in v0.12.0
func (m *MemoryHarness) Setup(setupData ...[]setup.SetupScript)
func (*MemoryHarness) SkipQueryTest ¶ added in v0.10.0
func (m *MemoryHarness) SkipQueryTest(query string) bool
func (*MemoryHarness) SnapshotTable ¶
func (m *MemoryHarness) SnapshotTable(db sql.VersionedDatabase, name string, asOf interface{}) error
func (*MemoryHarness) SupportsForeignKeys ¶
func (m *MemoryHarness) SupportsForeignKeys() bool
func (*MemoryHarness) SupportsKeylessTables ¶
func (m *MemoryHarness) SupportsKeylessTables() bool
func (*MemoryHarness) SupportsNativeIndexCreation ¶
func (m *MemoryHarness) SupportsNativeIndexCreation() bool
func (*MemoryHarness) UseServer ¶ added in v0.18.0
func (m *MemoryHarness) UseServer()
func (*MemoryHarness) ValidateEngine ¶ added in v0.12.0
func (*MemoryHarness) WithProvider ¶ added in v0.18.0
func (m *MemoryHarness) WithProvider(provider sql.DatabaseProvider) *MemoryHarness
type MySQLPersister ¶ added in v0.18.0
type MySQLPersister struct {
Data []byte
}
MySQLPersister is an example struct which handles the persistence of the data in the "mysql" database.
func (*MySQLPersister) Persist ¶ added in v0.18.0
func (m *MySQLPersister) Persist(ctx *sql.Context, data []byte) error
Persist implements the interface mysql_db.MySQLDbPersistence. This function is simple, in that it simply stores the given data inside itself. A real application would persist to the file system.
type QueryEngine ¶ added in v0.18.0
type QueryEngine interface { PrepareQuery(*sql.Context, string) (sql.Node, error) AnalyzeQuery(*sql.Context, string) (sql.Node, error) Query(ctx *sql.Context, query string) (sql.Schema, sql.RowIter, *sql.QueryFlags, error) // TODO: get rid of this, should not be exposed to engine tests EngineAnalyzer() *analyzer.Analyzer EngineEventScheduler() sql.EventScheduler // TODO: get rid of this, should not be exposed to engine tests EnginePreparedDataCache() *sqle.PreparedDataCache QueryWithBindings(ctx *sql.Context, query string, parsed sqlparser.Statement, bindings map[string]sqlparser.Expr, qFlags *sql.QueryFlags) (sql.Schema, sql.RowIter, *sql.QueryFlags, error) CloseSession(connID uint32) Close() error }
type ReadOnlyDatabaseHarness ¶ added in v0.11.0
type ReadOnlyDatabaseHarness interface { Harness // NewReadOnlyEngine returns a new engine with read-only versions of the databases supplied by the provider. // TODO: should this and NewEngine actually just be NewProvider? NewReadOnlyEngine(provider sql.DatabaseProvider) (QueryEngine, error) }
type ResultEvaluationHarness ¶ added in v0.19.0
type ResultEvaluationHarness interface { Harness // EvaluateQueryResults compares expected query results to actual results and emits failed test assertions in the event // there are any EvaluateQueryResults( t *testing.T, expectedRows []sql.Row, expectedCols []*sql.Column, expectdSch sql.Schema, actualRows []sql.Row, query string, ) // EvaluateExpectedError compares expected error strings to actual errors and emits failed test assertions in the // event there are any EvaluateExpectedError(t *testing.T, expected string, err error) // EvaluateExpectedErrorKind compares expected error kinds to actual errors and emits failed test assertions in the EvaluateExpectedErrorKind(t *testing.T, expected *errors.Kind, err error) }
ResultEvaluationHarness is a harness that wants to assert more control over how query results are evaluated
type ServerHarness ¶ added in v0.18.0
type ServerHarness interface { Harness // SessionBuilder returns a function that creates a new session for connections to a server SessionBuilder() server.SessionBuilder }
type ServerQueryEngine ¶ added in v0.18.0
type ServerQueryEngine struct {
// contains filtered or unexported fields
}
func NewServerQueryEngine ¶ added in v0.18.0
func NewServerQueryEngine(t *testing.T, engine *sqle.Engine, builder server.SessionBuilder) (*ServerQueryEngine, error)
func (*ServerQueryEngine) AnalyzeQuery ¶ added in v0.18.0
func (*ServerQueryEngine) Close ¶ added in v0.18.0
func (s *ServerQueryEngine) Close() error
func (*ServerQueryEngine) CloseSession ¶ added in v0.18.0
func (s *ServerQueryEngine) CloseSession(connID uint32)
func (*ServerQueryEngine) EngineAnalyzer ¶ added in v0.18.0
func (s *ServerQueryEngine) EngineAnalyzer() *analyzer.Analyzer
func (*ServerQueryEngine) EngineEventScheduler ¶ added in v0.19.0
func (s *ServerQueryEngine) EngineEventScheduler() sql.EventScheduler
func (*ServerQueryEngine) EnginePreparedDataCache ¶ added in v0.18.0
func (s *ServerQueryEngine) EnginePreparedDataCache() *sqle.PreparedDataCache
func (*ServerQueryEngine) NewConnection ¶ added in v0.18.0
func (s *ServerQueryEngine) NewConnection(ctx *sql.Context) error
NewConnection creates a new connection to the server regardless of whether there is an existing connection. If there is an existing connection, it closes it and creates a new connection. New connection uses new session that the previous session state data will not persist. This function is also called when there is no connection when running a query.
func (*ServerQueryEngine) PrepareQuery ¶ added in v0.18.0
func (*ServerQueryEngine) QueryWithBindings ¶ added in v0.18.0
type SkippingHarness ¶
type SkippingHarness interface { // SkipQueryTest returns whether to skip a test of the provided query string. SkipQueryTest(query string) bool }
SkippingHarness provides a way for integrators to skip tests that are known to be broken. E.g., integrators that can't handle every possible SQL type.
type SkippingMemoryHarness ¶
type SkippingMemoryHarness struct {
MemoryHarness
}
func NewSkippingMemoryHarness ¶
func NewSkippingMemoryHarness() *SkippingMemoryHarness
func (SkippingMemoryHarness) SkipQueryTest ¶
func (s SkippingMemoryHarness) SkipQueryTest(query string) bool
type SpatialIndexPlanTest ¶ added in v0.15.0
type SpatialIndexPlanTest struct {
// contains filtered or unexported fields
}
type SpatialIndexPlanTestAssertion ¶ added in v0.15.0
type SpatialIndexPlanTestAssertion struct {
// contains filtered or unexported fields
}
type TestProvider ¶ added in v0.18.0
type TestProvider struct { sql.MutableDatabaseProvider // contains filtered or unexported fields }
func NewTestProvider ¶ added in v0.18.0
func NewTestProvider(dbProvider *sql.MutableDatabaseProvider, tf ...sql.TableFunction) *TestProvider
func (TestProvider) TableFunction ¶ added in v0.18.0
func (t TestProvider) TableFunction(_ *sql.Context, name string) (sql.TableFunction, bool)
func (TestProvider) WithTableFunctions ¶ added in v0.18.0
func (t TestProvider) WithTableFunctions(fns ...sql.TableFunction) (sql.TableFunctionProvider, error)
type TransactionHarness ¶ added in v0.10.0
type ValidatingHarness ¶ added in v0.12.0
type VersionedDBHarness ¶
type VersionedDBHarness interface { Harness // NewDatabases returns a set of new databases used for the duration of a versioned test NewDatabases(names ...string) []sql.Database // NewTableAsOf creates a new table with the given name and schema, optionally handling snapshotting with the asOf // identifier. NewTableAsOf must ignore tables that already exist in the database. Tables returned by this method do // not need to have any previously created data in them, but they can. This behavior is implementation specific, and // the harness works either way. NewTableAsOf(db sql.VersionedDatabase, name string, schema sql.PrimaryKeySchema, asOf interface{}) sql.Table // SnapshotTable creates a snapshot of the table named with the given asOf label. Depending on the implementation, // NewTableAsOf might do all the necessary work to create such snapshots, so this could be a no-op. SnapshotTable(db sql.VersionedDatabase, name string, asOf interface{}) error }
VersionedDBHarness is an extension to Harness that lets an integrator test their implementation of versioned (AS OF) queries. Integrators must implement sql.VersionedDatabase. For each table version being created, there will be a call to NewTableAsOf, some number of Delete and Insert operations, and then a call to SnapshotTable.