diff --git a/core/context.go b/core/context.go index f02df03c7f..b7687d8dd9 100644 --- a/core/context.go +++ b/core/context.go @@ -58,8 +58,8 @@ func getContextValues(ctx *sql.Context) (*contextValues, error) { return cv, nil } -// getRootFromContext returns the working session's root from the context, along with the session. -func getRootFromContext(ctx *sql.Context) (*dsess.DoltSession, *RootValue, error) { +// GetRootFromContext returns the working session's root from the context, along with the session. +func GetRootFromContext(ctx *sql.Context) (*dsess.DoltSession, *RootValue, error) { return getRootFromContextForDatabase(ctx, "") } @@ -120,7 +120,7 @@ func SetPgCatalogCache(ctx *sql.Context, pgCatalogCache any) error { // GetDoltTableFromContext returns the Dolt table from the context. Returns nil if no table was found. func GetDoltTableFromContext(ctx *sql.Context, tableName doltdb.TableName) (*doltdb.Table, error) { - _, root, err := getRootFromContext(ctx) + _, root, err := GetRootFromContext(ctx) if err != nil { return nil, err } @@ -220,7 +220,7 @@ func GetFunctionsCollectionFromContext(ctx *sql.Context) (*functions.Collection, if err != nil { return nil, err } - _, root, err := getRootFromContext(ctx) + _, root, err := GetRootFromContext(ctx) if err != nil { return nil, err } @@ -293,7 +293,7 @@ func GetTypesCollectionFromContext(ctx *sql.Context) (*typecollection.TypeCollec return nil, err } if cv.types == nil { - _, root, err := getRootFromContext(ctx) + _, root, err := GetRootFromContext(ctx) if err != nil { return nil, err } diff --git a/core/schema.go b/core/schema.go index 7975808d1c..e651a4f4a0 100644 --- a/core/schema.go +++ b/core/schema.go @@ -22,7 +22,7 @@ import ( // GetCurrentSchema returns the current schema used by the context. Defaults to "public" if the context does not specify // a schema. func GetCurrentSchema(ctx *sql.Context) (string, error) { - _, root, err := getRootFromContext(ctx) + _, root, err := GetRootFromContext(ctx) if err != nil { return "", nil } diff --git a/go.mod b/go.mod index 38d32860c2..994cb7adc5 100644 --- a/go.mod +++ b/go.mod @@ -6,13 +6,13 @@ require ( github.com/PuerkitoBio/goquery v1.8.1 github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a github.com/cockroachdb/errors v1.7.5 - github.com/dolthub/dolt/go v0.40.5-0.20250610173122-93301be37322 + github.com/dolthub/dolt/go v0.40.5-0.20250619014715-a87c3da8efaf github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241119094239-f4e529af734d github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad - github.com/dolthub/go-mysql-server v0.20.1-0.20250609235012-75f15bbda63a + github.com/dolthub/go-mysql-server v0.20.1-0.20250618175653-7d22a78f4c71 github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216 - github.com/dolthub/vitess v0.0.0-20250609213846-75541d7ef20a + github.com/dolthub/vitess v0.0.0-20250611225316-90a5898bfe26 github.com/fatih/color v1.13.0 github.com/goccy/go-json v0.10.2 github.com/gogo/protobuf v1.3.2 diff --git a/go.sum b/go.sum index ab9b579315..9f10eeb1d7 100644 --- a/go.sum +++ b/go.sum @@ -256,8 +256,8 @@ github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12 h1:IdqX7J8vi/Kn3T3Ee0VzqnLqwFmgA2hr8WZETPcQjfM= github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12/go.mod h1:rN7X8BHwkjPcfMQQ2QTAq/xM3leUSGLfb+1Js7Y6TVo= -github.com/dolthub/dolt/go v0.40.5-0.20250610173122-93301be37322 h1:a1RFFm9S7evoi52dDLYalO4dJ0ODZp0fpDzeGaRnMmU= -github.com/dolthub/dolt/go v0.40.5-0.20250610173122-93301be37322/go.mod h1:bCnd7kgVzluInixqje/NRPwykkjStWr8bLM+O8q6YB4= +github.com/dolthub/dolt/go v0.40.5-0.20250619014715-a87c3da8efaf h1:enouuGG0sJAlCN11sthy0ngFYN26vVvxDkgILI8VRRw= +github.com/dolthub/dolt/go v0.40.5-0.20250619014715-a87c3da8efaf/go.mod h1:iqXXu2G7HkrrV8G5v5a0I60HaxLeLSfjZLdP64ZepYM= github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241119094239-f4e529af734d h1:gO9+wrmNHXukPNCO1tpfCcXIdMlW/qppbUStfLvqz/U= github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241119094239-f4e529af734d/go.mod h1:L5RDYZbC9BBWmoU2+TjTekeqqhFXX5EqH9ln00O0stY= github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww= @@ -266,8 +266,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U= github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0= github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad h1:66ZPawHszNu37VPQckdhX1BPPVzREsGgNxQeefnlm3g= github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad/go.mod h1:ylU4XjUpsMcvl/BKeRRMXSH7e7WBrPXdSLvnRJYrxEA= -github.com/dolthub/go-mysql-server v0.20.1-0.20250609235012-75f15bbda63a h1:Q7obvACozcTOz11+L55dh1muPtNweIJdzNY5m0PLfDU= -github.com/dolthub/go-mysql-server v0.20.1-0.20250609235012-75f15bbda63a/go.mod h1:yVcBcDGOyYHmciKmQ20JZ+Mr12lOjSnzpmuBMZKPQGo= +github.com/dolthub/go-mysql-server v0.20.1-0.20250618175653-7d22a78f4c71 h1:KMg3/8YX0Jcs/AtghLroZ+RYp8FRo0Vvww9i2PmpUfw= +github.com/dolthub/go-mysql-server v0.20.1-0.20250618175653-7d22a78f4c71/go.mod h1:zuYoQ3keJHAvWUWMLzbP9anvR32b3sy1Fm8wB8ukNxQ= github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI= github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q= github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE= @@ -276,8 +276,8 @@ github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71 h1:bMGS25NWAGTE github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71/go.mod h1:2/2zjLQ/JOOSbbSboojeg+cAwcRV0fDLzIiWch/lhqI= github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216 h1:JWkKRE4EHUcEVQCMRBej8DYxjYjRz/9MdF/NNQh0o70= github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216/go.mod h1:e/FIZVvT2IR53HBCAo41NjqgtEnjMJGKca3Y/dAmZaA= -github.com/dolthub/vitess v0.0.0-20250609213846-75541d7ef20a h1:DWQt6KSgrkZYuxzvGflImldau0a3IfINhEGQnFst/pw= -github.com/dolthub/vitess v0.0.0-20250609213846-75541d7ef20a/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70= +github.com/dolthub/vitess v0.0.0-20250611225316-90a5898bfe26 h1:9Npf0JYVCrwe9edTfYD/pjIncCePNDiu4j50xLcV334= +github.com/dolthub/vitess v0.0.0-20250611225316-90a5898bfe26/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= diff --git a/server/ast/expr.go b/server/ast/expr.go index b3a5c288db..206c06cdb9 100644 --- a/server/ast/expr.go +++ b/server/ast/expr.go @@ -361,36 +361,43 @@ func nodeExpr(ctx *Context, node tree.Expr) (vitess.Expr, error) { Expression: pgexprs.NewBinaryOperator(framework.Operator_BinaryNotEqual), Children: vitess.Exprs{left, right}, }, nil - case tree.In: + case tree.In, tree.NotIn: + var innerExpression vitess.InjectedExpr switch right := right.(type) { case vitess.ValTuple: - return vitess.InjectedExpr{ + innerExpression = vitess.InjectedExpr{ Expression: pgexprs.NewInTuple(), Children: vitess.Exprs{left, right}, - }, nil + } case *vitess.Subquery: - return vitess.InjectedExpr{ + innerExpression = vitess.InjectedExpr{ Expression: pgexprs.NewInSubquery(), Children: vitess.Exprs{left, right}, - }, nil + } case vitess.InjectedExpr: if _, ok := right.Expression.(*pgexprs.RecordExpr); ok { - return vitess.InjectedExpr{ + innerExpression = vitess.InjectedExpr{ Expression: pgexprs.NewInTuple(), Children: vitess.Exprs{left, vitess.ValTuple(right.Children)}, - }, nil + } } } - return nil, errors.Errorf("right side of IN expression is not a tuple or subquery, got %T", right) - case tree.NotIn: - innerExpr := vitess.InjectedExpr{ - Expression: pgexprs.NewInTuple(), - Children: vitess.Exprs{left, right}, + + if innerExpression.Expression == nil { + return nil, errors.Errorf("right side of IN expression is not a tuple or subquery, got %T", right) + } + + switch node.Operator { + case tree.In: + return innerExpression, nil + case tree.NotIn: + return vitess.InjectedExpr{ + Expression: pgexprs.NewNot(), + Children: vitess.Exprs{innerExpression}, + }, nil + default: + return nil, errors.Errorf("unknown comparison operator used") } - return vitess.InjectedExpr{ - Expression: pgexprs.NewNot(), - Children: vitess.Exprs{innerExpr}, - }, nil case tree.Like: operator = vitess.LikeStr case tree.NotLike: diff --git a/server/expression/in_subquery.go b/server/expression/in_subquery.go index 113e818e43..2b38839163 100644 --- a/server/expression/in_subquery.go +++ b/server/expression/in_subquery.go @@ -15,12 +15,12 @@ package expression import ( - "context" "fmt" "github.com/cockroachdb/errors" "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" + "github.com/dolthub/go-mysql-server/sql/hash" "github.com/dolthub/go-mysql-server/sql/plan" "github.com/dolthub/go-mysql-server/sql/types" vitess "github.com/dolthub/vitess/go/vt/sqlparser" @@ -46,7 +46,7 @@ var _ sql.Expression = (*InSubquery)(nil) var _ expression.BinaryExpression = (*InSubquery)(nil) // nilKey is the hash of a row with a single nil value. -var nilKey, _ = sql.HashOf(context.TODO(), sql.NewRow(nil)) +var nilKey, _ = hash.HashOf(nil, nil, sql.NewRow(nil)) // NewInSubquery returns a new *InSubquery. func NewInSubquery() *InSubquery { @@ -97,7 +97,7 @@ func (in *InSubquery) Eval(ctx *sql.Context, row sql.Row) (any, error) { // TODO: it might be possible for the left value to hash to a different value than the right even though they pass // an equality check. We need to perform a type conversion here to catch this case. - key, err := sql.HashOf(ctx, sql.NewRow(left)) + key, err := hash.HashOf(ctx, nil, sql.NewRow(left)) if err != nil { return nil, err } diff --git a/server/tables/database.go b/server/tables/database.go index 44f2bcb1c2..29a09d47a3 100644 --- a/server/tables/database.go +++ b/server/tables/database.go @@ -35,7 +35,7 @@ func (d Database) GetTableInsensitive(ctx *sql.Context, tblName string) (sql.Tab // exact search. if tableMap, ok := handlers[d.db.Schema()]; ok { if handler, ok := tableMap[tblName]; ok { - return NewVirtualTable(handler), true, nil + return NewVirtualTable(handler, d.db), true, nil } } return nil, false, nil diff --git a/server/tables/pgcatalog/init.go b/server/tables/pgcatalog/init.go index cc65f00b31..cd06dd3a97 100644 --- a/server/tables/pgcatalog/init.go +++ b/server/tables/pgcatalog/init.go @@ -14,11 +14,17 @@ package pgcatalog +import "os" + // PgCatalogName is a constant to the pg_catalog name. const PgCatalogName = "pg_catalog" +// includeSystemTables is a flag to determine whether to include system tables in the pg_catalog tables. +var includeSystemTables = true + // Init initializes everything necessary for the pg_catalog tables. func Init() { + InitIncludeSystemTables() InitPgAggregate() InitPgAm() InitPgAmop() @@ -159,3 +165,11 @@ func Init() { InitPgUserMappings() InitPgViews() } + +func InitIncludeSystemTables() { + if _, ok := os.LookupEnv("REGRESSION_TESTING"); ok { + // In CI regression tests, we exclude system tables to make them faster. + // None of them rely on the presence of system tables. + includeSystemTables = false + } +} diff --git a/server/tables/pgcatalog/pg_attribute.go b/server/tables/pgcatalog/pg_attribute.go index 5fee85093a..9ddf667d30 100644 --- a/server/tables/pgcatalog/pg_attribute.go +++ b/server/tables/pgcatalog/pg_attribute.go @@ -17,8 +17,12 @@ package pgcatalog import ( "io" + "github.com/cockroachdb/errors" + "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" + "github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/doltgresql/core" "github.com/dolthub/doltgresql/core/id" "github.com/dolthub/doltgresql/server/functions" "github.com/dolthub/doltgresql/server/tables" @@ -69,6 +73,38 @@ func (p PgAttributeHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { if err != nil { return nil, err } + + if includeSystemTables { + _, root, err := core.GetRootFromContext(ctx) + if err != nil { + return nil, err + } + + systemTables, err := resolve.GetGeneratedSystemTables(ctx, root) + if err != nil { + return nil, err + } + + db := ctx.GetCurrentDatabase() + for _, tblName := range systemTables { + tbl, err := core.GetSqlTableFromContext(ctx, db, tblName) + if err != nil { + // Some of the system tables exist conditionally when accessed, so just skip them in this case + if errors.Is(doltdb.ErrTableNotFound, err) { + continue + } + return nil, err + } + + schema := tbl.Schema() + for i, col := range schema { + cols = append(cols, col) + colIdxs = append(colIdxs, i) + tableOIDs = append(tableOIDs, id.NewTable(tblName.Schema, tblName.Name).AsId()) + } + } + } + pgCatalogCache.attributeCols = cols pgCatalogCache.attributeColIdxs = colIdxs pgCatalogCache.attributeTableOIDs = tableOIDs diff --git a/server/tables/pgcatalog/pg_catalog_cache.go b/server/tables/pgcatalog/pg_catalog_cache.go index 7e3bf94b91..504d7f9f82 100644 --- a/server/tables/pgcatalog/pg_catalog_cache.go +++ b/server/tables/pgcatalog/pg_catalog_cache.go @@ -16,6 +16,7 @@ package pgcatalog import ( "github.com/cockroachdb/errors" + "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/go-mysql-server/sql" @@ -75,7 +76,7 @@ type pgCatalogCache struct { // pg_tables tables []sql.Table - tableSchemas []string + systemTables []doltdb.TableName } // newPgCatalogCache creates a new pgCatalogCache, with the query/process ID set to |pid|. The PID is important, diff --git a/server/tables/pgcatalog/pg_class.go b/server/tables/pgcatalog/pg_class.go index a1acdc5246..042092767d 100644 --- a/server/tables/pgcatalog/pg_class.go +++ b/server/tables/pgcatalog/pg_class.go @@ -18,8 +18,10 @@ import ( "fmt" "io" + "github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/doltgresql/core" "github.com/dolthub/doltgresql/core/id" "github.com/dolthub/doltgresql/server/functions" "github.com/dolthub/doltgresql/server/tables" @@ -103,6 +105,28 @@ func (p PgClassHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { if err != nil { return nil, err } + + if includeSystemTables { + _, root, err := core.GetRootFromContext(ctx) + if err != nil { + return nil, err + } + + systemTables, err := resolve.GetGeneratedSystemTables(ctx, root) + if err != nil { + return nil, err + } + + for _, tblName := range systemTables { + classes = append(classes, pgClass{ + oid: id.NewTable(tblName.Schema, tblName.Name).AsId(), + name: tblName.Name, + schemaOid: id.NewNamespace(tblName.Schema).AsId(), + kind: "r", + }) + } + } + pgCatalogCache.pgClasses = classes } diff --git a/server/tables/pgcatalog/pg_tables.go b/server/tables/pgcatalog/pg_tables.go index 9ecc693806..20d6b7d21c 100644 --- a/server/tables/pgcatalog/pg_tables.go +++ b/server/tables/pgcatalog/pg_tables.go @@ -17,8 +17,11 @@ package pgcatalog import ( "io" + "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" + "github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/doltgresql/core" "github.com/dolthub/doltgresql/server/functions" "github.com/dolthub/doltgresql/server/tables" pgtypes "github.com/dolthub/doltgresql/server/types" @@ -64,14 +67,26 @@ func (p PgTablesHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { if err != nil { return nil, err } + + if includeSystemTables { + _, root, err := core.GetRootFromContext(ctx) + if err != nil { + return nil, err + } + + systemTables, err := resolve.GetGeneratedSystemTables(ctx, root) + if err != nil { + return nil, err + } + pgCatalogCache.systemTables = systemTables + } + pgCatalogCache.tables = tables - pgCatalogCache.tableSchemas = tableSchemas } return &pgTablesRowIter{ - tables: pgCatalogCache.tables, - schemas: pgCatalogCache.tableSchemas, - idx: 0, + userTables: pgCatalogCache.tables, + systemTableNames: pgCatalogCache.systemTables, }, nil } @@ -97,44 +112,66 @@ var pgTablesSchema = sql.Schema{ // pgTablesRowIter is the sql.RowIter for the pg_tables table. type pgTablesRowIter struct { - tables []sql.Table - schemas []string - idx int + // userTable are the set of user-defined tables + userTables []sql.Table + // systemTableNames is the names of all system tables + systemTableNames []doltdb.TableName + // idx is the current index in the iteration through both slices + idx int } var _ sql.RowIter = (*pgTablesRowIter)(nil) // Next implements the interface sql.RowIter. func (iter *pgTablesRowIter) Next(ctx *sql.Context) (sql.Row, error) { - if iter.idx >= len(iter.tables) { + if iter.idx >= len(iter.userTables)+len(iter.systemTableNames) { return nil, io.EOF } - iter.idx++ - table := iter.tables[iter.idx-1] - schema := iter.schemas[iter.idx-1] - - hasIndexes := false - if it, ok := table.(sql.IndexAddressable); ok { - idxs, err := it.GetIndexes(ctx) - if err != nil { - return nil, err + defer func() { + iter.idx++ + }() + + var tableName string + var hasIndexes bool + var schema string + + if iter.idx < len(iter.userTables) { + table := iter.userTables[iter.idx] + + switch table := table.(type) { + case sql.DatabaseSchemaTable: + schema = table.DatabaseSchema().SchemaName() + default: + schema = "information_schema" } - if len(idxs) > 0 { - hasIndexes = true + tableName = table.Name() + + if it, ok := table.(sql.IndexAddressable); ok { + idxs, err := it.GetIndexes(ctx) + if err != nil { + return nil, err + } + + if len(idxs) > 0 { + hasIndexes = true + } } + } else { + tblName := iter.systemTableNames[iter.idx-len(iter.userTables)] + tableName = tblName.Name + schema = tblName.Schema } - // TODO: Implement the rest of these pg_tables columns return sql.Row{ - schema, // schemaname - table.Name(), // tablename - "", // tableowner - "", // tablespace - hasIndexes, // hasindexes - false, // hasrules - false, // hastriggers - false, // rowsecurity + schema, // schemaname + tableName, // tablename + "postgres", // tableowner + nil, // tablespace + hasIndexes, // hasindexes + false, // hasrules // TODO + false, // hastriggers // TODO + false, // rowsecurity }, nil } diff --git a/server/tables/virtual_table.go b/server/tables/virtual_table.go index 98fbbf2c36..258c82aae4 100644 --- a/server/tables/virtual_table.go +++ b/server/tables/virtual_table.go @@ -21,16 +21,19 @@ import ( // VirtualTable represents a table that does not enforce any particular storage of its data. type VirtualTable struct { handler Handler + schema sql.DatabaseSchema } var _ sql.DebugStringer = (*VirtualTable)(nil) var _ sql.PrimaryKeyTable = (*VirtualTable)(nil) var _ sql.Table = (*VirtualTable)(nil) +var _ sql.DatabaseSchemaTable = (*VirtualTable)(nil) // NewVirtualTable creates a new *VirtualTable from the given Handler. -func NewVirtualTable(handler Handler) *VirtualTable { +func NewVirtualTable(handler Handler, schema sql.DatabaseSchema) *VirtualTable { return &VirtualTable{ handler: handler, + schema: schema, } } @@ -75,3 +78,7 @@ func (tbl *VirtualTable) Schema() sql.Schema { func (tbl *VirtualTable) String() string { return tbl.Name() } + +func (tbl *VirtualTable) DatabaseSchema() sql.DatabaseSchema { + return tbl.schema +} diff --git a/testing/bats/pgcatalog.bats b/testing/bats/pgcatalog.bats index 02d1779cf4..f1c53b9e0c 100644 --- a/testing/bats/pgcatalog.bats +++ b/testing/bats/pgcatalog.bats @@ -22,7 +22,7 @@ teardown() { [[ "$output" =~ "postgres" ]] || false [ "${#lines[@]}" -eq 2 ] - run query_server --csv -c "SELECT attname FROM pg_catalog.pg_attribute WHERE attname = 'pk';" + run query_server --csv -c "SELECT attname FROM pg_catalog.pg_attribute WHERE attname = 'pk' and attrelid not in (select oid from pg_catalog.pg_class where left(relname, 5) = 'dolt_');" [ "$status" -eq 0 ] [[ "$output" =~ "attname" ]] || false [[ "$output" =~ "pk" ]] || false diff --git a/testing/bats/psql-commands.bats b/testing/bats/psql-commands.bats index bd2cbe3310..c90dd9cd0b 100644 --- a/testing/bats/psql-commands.bats +++ b/testing/bats/psql-commands.bats @@ -29,7 +29,6 @@ teardown() { [ "$status" -eq 0 ] [[ "$output" =~ "public,test1,table,postgres" ]] || false [[ "$output" =~ "public,test2,table,postgres" ]] || false - [ "${#lines[@]}" -eq 3 ] } @test 'psql-commands: \dt table' { @@ -46,8 +45,7 @@ teardown() { [[ "$output" =~ "public,test1,table,postgres" ]] || false [[ "$output" =~ "public,test2,table,postgres" ]] || false [[ "$output" =~ "public,testview,view,postgres" ]] || false - [ "${#lines[@]}" -eq 4 ] -} + } @test 'psql-commands: \d table' { skip "this command has not yet been implemented" diff --git a/testing/go/dolt_tables_test.go b/testing/go/dolt_tables_test.go index 5f4d226265..768de250b6 100755 --- a/testing/go/dolt_tables_test.go +++ b/testing/go/dolt_tables_test.go @@ -35,6 +35,11 @@ func TestUserSpaceDoltTables(t *testing.T) { ExpectedColNames: []string{"name"}, Expected: []sql.Row{{"main"}}, }, + { + Query: `SELECT name FROM public.dolt_branches`, + ExpectedColNames: []string{"name"}, + Expected: []sql.Row{{"main"}}, + }, { Query: `SELECT branches.name FROM dolt.branches`, ExpectedColNames: []string{"name"}, diff --git a/testing/go/enginetest/doltgres_engine_test.go b/testing/go/enginetest/doltgres_engine_test.go index ba7a268823..4cb747da44 100755 --- a/testing/go/enginetest/doltgres_engine_test.go +++ b/testing/go/enginetest/doltgres_engine_test.go @@ -1687,6 +1687,7 @@ func TestDoltCommit(t *testing.T) { "CALL DOLT_COMMIT('-amend') works to add changes to a commit", "CALL DOLT_COMMIT('-amend') works to remove changes from a commit", "CALL DOLT_COMMIT('-amend') works to update a merge commit", + "CALL DOLT_COMMIT('--amend') works on initial commit", }) denginetest.RunDoltCommitTests(t, harness) } diff --git a/testing/go/expressions_test.go b/testing/go/expressions_test.go index 2e2f50add5..3b76042a2b 100644 --- a/testing/go/expressions_test.go +++ b/testing/go/expressions_test.go @@ -100,6 +100,52 @@ func TestIn(t *testing.T) { }, }, }, + { + Name: "NOT IN", + SetUpScript: []string{ + `CREATE TABLE test (id INT);`, + `INSERT INTO test VALUES (1), (3), (2);`, + + `CREATE TABLE test2 (id INT, test_id INT, txt text);`, + `INSERT INTO test2 VALUES (1, 1, 'foo'), (2, 10, 'bar'), (3, 2, 'baz');`, + }, + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM test WHERE id NOT IN (2, 3, 4, 5);`, + Expected: []sql.Row{{int32(1)}}, + }, + { + Query: `SELECT * FROM test2 WHERE test_id NOT IN (SELECT * FROM test WHERE id = 2);`, + Expected: []sql.Row{{int32(1), int32(1), "foo"}, {int32(2), int32(10), "bar"}}, + }, + { + Query: `SELECT * FROM test2 WHERE test_id NOT IN (SELECT * FROM test WHERE id > 0);`, + Expected: []sql.Row{ + {int32(2), int32(10), "bar"}, + }, + }, + { + Query: `SELECT 4 NOT IN (null, 1, 2, 3);`, + Expected: []sql.Row{{nil}}, + }, + { + Query: `SELECT NULL NOT IN (null, 1, 2, 3);`, + Expected: []sql.Row{{nil}}, + }, + { + Query: `SELECT 4 NOT IN (1, 2, 3);`, + Expected: []sql.Row{{"t"}}, + }, + { + Query: `SELECT 4 NOT IN (1, 2, 3, 4);`, + Expected: []sql.Row{{"f"}}, + }, + { + Query: `SELECT concat('a', 'b') NOT in ('a', 'b');`, + Expected: []sql.Row{{"t"}}, + }, + }, + }, }) } diff --git a/testing/go/functions_test.go b/testing/go/functions_test.go index 35d0668670..a8f331142f 100644 --- a/testing/go/functions_test.go +++ b/testing/go/functions_test.go @@ -1340,15 +1340,15 @@ func TestSchemaVisibilityInquiryFunctions(t *testing.T) { }, Assertions: []ScriptTestAssertion{ { - Query: `SELECT c.oid, c.relname AS table_name, n.nspname AS table_schema FROM pg_catalog.pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname='myschema' OR n.nspname='testschema';`, + Query: `SELECT c.oid, c.relname AS table_name, n.nspname AS table_schema FROM pg_catalog.pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE (n.nspname='myschema' OR n.nspname='testschema') AND left(relname, 5) <> 'dolt_' order by relname;`, Expected: []sql.Row{ - {3983475213, "myview", "myschema"}, {3905781870, "mytable", "myschema"}, + {3983475213, "myview", "myschema"}, + {3057657334, "test_index", "testschema"}, {1539973141, "test_seq", "testschema"}, + {1952237395, "test_table", "testschema"}, {3508950454, "test_table_pkey", "testschema"}, - {3057657334, "test_index", "testschema"}, {521883837, "v1", "testschema"}, - {1952237395, "test_table", "testschema"}, }, }, { @@ -1542,7 +1542,7 @@ func TestSystemCatalogInformationFunctions(t *testing.T) { }, Assertions: []ScriptTestAssertion{ { - Query: `SELECT c.oid, c.relname AS table_name, n.nspname AS table_schema FROM pg_catalog.pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname='myschema' OR n.nspname='public';`, + Query: `SELECT c.oid, c.relname AS table_name, n.nspname AS table_schema FROM pg_catalog.pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE (n.nspname='myschema' OR n.nspname='public') and left(relname, 5) <> 'dolt_';`, Expected: []sql.Row{ {2707638987, "test_view", "public"}, {1397286223, "test", "public"}, diff --git a/testing/go/information_schema_test.go b/testing/go/information_schema_test.go index ed4cc63b2a..753ec4fa67 100644 --- a/testing/go/information_schema_test.go +++ b/testing/go/information_schema_test.go @@ -258,7 +258,7 @@ func TestInfoSchemaColumns(t *testing.T) { }, }, { - Query: `SELECT p.oid AS oid, p.relname AS table_name, n.nspname as table_schema FROM pg_class AS p JOIN pg_namespace AS n ON p.relnamespace=n.oid WHERE n.nspname='public' AND p.relkind='r';`, + Query: `SELECT p.oid AS oid, p.relname AS table_name, n.nspname as table_schema FROM pg_class AS p JOIN pg_namespace AS n ON p.relnamespace=n.oid WHERE (n.nspname='public' AND p.relkind='r') AND left(relname, 5) <> 'dolt_';`, Expected: []sql.Row{{2957635223, "test_table", "public"}}, }, { diff --git a/testing/go/pgcatalog_test.go b/testing/go/pgcatalog_test.go index 726f092a66..1c94a78e76 100644 --- a/testing/go/pgcatalog_test.go +++ b/testing/go/pgcatalog_test.go @@ -474,7 +474,7 @@ func TestPgClass(t *testing.T) { ExpectedErr: "not", }, { // Different cases but non-quoted, so it works - Query: "SELECT relname FROM PG_catalog.pg_CLASS ORDER BY relname ASC LIMIT 3;", + Query: "SELECT relname FROM PG_catalog.pg_CLASS where relnamespace not in (select oid from pg_namespace where nspname = 'dolt') ORDER BY relname ASC LIMIT 3;", Expected: []sql.Row{ {"administrable_role_authorizations"}, {"applicable_roles"}, @@ -482,7 +482,7 @@ func TestPgClass(t *testing.T) { }, }, { - Query: "SELECT relname from pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid WHERE n.nspname = 'testschema' ORDER BY relname;", + Query: "SELECT relname from pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid WHERE n.nspname = 'testschema' and left(relname, 5) <> 'dolt_' ORDER BY relname;", Expected: []sql.Row{ {"testing"}, {"testing_pkey"}, @@ -3505,6 +3505,8 @@ func TestPgTables(t *testing.T) { { Name: "pg_tables", SetUpScript: []string{ + `create table t1 (pk int primary key, v1 int);`, + `create table t2 (pk int primary key, v1 int);`, `CREATE SCHEMA testschema;`, `SET search_path TO testschema;`, `CREATE TABLE testing (pk INT primary key, v1 INT);`, @@ -3515,8 +3517,8 @@ func TestPgTables(t *testing.T) { }, Assertions: []ScriptTestAssertion{ { - Query: `SELECT * FROM "pg_catalog"."pg_tables" WHERE tablename='testing';`, - Expected: []sql.Row{{"testschema", "testing", "", "", "t", "f", "f", "f"}}, + Query: `SELECT * FROM "pg_catalog"."pg_tables" WHERE tablename='testing' order by 1;`, + Expected: []sql.Row{{"testschema", "testing", "postgres", nil, "t", "f", "f", "f"}}, }, { Query: `SELECT count(*) FROM "pg_catalog"."pg_tables" WHERE schemaname='pg_catalog';`, @@ -3531,13 +3533,63 @@ func TestPgTables(t *testing.T) { ExpectedErr: "not", }, { // Different cases but non-quoted, so it works - Query: "SELECT schemaname, tablename FROM PG_catalog.pg_TABLES WHERE schemaname != 'information_schema' ORDER BY tablename DESC LIMIT 3;", + Query: "SELECT schemaname, tablename FROM PG_catalog.pg_TABLES WHERE schemaname not in ('information_schema', 'dolt', 'public') ORDER BY tablename DESC LIMIT 3;", Expected: []sql.Row{ {"testschema", "testing"}, {"pg_catalog", "pg_views"}, {"pg_catalog", "pg_user_mappings"}, }, }, + { + Query: "SELECT schemaname, tablename FROM PG_catalog.pg_TABLES WHERE schemaname ='public' ORDER BY tablename;", + Expected: []sql.Row{ + {"public", "dolt_branches"}, + {"public", "dolt_column_diff"}, + {"public", "dolt_commit_ancestors"}, + {"public", "dolt_commit_diff_t1"}, + {"public", "dolt_commit_diff_t2"}, + {"public", "dolt_commits"}, + {"public", "dolt_conflicts"}, + {"public", "dolt_conflicts_t1"}, + {"public", "dolt_conflicts_t2"}, + {"public", "dolt_constraint_violations"}, + {"public", "dolt_constraint_violations_t1"}, + {"public", "dolt_constraint_violations_t2"}, + {"public", "dolt_diff"}, + {"public", "dolt_diff_t1"}, + {"public", "dolt_diff_t2"}, + {"public", "dolt_history_t1"}, + {"public", "dolt_history_t2"}, + {"public", "dolt_log"}, + {"public", "dolt_merge_status"}, + {"public", "dolt_remote_branches"}, + {"public", "dolt_remotes"}, + {"public", "dolt_schema_conflicts"}, + {"public", "dolt_status"}, + {"public", "dolt_tags"}, + {"public", "dolt_workspace_t1"}, + {"public", "dolt_workspace_t2"}, + {"public", "t1"}, + {"public", "t2"}, + }, + }, + { + Query: "SELECT schemaname, tablename FROM PG_catalog.pg_TABLES WHERE schemaname ='dolt' ORDER BY tablename;", + Expected: []sql.Row{ + {"dolt", "branches"}, + {"dolt", "commit_ancestors"}, + {"dolt", "commits"}, + {"dolt", "conflicts"}, + {"dolt", "constraint_violations"}, + {"dolt", "dolt_backups"}, + {"dolt", "dolt_help"}, + {"dolt", "dolt_stashes"}, + {"dolt", "log"}, + {"dolt", "remote_branches"}, + {"dolt", "remotes"}, + {"dolt", "status"}, + }, + }, }, }, }) @@ -4065,7 +4117,7 @@ func TestPgViews(t *testing.T) { func TestPgCatalogQueries(t *testing.T) { RunScripts(t, []ScriptTest{ { - Name: "sqlalchemy query", + Name: "sqlalchemy queries", Assertions: []ScriptTestAssertion{ { Query: `SELECT pg_catalog.pg_attribute.attname AS name, pg_catalog.format_type(pg_catalog.pg_attribute.atttypid, pg_catalog.pg_attribute.atttypmod) AS format_type, (SELECT pg_catalog.pg_get_expr(pg_catalog.pg_attrdef.adbin, pg_catalog.pg_attrdef.adrelid) AS pg_get_expr_1 @@ -4075,6 +4127,460 @@ FROM pg_catalog.pg_sequence WHERE pg_catalog.pg_attribute.attidentity != '' AND pg_catalog.pg_sequence.seqrelid = CAST(CAST(pg_catalog.pg_get_serial_sequence(CAST(CAST(pg_catalog.pg_attribute.attrelid AS REGCLASS) AS TEXT), pg_catalog.pg_attribute.attname) AS REGCLASS) AS OID)) AS identity_options FROM pg_catalog.pg_class LEFT OUTER JOIN pg_catalog.pg_attribute ON pg_catalog.pg_class.oid = pg_catalog.pg_attribute.attrelid AND pg_catalog.pg_attribute.attnum > 0 AND NOT pg_catalog.pg_attribute.attisdropped LEFT OUTER JOIN pg_catalog.pg_description ON pg_catalog.pg_description.objoid = pg_catalog.pg_attribute.attrelid AND pg_catalog.pg_description.objsubid = pg_catalog.pg_attribute.attnum JOIN pg_catalog.pg_namespace ON pg_catalog.pg_namespace.oid = pg_catalog.pg_class.relnamespace WHERE pg_catalog.pg_class.relkind = ANY (ARRAY['r', 'p', 'f', 'v', 'm']) AND pg_catalog.pg_table_is_visible(pg_catalog.pg_class.oid) AND pg_catalog.pg_namespace.nspname != 'pg_catalog' AND pg_catalog.pg_class.relname IN ('dolt_log') ORDER BY pg_catalog.pg_class.relname, pg_catalog.pg_attribute.attnum`, + Expected: []sql.Row{ + {"commit_hash", "text", nil, "t", "dolt_log", nil, "", nil}, + {"committer", "text", nil, "t", "dolt_log", nil, "", nil}, + {"email", "text", nil, "t", "dolt_log", nil, "", nil}, + {"date", "timestamp without time zone", nil, "t", "dolt_log", nil, "", nil}, + {"message", "text", nil, "t", "dolt_log", nil, "", nil}, + {"commit_order", "bigint", nil, "t", "dolt_log", nil, "", nil}, + }, + }, + { + Query: `SELECT pg_catalog.pg_type.typname AS name, + pg_catalog.pg_type_is_visible(pg_catalog.pg_type.oid) AS visible, + pg_catalog.pg_namespace.nspname AS schema, + lbl_agg.labels AS labels +FROM pg_catalog.pg_type +JOIN pg_catalog.pg_namespace ON pg_catalog.pg_namespace.oid = pg_catalog.pg_type.typnamespace + LEFT OUTER JOIN + (SELECT pg_catalog.pg_enum.enumtypid AS enumtypid, + array_agg(CAST(pg_catalog.pg_enum.enumlabel AS TEXT) ORDER BY pg_catalog.pg_enum.enumsortorder) + AS labels FROM pg_catalog.pg_enum GROUP BY pg_catalog.pg_enum.enumtypid) AS lbl_agg + ON pg_catalog.pg_type.oid = lbl_agg.enumtypid WHERE pg_catalog.pg_type.typtype = 'e' + ORDER BY pg_catalog.pg_namespace.nspname, pg_catalog.pg_type.typname`, + }, + { + Query: `SELECT pg_catalog.pg_attribute.attname AS name, + pg_catalog.format_type(pg_catalog.pg_attribute.atttypid, + pg_catalog.pg_attribute.atttypmod) AS format_type, + (SELECT pg_catalog.pg_get_expr(pg_catalog .pg_attrdef.adbin, pg_catalog.pg_attrdef.adrelid) AS pg_get_expr_1 + FROM pg_catalog.pg_attrdef + WHERE pg_catalog.pg_attrdef.adrelid = pg_catalog.pg_attribute.attrelid + AND pg_catalog.pg_attrdef.adnum = pg_catalog.pg_attribute.attnum + AND pg_catalog.pg_attribute.atthasdef) AS "default", + pg_catalog.pg_attribute.attnotnull AS not_null, + pg_catalog.pg_class.relname AS table_name, + pg_catalog.pg_description.description AS comment, + pg_catalog.pg_attribute.attgenerated AS generated, + (SELECT json_build_object('always', pg_catalog.pg_attribute.attidentity = 'a', + 'start', pg_catalog.pg_sequence.seqstart, + 'increment', pg_catalog.pg_sequence.seqincrement, + 'minvalue', pg_catalog.pg_sequence.seqmin, + 'maxvalue', pg_catalog.pg_sequence.seqmax, + 'cache', pg_catalog.pg_sequence.seqcache, + 'cycle', pg_catalog.pg_sequence.seqcycle) AS json_build_object_1 + FROM pg_catalog.pg_sequence + WHERE pg_catalog.pg_attribute.attidentity != '' + AND pg_catalog.pg_sequence.seqrelid = CAST(CAST(pg_catalog.pg_get_serial_sequence(CAST(CAST(pg_catalog.pg_attribute.attrelid AS REGCLASS) AS TEXT), pg_catalog.pg_attribute.attname) AS REGCLASS) AS OID) + ) AS identity_options + FROM pg_catalog.pg_class + LEFT OUTER JOIN pg_catalog.pg_attribute ON pg_catalog.pg_class.oid = pg_catalog.pg_attribute.attrelid + AND pg_catalog.pg_attribute.attnum > 0 AND NOT pg_catalog.pg_attribute.attisdropped + LEFT OUTER JOIN pg_catalog.pg_description ON pg_catalog.pg_description.objoid = pg_catalog.pg_attribute.attrelid + AND pg_catalog.pg_description.objsubid = pg_catalog.pg_attribute.attnum + JOIN pg_catalog.pg_namespace ON pg_catalog.pg_namespace.oid = pg_catalog.pg_class.relnamespace + WHERE pg_catalog.pg_class.relkind = ANY (ARRAY['r', 'p', 'f ', 'v', 'm']) + AND pg_catalog.pg_table_is_visible(pg_catalog.pg_class.oid) + AND pg_catalog.pg_namespace.nspname != 'pg_catalog' + AND pg_catalog.pg_class.relname IN ('dolt_log') + ORDER BY pg_catalog.pg_class.relname, pg_catalog.pg_attribute.attnum`, + Expected: []sql.Row{ + {"commit_hash", "text", nil, "t", "dolt_log", nil, "", nil}, + {"committer", "text", nil, "t", "dolt_log", nil, "", nil}, + {"email", "text", nil, "t", "dolt_log", nil, "", nil}, + {"date", "timestamp without time zone", nil, "t", "dolt_log", nil, "", nil}, + {"message", "text", nil, "t", "dolt_log", nil, "", nil}, + {"commit_order", "bigint", nil, "t", "dolt_log", nil, "", nil}, + }, + }, + }, + }, + }) +} + +func TestSystemTablesInPgcatalog(t *testing.T) { + RunScripts(t, []ScriptTest{ + { + Name: "pg_tables", + SetUpScript: []string{ + `CREATE SCHEMA s1;`, + `CREATE TABLE s1.t1 (pk INT primary key, v1 INT);`, + }, + // TODO: some of these dolt_ table names are wrong, see https://github.com/dolthub/doltgresql/issues/1560 + Assertions: []ScriptTestAssertion{ + { + Query: "select * from pg_catalog.pg_tables where schemaname not in ('information_schema', 'pg_catalog') order by schemaname, tablename;", + Expected: []sql.Row{ + {"dolt", "branches", "postgres", nil, "f", "f", "f", "f"}, + {"dolt", "commit_ancestors", "postgres", nil, "f", "f", "f", "f"}, + {"dolt", "commits", "postgres", nil, "f", "f", "f", "f"}, + {"dolt", "conflicts", "postgres", nil, "f", "f", "f", "f"}, + {"dolt", "constraint_violations", "postgres", nil, "f", "f", "f", "f"}, + {"dolt", "dolt_backups", "postgres", nil, "f", "f", "f", "f"}, + {"dolt", "dolt_help", "postgres", nil, "f", "f", "f", "f"}, + {"dolt", "dolt_stashes", "postgres", nil, "f", "f", "f", "f"}, + {"dolt", "log", "postgres", nil, "f", "f", "f", "f"}, + {"dolt", "remote_branches", "postgres", nil, "f", "f", "f", "f"}, + {"dolt", "remotes", "postgres", nil, "f", "f", "f", "f"}, + {"dolt", "status", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_branches", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_column_diff", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_commit_ancestors", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_commits", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_conflicts", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_constraint_violations", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_diff", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_log", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_merge_status", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_remote_branches", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_remotes", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_schema_conflicts", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_status", "postgres", nil, "f", "f", "f", "f"}, + {"public", "dolt_tags", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_branches", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_column_diff", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_commit_ancestors", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_commit_diff_t1", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_commits", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_conflicts", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_conflicts_t1", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_constraint_violations", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_constraint_violations_t1", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_diff", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_diff_t1", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_history_t1", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_log", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_merge_status", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_remote_branches", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_remotes", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_schema_conflicts", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_status", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_tags", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "dolt_workspace_t1", "postgres", nil, "f", "f", "f", "f"}, + {"s1", "t1", "postgres", nil, "t", "f", "f", "f"}, + }, + }, + }, + }, + { + Name: "pg_class", + SetUpScript: []string{ + `CREATE SCHEMA s1;`, + `CREATE TABLE s1.t1 (pk INT primary key, v1 INT);`, + }, + Assertions: []ScriptTestAssertion{ + { + // TODO: some of these dolt_ table names are wrong, see https://github.com/dolthub/doltgresql/issues/1560 + Query: `select oid, relname, relnamespace, relkind from pg_class where relnamespace not in (select oid from pg_namespace where nspname in ('information_schema', 'pg_catalog')) order by relnamespace, relname;`, + Expected: []sql.Row{ + {458530874, "dolt_branches", 2200, "r"}, + {2056815203, "dolt_column_diff", 2200, "r"}, + {1555944102, "dolt_commit_ancestors", 2200, "r"}, + {3152041833, "dolt_commits", 2200, "r"}, + {245736992, "dolt_conflicts", 2200, "r"}, + {1932298159, "dolt_constraint_violations", 2200, "r"}, + {2357712556, "dolt_diff", 2200, "r"}, + {3491847678, "dolt_log", 2200, "r"}, + {604995978, "dolt_merge_status", 2200, "r"}, + {887648921, "dolt_remote_branches", 2200, "r"}, + {341706375, "dolt_remotes", 2200, "r"}, + {3210116770, "dolt_schema_conflicts", 2200, "r"}, + {1060579466, "dolt_status", 2200, "r"}, + {1807684176, "dolt_tags", 2200, "r"}, + {1763579892, "dolt_branches", 1634633383, "r"}, + {1212681264, "dolt_column_diff", 1634633383, "r"}, + {4001633963, "dolt_commit_ancestors", 1634633383, "r"}, + {115796810, "dolt_commit_diff_t1", 1634633383, "r"}, + {3112353516, "dolt_commits", 1634633383, "r"}, + {2517735330, "dolt_conflicts", 1634633383, "r"}, + {2419641880, "dolt_conflicts_t1", 1634633383, "r"}, + {1322753784, "dolt_constraint_violations", 1634633383, "r"}, + {3390577184, "dolt_constraint_violations_t1", 1634633383, "r"}, + {649632770, "dolt_diff", 1634633383, "r"}, + {876336553, "dolt_diff_t1", 1634633383, "r"}, + {3422698383, "dolt_history_t1", 1634633383, "r"}, + {2067982358, "dolt_log", 1634633383, "r"}, + {3947121936, "dolt_merge_status", 1634633383, "r"}, + {867423409, "dolt_remote_branches", 1634633383, "r"}, + {373092098, "dolt_remotes", 1634633383, "r"}, + {225426095, "dolt_schema_conflicts", 1634633383, "r"}, + {3554775706, "dolt_status", 1634633383, "r"}, + {3246414078, "dolt_tags", 1634633383, "r"}, + {1640933374, "dolt_workspace_t1", 1634633383, "r"}, + {2849341124, "t1", 1634633383, "r"}, + {512149063, "t1_pkey", 1634633383, "i"}, + {398111247, "branches", 1882653564, "r"}, + {4126412490, "commit_ancestors", 1882653564, "r"}, + {3425483043, "commits", 1882653564, "r"}, + {1218627310, "conflicts", 1882653564, "r"}, + {1967026500, "constraint_violations", 1882653564, "r"}, + {1167248682, "dolt_backups", 1882653564, "r"}, + {629684363, "dolt_help", 1882653564, "r"}, + {1384122262, "dolt_stashes", 1882653564, "r"}, + {909123395, "log", 1882653564, "r"}, + {148630507, "remote_branches", 1882653564, "r"}, + {1670572237, "remotes", 1882653564, "r"}, + {3431637196, "status", 1882653564, "r"}, + }, + }, + }, + }, + { + Name: "pg_attribute", + SetUpScript: []string{ + `CREATE SCHEMA s1;`, + `CREATE TABLE s1.t1 (pk INT primary key, v1 INT);`, + }, + Assertions: []ScriptTestAssertion{ + { + Query: `select attrelid, attname, atttypid, attnum, attnotnull, atthasdef, attisdropped from pg_catalog.pg_attribute where attrelid in (select oid from pg_catalog.pg_class where relnamespace not in (select oid from pg_namespace where nspname in ('information_schema', 'pg_catalog'))) order by attrelid, attnum;`, + Expected: []sql.Row{ + {115796810, "to_pk", 23, 1, "f", "f", "f"}, + {115796810, "to_v1", 23, 2, "f", "f", "f"}, + {115796810, "to_commit", 25, 3, "f", "f", "f"}, + {115796810, "to_commit_date", 1114, 4, "f", "f", "f"}, + {115796810, "from_pk", 23, 5, "f", "f", "f"}, + {115796810, "from_v1", 23, 6, "f", "f", "f"}, + {115796810, "from_commit", 25, 7, "f", "f", "f"}, + {115796810, "from_commit_date", 1114, 8, "f", "f", "f"}, + {115796810, "diff_type", 25, 9, "f", "f", "f"}, + {148630507, "name", 25, 1, "t", "f", "f"}, + {148630507, "hash", 25, 2, "t", "f", "f"}, + {148630507, "latest_committer", 25, 3, "f", "f", "f"}, + {148630507, "latest_committer_email", 25, 4, "f", "f", "f"}, + {148630507, "latest_commit_date", 1114, 5, "f", "f", "f"}, + {148630507, "latest_commit_message", 25, 6, "f", "f", "f"}, + {225426095, "table_name", 25, 1, "t", "f", "f"}, + {225426095, "base_schema", 25, 2, "t", "f", "f"}, + {225426095, "our_schema", 25, 3, "t", "f", "f"}, + {225426095, "their_schema", 25, 4, "t", "f", "f"}, + {225426095, "description", 25, 5, "t", "f", "f"}, + {245736992, "table", 25, 1, "t", "f", "f"}, + {245736992, "num_conflicts", 20, 2, "t", "f", "f"}, + {341706375, "name", 25, 1, "t", "f", "f"}, + {341706375, "url", 25, 2, "t", "f", "f"}, + {341706375, "fetch_specs", 114, 3, "f", "f", "f"}, + {341706375, "params", 114, 4, "f", "f", "f"}, + {373092098, "name", 25, 1, "t", "f", "f"}, + {373092098, "url", 25, 2, "t", "f", "f"}, + {373092098, "fetch_specs", 114, 3, "f", "f", "f"}, + {373092098, "params", 114, 4, "f", "f", "f"}, + {398111247, "name", 25, 1, "t", "f", "f"}, + {398111247, "hash", 25, 2, "t", "f", "f"}, + {398111247, "latest_committer", 25, 3, "f", "f", "f"}, + {398111247, "latest_committer_email", 25, 4, "f", "f", "f"}, + {398111247, "latest_commit_date", 1114, 5, "f", "f", "f"}, + {398111247, "latest_commit_message", 25, 6, "f", "f", "f"}, + {398111247, "remote", 25, 7, "f", "f", "f"}, + {398111247, "branch", 25, 8, "f", "f", "f"}, + {398111247, "dirty", 16, 9, "f", "f", "f"}, + {458530874, "name", 25, 1, "t", "f", "f"}, + {458530874, "hash", 25, 2, "t", "f", "f"}, + {458530874, "latest_committer", 25, 3, "f", "f", "f"}, + {458530874, "latest_committer_email", 25, 4, "f", "f", "f"}, + {458530874, "latest_commit_date", 1114, 5, "f", "f", "f"}, + {458530874, "latest_commit_message", 25, 6, "f", "f", "f"}, + {458530874, "remote", 25, 7, "f", "f", "f"}, + {458530874, "branch", 25, 8, "f", "f", "f"}, + {458530874, "dirty", 16, 9, "f", "f", "f"}, + {604995978, "is_merging", 16, 1, "t", "f", "f"}, + {604995978, "source", 25, 2, "f", "f", "f"}, + {604995978, "source_commit", 25, 3, "f", "f", "f"}, + {604995978, "target", 25, 4, "f", "f", "f"}, + {604995978, "unmerged_tables", 25, 5, "f", "f", "f"}, + {629684363, "name", 25, 1, "t", "f", "f"}, + {629684363, "type", 21, 2, "t", "f", "f"}, + {629684363, "synopsis", 25, 3, "t", "f", "f"}, + {629684363, "short_description", 25, 4, "t", "f", "f"}, + {629684363, "long_description", 25, 5, "t", "f", "f"}, + {629684363, "arguments", 114, 6, "t", "f", "f"}, + {649632770, "commit_hash", 25, 1, "t", "f", "f"}, + {649632770, "table_name", 25, 2, "t", "f", "f"}, + {649632770, "committer", 25, 3, "t", "f", "f"}, + {649632770, "email", 25, 4, "t", "f", "f"}, + {649632770, "date", 1114, 5, "t", "f", "f"}, + {649632770, "message", 25, 6, "t", "f", "f"}, + {649632770, "data_change", 16, 7, "t", "f", "f"}, + {649632770, "schema_change", 16, 8, "t", "f", "f"}, + {867423409, "name", 25, 1, "t", "f", "f"}, + {867423409, "hash", 25, 2, "t", "f", "f"}, + {867423409, "latest_committer", 25, 3, "f", "f", "f"}, + {867423409, "latest_committer_email", 25, 4, "f", "f", "f"}, + {867423409, "latest_commit_date", 1114, 5, "f", "f", "f"}, + {867423409, "latest_commit_message", 25, 6, "f", "f", "f"}, + {876336553, "to_pk", 23, 1, "f", "f", "f"}, + {876336553, "to_v1", 23, 2, "f", "f", "f"}, + {876336553, "to_commit", 25, 3, "f", "f", "f"}, + {876336553, "to_commit_date", 1114, 4, "f", "f", "f"}, + {876336553, "from_pk", 23, 5, "f", "f", "f"}, + {876336553, "from_v1", 23, 6, "f", "f", "f"}, + {876336553, "from_commit", 25, 7, "f", "f", "f"}, + {876336553, "from_commit_date", 1114, 8, "f", "f", "f"}, + {876336553, "diff_type", 25, 9, "f", "f", "f"}, + {887648921, "name", 25, 1, "t", "f", "f"}, + {887648921, "hash", 25, 2, "t", "f", "f"}, + {887648921, "latest_committer", 25, 3, "f", "f", "f"}, + {887648921, "latest_committer_email", 25, 4, "f", "f", "f"}, + {887648921, "latest_commit_date", 1114, 5, "f", "f", "f"}, + {887648921, "latest_commit_message", 25, 6, "f", "f", "f"}, + {909123395, "commit_hash", 25, 1, "t", "f", "f"}, + {909123395, "committer", 25, 2, "t", "f", "f"}, + {909123395, "email", 25, 3, "t", "f", "f"}, + {909123395, "date", 1114, 4, "t", "f", "f"}, + {909123395, "message", 25, 5, "t", "f", "f"}, + {909123395, "commit_order", 20, 6, "t", "f", "f"}, + {1060579466, "table_name", 25, 1, "t", "f", "f"}, + {1060579466, "staged", 16, 2, "t", "f", "f"}, + {1060579466, "status", 25, 3, "t", "f", "f"}, + {1167248682, "name", 25, 1, "t", "f", "f"}, + {1167248682, "url", 25, 2, "t", "f", "f"}, + {1212681264, "commit_hash", 25, 1, "t", "f", "f"}, + {1212681264, "table_name", 25, 2, "t", "f", "f"}, + {1212681264, "column_name", 25, 3, "t", "f", "f"}, + {1212681264, "committer", 25, 4, "t", "f", "f"}, + {1212681264, "email", 25, 5, "t", "f", "f"}, + {1212681264, "date", 1114, 6, "t", "f", "f"}, + {1212681264, "message", 25, 7, "t", "f", "f"}, + {1212681264, "diff_type", 25, 8, "t", "f", "f"}, + {1218627310, "table", 25, 1, "t", "f", "f"}, + {1218627310, "num_conflicts", 20, 2, "t", "f", "f"}, + {1322753784, "table", 25, 1, "t", "f", "f"}, + {1322753784, "num_violations", 20, 2, "t", "f", "f"}, + {1384122262, "name", 25, 1, "t", "f", "f"}, + {1384122262, "stash_id", 25, 2, "t", "f", "f"}, + {1384122262, "branch", 25, 3, "t", "f", "f"}, + {1384122262, "hash", 25, 4, "t", "f", "f"}, + {1384122262, "commit_message", 25, 5, "f", "f", "f"}, + {1555944102, "commit_hash", 25, 1, "t", "f", "f"}, + {1555944102, "parent_hash", 25, 2, "t", "f", "f"}, + {1555944102, "parent_index", 23, 3, "t", "f", "f"}, + {1640933374, "id", 20, 1, "t", "f", "f"}, + {1640933374, "staged", 16, 2, "t", "f", "f"}, + {1640933374, "diff_type", 25, 3, "t", "f", "f"}, + {1640933374, "to_pk", 23, 4, "f", "f", "f"}, + {1640933374, "to_v1", 23, 5, "f", "f", "f"}, + {1640933374, "from_pk", 23, 6, "f", "f", "f"}, + {1640933374, "from_v1", 23, 7, "f", "f", "f"}, + {1670572237, "name", 25, 1, "t", "f", "f"}, + {1670572237, "url", 25, 2, "t", "f", "f"}, + {1670572237, "fetch_specs", 114, 3, "f", "f", "f"}, + {1670572237, "params", 114, 4, "f", "f", "f"}, + {1763579892, "name", 25, 1, "t", "f", "f"}, + {1763579892, "hash", 25, 2, "t", "f", "f"}, + {1763579892, "latest_committer", 25, 3, "f", "f", "f"}, + {1763579892, "latest_committer_email", 25, 4, "f", "f", "f"}, + {1763579892, "latest_commit_date", 1114, 5, "f", "f", "f"}, + {1763579892, "latest_commit_message", 25, 6, "f", "f", "f"}, + {1763579892, "remote", 25, 7, "f", "f", "f"}, + {1763579892, "branch", 25, 8, "f", "f", "f"}, + {1763579892, "dirty", 16, 9, "f", "f", "f"}, + {1807684176, "tag_name", 25, 1, "t", "f", "f"}, + {1807684176, "tag_hash", 25, 2, "t", "f", "f"}, + {1807684176, "tagger", 25, 3, "t", "f", "f"}, + {1807684176, "email", 25, 4, "t", "f", "f"}, + {1807684176, "date", 1114, 5, "t", "f", "f"}, + {1807684176, "message", 25, 6, "t", "f", "f"}, + {1932298159, "table", 25, 1, "t", "f", "f"}, + {1932298159, "num_violations", 20, 2, "t", "f", "f"}, + {1967026500, "table", 25, 1, "t", "f", "f"}, + {1967026500, "num_violations", 20, 2, "t", "f", "f"}, + {2056815203, "commit_hash", 25, 1, "t", "f", "f"}, + {2056815203, "table_name", 25, 2, "t", "f", "f"}, + {2056815203, "column_name", 25, 3, "t", "f", "f"}, + {2056815203, "committer", 25, 4, "t", "f", "f"}, + {2056815203, "email", 25, 5, "t", "f", "f"}, + {2056815203, "date", 1114, 6, "t", "f", "f"}, + {2056815203, "message", 25, 7, "t", "f", "f"}, + {2056815203, "diff_type", 25, 8, "t", "f", "f"}, + {2067982358, "commit_hash", 25, 1, "t", "f", "f"}, + {2067982358, "committer", 25, 2, "t", "f", "f"}, + {2067982358, "email", 25, 3, "t", "f", "f"}, + {2067982358, "date", 1114, 4, "t", "f", "f"}, + {2067982358, "message", 25, 5, "t", "f", "f"}, + {2067982358, "commit_order", 20, 6, "t", "f", "f"}, + {2357712556, "commit_hash", 25, 1, "t", "f", "f"}, + {2357712556, "table_name", 25, 2, "t", "f", "f"}, + {2357712556, "committer", 25, 3, "t", "f", "f"}, + {2357712556, "email", 25, 4, "t", "f", "f"}, + {2357712556, "date", 1114, 5, "t", "f", "f"}, + {2357712556, "message", 25, 6, "t", "f", "f"}, + {2357712556, "data_change", 16, 7, "t", "f", "f"}, + {2357712556, "schema_change", 16, 8, "t", "f", "f"}, + {2419641880, "from_root_ish", 25, 1, "f", "f", "f"}, + {2419641880, "base_pk", 23, 2, "f", "f", "f"}, + {2419641880, "base_v1", 23, 3, "f", "f", "f"}, + {2419641880, "our_pk", 23, 4, "t", "f", "f"}, + {2419641880, "our_v1", 23, 5, "f", "f", "f"}, + {2419641880, "our_diff_type", 25, 6, "f", "f", "f"}, + {2419641880, "their_pk", 23, 7, "f", "f", "f"}, + {2419641880, "their_v1", 23, 8, "f", "f", "f"}, + {2419641880, "their_diff_type", 25, 9, "f", "f", "f"}, + {2419641880, "dolt_conflict_id", 25, 10, "f", "f", "f"}, + {2517735330, "table", 25, 1, "t", "f", "f"}, + {2517735330, "num_conflicts", 20, 2, "t", "f", "f"}, + {2849341124, "pk", 23, 1, "t", "f", "f"}, + {2849341124, "v1", 23, 2, "f", "f", "f"}, + {3112353516, "commit_hash", 25, 1, "t", "f", "f"}, + {3112353516, "committer", 25, 2, "t", "f", "f"}, + {3112353516, "email", 25, 3, "t", "f", "f"}, + {3112353516, "date", 1114, 4, "t", "f", "f"}, + {3112353516, "message", 25, 5, "t", "f", "f"}, + {3152041833, "commit_hash", 25, 1, "t", "f", "f"}, + {3152041833, "committer", 25, 2, "t", "f", "f"}, + {3152041833, "email", 25, 3, "t", "f", "f"}, + {3152041833, "date", 1114, 4, "t", "f", "f"}, + {3152041833, "message", 25, 5, "t", "f", "f"}, + {3210116770, "table_name", 25, 1, "t", "f", "f"}, + {3210116770, "base_schema", 25, 2, "t", "f", "f"}, + {3210116770, "our_schema", 25, 3, "t", "f", "f"}, + {3210116770, "their_schema", 25, 4, "t", "f", "f"}, + {3210116770, "description", 25, 5, "t", "f", "f"}, + {3246414078, "tag_name", 25, 1, "t", "f", "f"}, + {3246414078, "tag_hash", 25, 2, "t", "f", "f"}, + {3246414078, "tagger", 25, 3, "t", "f", "f"}, + {3246414078, "email", 25, 4, "t", "f", "f"}, + {3246414078, "date", 1114, 5, "t", "f", "f"}, + {3246414078, "message", 25, 6, "t", "f", "f"}, + {3390577184, "from_root_ish", 25, 1, "f", "f", "f"}, + {3390577184, "violation_type", 1043, 2, "t", "f", "f"}, + {3390577184, "pk", 23, 3, "t", "f", "f"}, + {3390577184, "v1", 23, 4, "f", "f", "f"}, + {3390577184, "violation_info", 114, 5, "f", "f", "f"}, + {3422698383, "pk", 23, 1, "t", "f", "f"}, + {3422698383, "v1", 23, 2, "f", "f", "f"}, + {3422698383, "commit_hash", 25, 3, "t", "f", "f"}, + {3422698383, "committer", 25, 4, "t", "f", "f"}, + {3422698383, "commit_date", 1114, 5, "t", "f", "f"}, + {3425483043, "commit_hash", 25, 1, "t", "f", "f"}, + {3425483043, "committer", 25, 2, "t", "f", "f"}, + {3425483043, "email", 25, 3, "t", "f", "f"}, + {3425483043, "date", 1114, 4, "t", "f", "f"}, + {3425483043, "message", 25, 5, "t", "f", "f"}, + {3431637196, "table_name", 25, 1, "t", "f", "f"}, + {3431637196, "staged", 16, 2, "t", "f", "f"}, + {3431637196, "status", 25, 3, "t", "f", "f"}, + {3491847678, "commit_hash", 25, 1, "t", "f", "f"}, + {3491847678, "committer", 25, 2, "t", "f", "f"}, + {3491847678, "email", 25, 3, "t", "f", "f"}, + {3491847678, "date", 1114, 4, "t", "f", "f"}, + {3491847678, "message", 25, 5, "t", "f", "f"}, + {3491847678, "commit_order", 20, 6, "t", "f", "f"}, + {3554775706, "table_name", 25, 1, "t", "f", "f"}, + {3554775706, "staged", 16, 2, "t", "f", "f"}, + {3554775706, "status", 25, 3, "t", "f", "f"}, + {3947121936, "is_merging", 16, 1, "t", "f", "f"}, + {3947121936, "source", 25, 2, "f", "f", "f"}, + {3947121936, "source_commit", 25, 3, "f", "f", "f"}, + {3947121936, "target", 25, 4, "f", "f", "f"}, + {3947121936, "unmerged_tables", 25, 5, "f", "f", "f"}, + {4001633963, "commit_hash", 25, 1, "t", "f", "f"}, + {4001633963, "parent_hash", 25, 2, "t", "f", "f"}, + {4001633963, "parent_index", 23, 3, "t", "f", "f"}, + {4126412490, "commit_hash", 25, 1, "t", "f", "f"}, + {4126412490, "parent_hash", 25, 2, "t", "f", "f"}, + {4126412490, "parent_index", 23, 3, "t", "f", "f"}, + }, }, }, }, diff --git a/testing/go/prepared_statement_test.go b/testing/go/prepared_statement_test.go index 4bbf03fbb8..3af5d8f03b 100755 --- a/testing/go/prepared_statement_test.go +++ b/testing/go/prepared_statement_test.go @@ -468,7 +468,7 @@ var pgCatalogTests = []ScriptTest{ { Query: `SELECT * FROM "pg_catalog"."pg_tables" WHERE tablename=$1;`, BindVars: []any{"testing"}, - Expected: []sql.Row{{"public", "testing", "", "", "t", "f", "f", "f"}}, + Expected: []sql.Row{{"public", "testing", "postgres", nil, "t", "f", "f", "f"}}, }, { Query: `SELECT count(*) FROM "pg_catalog"."pg_tables" WHERE schemaname=$1;`, @@ -488,12 +488,12 @@ var pgCatalogTests = []ScriptTest{ Query: `SELECT c.oid,d.description,pg_catalog.pg_get_expr(c.relpartbound, c.oid) as partition_expr, pg_catalog.pg_get_partkeydef(c.oid) as partition_key FROM pg_catalog.pg_class c LEFT OUTER JOIN pg_catalog.pg_description d ON d.objoid=c.oid AND d.objsubid=0 AND d.classoid='pg_class'::regclass -WHERE c.relnamespace=$1 AND c.relkind not in ('i','I','c');`, +WHERE c.relnamespace=$1 AND c.relkind not in ('i','I','c') and c.oid not in (select oid from pg_catalog.pg_class where left(relname, 5) = 'dolt_');`, BindVars: []any{2638679668}, Expected: []sql.Row{{1712283605, nil, nil, ""}}, }, { - Query: `select c.oid,pg_catalog.pg_total_relation_size(c.oid) as total_rel_size,pg_catalog.pg_relation_size(c.oid) as rel_size FROM pg_class c WHERE c.relnamespace=$1;`, + Query: `select c.oid,pg_catalog.pg_total_relation_size(c.oid) as total_rel_size,pg_catalog.pg_relation_size(c.oid) as rel_size FROM pg_class c WHERE c.relnamespace=$1 and c.oid not in (select oid from pg_catalog.pg_class where left(relname, 5) = 'dolt_');`, BindVars: []any{2638679668}, Expected: []sql.Row{{444447634, 0, 0}, {1712283605, 0, 0}}, }, diff --git a/testing/go/regression/tool/replay.go b/testing/go/regression/tool/replay.go index dea2665557..456d99b9a6 100644 --- a/testing/go/regression/tool/replay.go +++ b/testing/go/regression/tool/replay.go @@ -40,6 +40,8 @@ type ReplayOptions struct { func Replay(options ReplayOptions) (*ReplayTracker, error) { tracker := NewReplayTracker(options.File) reader := NewMessageReader(FilterMessages(options.Messages)) + + t := time.Now() fmt.Println("-------------------- ", tracker.File, " --------------------") ListenerLoop: for !reader.IsEmpty() { @@ -671,5 +673,8 @@ ListenerLoop: } connection.Close() } + + elapsed := time.Since(t) + fmt.Printf("-------------------- %s done in %fs --------------------", tracker.File, elapsed.Seconds()) return tracker, nil } diff --git a/testing/go/schemas_test.go b/testing/go/schemas_test.go index 552a0de556..82d585d6dc 100755 --- a/testing/go/schemas_test.go +++ b/testing/go/schemas_test.go @@ -754,7 +754,7 @@ var SchemaTests = []ScriptTest{ Expected: []sql.Row{}, }, { - Query: "SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';", + Query: "SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE schemaname not in ('pg_catalog', 'information_schema', 'dolt') and left(tablename, 5) <> 'dolt_';", Expected: []sql.Row{ {"myschema", "mytbl"}, }, @@ -828,7 +828,7 @@ var SchemaTests = []ScriptTest{ }, }, { - Query: "SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';", + Query: "SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE schemaname not in ('pg_catalog', 'information_schema', 'dolt') and left(tablename, 5) <> 'dolt_';", Expected: []sql.Row{ {"myschema", "mytbl"}, {"newbranchschema", "mytbl2"},