Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions postgres/parser/sem/tree/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,9 @@ func AsStringWithFQNames(n NodeFormatter, ann *Annotations) string {
return ctx.CloseAndGetString()
}

// AsString pretty prints a node to a string.
// AsString pretty prints a node to a string, with unquoted identifiers.
func AsString(n NodeFormatter) string {
return AsStringWithFlags(n, FmtSimple)
return AsStringWithFlags(n, FmtSimple|FmtBareIdentifiers)
}

// ErrString pretty prints a node to a string. Identifiers are not quoted.
Expand Down
4 changes: 4 additions & 0 deletions server/analyzer/validate_create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ func schToColMap(sch sql.Schema) map[string]*sql.Column {
func validateIndex(ctx *sql.Context, colMap map[string]*sql.Column, idxDef *sql.IndexDef) error {
seenCols := make(map[string]struct{})
for _, idxCol := range idxDef.Columns {
if idxCol.Expression != nil {
continue
}

schCol, exists := colMap[strings.ToLower(idxCol.Name)]
if !exists {
return sql.ErrKeyColumnDoesNotExist.New(idxCol.Name)
Expand Down
4 changes: 0 additions & 4 deletions server/ast/index_elem.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ import (
func nodeIndexElemList(ctx *Context, node tree.IndexElemList) ([]*vitess.IndexField, error) {
vitessIndexColumns := make([]*vitess.IndexField, 0, len(node))
for _, inputColumn := range node {
if inputColumn.Expr != nil {
return nil, errors.Errorf("expression index attribute is not yet supported")
}

if inputColumn.Collation != "" {
logrus.Warn("index attribute collation is not yet supported, ignoring")
}
Expand Down
3 changes: 3 additions & 0 deletions server/tables/information_schema/columns_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ func getRowsFromTable(ctx *sql.Context, db information_schema.DbWithNames, t sql

tblName := t.Name()
for i, col := range information_schema.SchemaForTable(t, db.Database, allColsWithDefaultValue) {
if col.HiddenSystem {
continue
}
r := getRowFromColumn(ctx, i, col, db.CatalogName, db.SchemaName, tblName)
if r != nil {
rows = append(rows, r)
Expand Down
242 changes: 121 additions & 121 deletions testing/generation/command_docs/output/create_index_test.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions testing/go/enginetest/doltgres_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,12 @@ func TestIndexes(t *testing.T) {
enginetest.TestIndexes(t, harness)
}

func TestIndexedExpressions(t *testing.T) {
harness := newDoltgresServerHarness(t)
defer harness.Close()
enginetest.TestIndexedExpressions(t, harness)
}

func TestIndexPrefix(t *testing.T) {
t.Skip()
harness := newDoltgresServerHarness(t)
Expand Down
24 changes: 21 additions & 3 deletions testing/go/enginetest/doltgres_harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,23 @@ var defaultSkippedQueries = []string{
"show create table fk_tbl", // we create an extra key for the FK that vanilla gms does not
"show indexes from", // we create / expose extra indexes (for foreign keys)
"show global variables like", // we set extra variables
"show columns from", // MySQL SHOW variant with no PostgreSQL equivalent
"show extended columns from", // MySQL SHOW variant with no PostgreSQL equivalent

// unsupported doltgres syntax
// " WITH ",
// " OVER ",
// string functions are broken due to incompatible types
"HEX(",
"TO_BASE64(",
// MySQL-specific functions not supported in doltgresql
"json_unquote", // MySQL JSON function
"year(", // YEAR() functional index hits a type-incompatibility in doltgresql

// MySQL-specific operators and syntax not supported in PostgreSQL
"<=>", // null-safe equality (PostgreSQL uses IS NOT DISTINCT FROM)
"modify column", // MySQL ALTER TABLE MODIFY COLUMN syntax
"column first", // MySQL ADD COLUMN ... FIRST positioning
}

// Setup sets the setup scripts for this DoltHarness's engine
Expand Down Expand Up @@ -729,6 +740,10 @@ func getDmlResult(rows pgx.Rows, query string) (sql.Row, bool) {
return sql.NewRow(gmstypes.NewOkResult(0)), true
case strings.HasPrefix(tag.String(), "ALTER TABLE"):
return sql.NewRow(gmstypes.NewOkResult(0)), true
case strings.HasPrefix(tag.String(), "CREATE INDEX"):
return sql.NewRow(gmstypes.NewOkResult(0)), true
case strings.HasPrefix(tag.String(), "DROP INDEX"):
return sql.NewRow(gmstypes.NewOkResult(0)), true
case strings.HasPrefix(tag.String(), "TRUNCATE"):
return sql.NewRow(gmstypes.NewOkResult(0)), true
case strings.HasPrefix(tag.String(), "SET"):
Expand Down Expand Up @@ -814,12 +829,15 @@ func unwrapResultColumn(v any) (any, error) {
}
}

// IsServerBacked implements enginetest.ServerBackedEngine, marking DoltgresQueryEngine
// as a server-backed engine so that plan-inspection checks (evalIndexTest, etc.) are
// skipped, matching the behavior of GMS's own ServerQueryEngine.
func (d *DoltgresQueryEngine) IsServerBacked() bool { return true }

func (d *DoltgresQueryEngine) EngineAnalyzer() *analyzer.Analyzer {
// TODO: this is a shim to get simple tests to work, we need to restructure the tests to not require access to
// an analyzer
catalog := &analyzer.Catalog{}
catalog.AuthHandler = sql.GetAuthorizationHandlerFactory().CreateHandler(catalog)

catalog := analyzer.NewCatalog(nil, sql.EngineOverrides{})
return &analyzer.Analyzer{
Catalog: catalog,
}
Expand Down
4 changes: 0 additions & 4 deletions testing/go/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1076,10 +1076,6 @@ func TestBasicIndexing(t *testing.T) {
// ignored warning-generating unsupported options
Query: "CREATE INDEX v1_idx ON test(v1 varchar_pattern_ops) WITH (storage_opt1 = foo) TABLESPACE tablespace_name;",
},
{
Query: "CREATE INDEX v1_idx2 ON test( (concat(v1, v1)) ) ;",
ExpectedErr: "not yet supported",
},
{
Query: "CREATE INDEX v1_idx2 ON test using hash (v1);",
ExpectedErr: "not yet supported",
Expand Down
Loading