Skip to content
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ require (
github.com/antchfx/xpath v1.3.3
github.com/cockroachdb/apd/v3 v3.2.3
github.com/cockroachdb/errors v1.7.5
github.com/dolthub/dolt/go v0.40.5-0.20261201231126-dbaa34826372
github.com/dolthub/dolt/go v0.40.5-0.20261202002828-b78236fb3132
github.com/dolthub/eventsapi_schema v0.0.0-20261119125135-6b30707d614f
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.20.1-0.20261201004615-a93903f58570
github.com/dolthub/go-mysql-server v0.20.1-0.20261201232317-e87baa9b8bd6
github.com/dolthub/pg_query_go/v6 v6.0.0-20260922094746-ae7577e21dfe
github.com/dolthub/sqllogictest/go v0.0.0-20260624223518-788480b24166
github.com/dolthub/vitess v0.0.0-20261125220612-ea2777f35f5b
github.com/dolthub/vitess v0.0.0-20261201205907-4b5932442d40
github.com/fatih/color v1.13.0
github.com/go-sql-driver/mysql v1.9.3
github.com/goccy/go-json v0.10.2
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12 h1:I
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12/go.mod h1:rN7X8BHwkjPcfMQQ2QTAq/xM3leUSGLfb+1Js7Y6TVo=
github.com/dolthub/dolt-mcp v0.3.9-0.20261201070427-ef87bdb213e1 h1:R8jC4d0JrX6friXJN3Ci8hsWEMCsLeKbk9x+7Sf/9lU=
github.com/dolthub/dolt-mcp v0.3.9-0.20261201070427-ef87bdb213e1/go.mod h1:h2LUUyt64a8YHeoOAKPnDS88u8XWXHEXZyVL1WnMEbU=
github.com/dolthub/dolt/go v0.40.5-0.20261201231126-dbaa34826372 h1:2B+NZM0RIgNoVt34y8muexIp+SDMMh4nTqzBqywF6NU=
github.com/dolthub/dolt/go v0.40.5-0.20261201231126-dbaa34826372/go.mod h1:hwY1NSWazGmeSuqHcVFBHYQKVPLXJ1siHi42Q0yU4MA=
github.com/dolthub/dolt/go v0.40.5-0.20261202002828-b78236fb3132 h1:54Iwx3pnpCFiPHxTxSFDRqA93271QTIsgI32b+bUB3U=
github.com/dolthub/dolt/go v0.40.5-0.20261202002828-b78236fb3132/go.mod h1:AulJsnBmj+s687b0rIQhAGDwdeGoPyBAWe2TB/4UAFk=
github.com/dolthub/eventsapi_schema v0.0.0-20261119125135-6b30707d614f h1:RrpwiZGxoZBFJFn8JuHHPJtGsugf2yWL2MMlNoTp0AI=
github.com/dolthub/eventsapi_schema v0.0.0-20261119125135-6b30707d614f/go.mod h1:SSLraQS/jGLYFgff3vuZ+JbVUct6vyEeMzjLBqWqoyM=
github.com/dolthub/file-locks v0.1.2 h1:D0eaII+636hkk7uJu++qaUT/XqDtRTQArWBQ6vEHfJU=
Expand All @@ -258,8 +258,8 @@ github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1G
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2/go.mod h1:mIEZOHnFx4ZMQeawhw9rhsj+0zwQj7adVsnBX7t+eKY=
github.com/dolthub/go-icu-regex v0.0.0-20260610153742-72563bc7ca83 h1:FEMjCGEroDnY/BXyAffVZxUpXhP2GpoUJyyq5KaLn8c=
github.com/dolthub/go-icu-regex v0.0.0-20260610153742-72563bc7ca83/go.mod h1:F3cnm+vMRK1HaU6+rNqQrOCyR03HHhR1GWG2gnPOqaE=
github.com/dolthub/go-mysql-server v0.20.1-0.20261201004615-a93903f58570 h1:fhKlV+XK8VAe05x6lEVAxOIEYi6mfXhh+HR3XD8w0cI=
github.com/dolthub/go-mysql-server v0.20.1-0.20261201004615-a93903f58570/go.mod h1:LeA939KZGxVGPZ/9+JDnYL8FPjlkK4tAZtTyhpZc4bo=
github.com/dolthub/go-mysql-server v0.20.1-0.20261201232317-e87baa9b8bd6 h1:Q5sAGBmziB3RnRDNLyQjm8E8yoVZIQ6JSd/p+dn5yIw=
github.com/dolthub/go-mysql-server v0.20.1-0.20261201232317-e87baa9b8bd6/go.mod h1:2PbY676fZrKtzIQNFX6VJDRAihJ9BxPoQAIQxQVqgBs=
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-20260414231531-5f031e3e9037 h1:oIW9HwuWrhxv+4HZxA+QQSKHLqWFyXZ2FmNjUYwkdiM=
Expand All @@ -270,8 +270,8 @@ github.com/dolthub/pg_query_go/v6 v6.0.0-20260922094746-ae7577e21dfe h1:5QQHZM+Z
github.com/dolthub/pg_query_go/v6 v6.0.0-20260922094746-ae7577e21dfe/go.mod h1:qnrZP3/1slFl2Bq5yw38HLOsArZareGwdpEceriblLc=
github.com/dolthub/sqllogictest/go v0.0.0-20260624223518-788480b24166 h1:fdexJBpLDyAGnFbviZYfZ0jhLMnbTWTh39CyQ1EhA28=
github.com/dolthub/sqllogictest/go v0.0.0-20260624223518-788480b24166/go.mod h1:e/FIZVvT2IR53HBCAo41NjqgtEnjMJGKca3Y/dAmZaA=
github.com/dolthub/vitess v0.0.0-20261125220612-ea2777f35f5b h1:l35e6fodACWuexlGQf11E6iJf/GeM7ZMVZuX0ywY+k0=
github.com/dolthub/vitess v0.0.0-20261125220612-ea2777f35f5b/go.mod h1:5SVEJgAhw5nnQUFnGgKI1Svqes1Mw+zKUsalyxmOuG0=
github.com/dolthub/vitess v0.0.0-20261201205907-4b5932442d40 h1:1mz96txoUCjNPY4vsJ0nYOr16hl09FmjoVdcUAVokLg=
github.com/dolthub/vitess v0.0.0-20261201205907-4b5932442d40/go.mod h1:5SVEJgAhw5nnQUFnGgKI1Svqes1Mw+zKUsalyxmOuG0=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
Expand Down
17 changes: 17 additions & 0 deletions postgres/parser/parser/sql/sql_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,23 @@ func (p PostgresFormatter) FormatExpression(ctx *sql.Context, expr sql.Expressio
return p.formatExpression(ctx, expr)
}

// FormatColumnDefault implements sql.SchemaFormatter.
func (p PostgresFormatter) FormatColumnDefault(ctx *sql.Context, def *sql.ColumnDefaultValue) (string, bool) {
if def == nil {
return "", false
}

if !def.IsLiteral() {
if def.IsParenthesized() {
return p.FormatExpression(ctx, def.Expr), true
}

return p.FormatExpression(ctx, def), true
}

return sql.DefaultMySQLSchemaFormatter.FormatColumnDefault(ctx, def)
}

func (p PostgresFormatter) QuoteIdentifier(identifier string) string {
return fmt.Sprintf(`"%s"`, strings.ReplaceAll(identifier, `"`, `""`))
}
Expand Down
1 change: 1 addition & 0 deletions server/connection_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (h *ConnectionHandler) handleCopyTo(copyTo *node.CopyTo) (err error) {

// Build and analyze the plan for the SELECT statement underlying this COPY TO statement.
builder := planbuilder.New(sqlCtx, h.doltgresHandler.e.Analyzer.Catalog, nil)
builder.SetSubqueryEvaluator(h.doltgresHandler.e.Analyzer.EvalSubquery)
boundNode, flags, err := builder.BindOnly(copyTo.SelectStub, "", nil)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions server/connection_cursors.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (h *ConnectionHandler) declareCursor(declare *node.DeclareCursor, query Con
return pgerror.Newf(pgcode.DuplicateCursor, `cursor "%s" already exists`, declare.Name)
}
builder := planbuilder.New(sqlCtx, h.doltgresHandler.e.Analyzer.Catalog, nil)
builder.SetSubqueryEvaluator(h.doltgresHandler.e.Analyzer.EvalSubquery)
if declare.Bindings != nil {
builder.SetBindings(declare.Bindings)
}
Expand Down
15 changes: 15 additions & 0 deletions server/expression/in_subquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,26 @@ func (in *InSubquery) NewJoinFilter(ctx *sql.Context, left, right sql.Expression
return nil, false, nil
}

if _, ok := left.Type(ctx).(*pgtypes.DoltgresType); !ok {
left = NewGMSCast(left)
}

if _, ok := right.Type(ctx).(*pgtypes.DoltgresType); !ok {
right = NewGMSCast(right)
}

// If we can't resolve an equality operator for these operands, then we leave the expression as-is.
filter, err := NewBinaryOperator(framework.Operator_BinaryEqual).WithChildren(ctx, left, right)
if err != nil {
return nil, false, nil
}

if binOp, ok := filter.(*BinaryOperator); ok {
if cf, ok := binOp.compiledFunc.(*framework.CompiledFunction); ok && cf.StashedError() != nil {
return nil, false, nil
}
}

return filter, true, nil
}

Expand Down
5 changes: 4 additions & 1 deletion server/tables/information_schema/columns_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ func getRowFromColumn(ctx *sql.Context, curOrdPos int, col *sql.Column, catName,
if err != nil {
return nil, err
}
columnDefault := information_schema.GetColumnDefault(ctx, displayedDefault)
var columnDefault interface{}
if formatted, ok := sql.DefaultMySQLSchemaFormatter.FormatColumnDefault(ctx, displayedDefault); ok {
columnDefault = formatted
}
if columnDefault != nil && col.Default.IsLiteral() {
columnType, _ := col.Type.(*pgtypes.DoltgresType)
var err error
Expand Down
51 changes: 49 additions & 2 deletions testing/go/dolt_tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
},
Assertions: []ScriptTestAssertion{
{
Skip: true,
Query: `SELECT to_id FROM dolt_commit_diff_bug6
WHERE to_commit = (SELECT commit_hash FROM dolt.log ORDER BY date DESC LIMIT 1)
AND from_commit = (SELECT commit_hash FROM dolt.log ORDER BY date DESC OFFSET 1 LIMIT 1);`,
Expand All @@ -1613,10 +1612,58 @@ WHERE to_commit = (SELECT commit_hash FROM dolt.log ORDER BY date DESC LIMIT 1)
{
// workaround: use hashof
Query: `SELECT to_id FROM dolt_commit_diff_bug6
WHERE to_commit = dolt_hashof('HEAD')
WHERE to_commit = dolt_hashof('HEAD')
AND from_commit = dolt_hashof('HEAD~');`,
Expected: []sql.Row{{1}},
},
{
Query: `SELECT to_id FROM DOLT_DIFF(
(SELECT commit_hash FROM dolt.log ORDER BY date DESC OFFSET 1 LIMIT 1),
(SELECT commit_hash FROM dolt.log ORDER BY date DESC LIMIT 1),
'bug6');`,
Expected: []sql.Row{{1}},
},
{
Query: `SELECT to_id FROM DOLT_DIFF(
(SELECT commit_hash FROM dolt.log WHERE NOW() IS NOT NULL ORDER BY date DESC OFFSET 1 LIMIT 1),
(SELECT commit_hash FROM dolt.log WHERE NOW() IS NOT NULL ORDER BY date DESC LIMIT 1),
'bug6');`,
Expected: []sql.Row{{1}},
},
{
Query: `SELECT to_id FROM dolt_commit_diff_bug6 WHERE to_commit = (SELECT commit_hash FROM dolt.log) AND from_commit = dolt_hashof('HEAD~');`,
ExpectedErr: "more than",
ExpectedErrCode: "21000",
},
{
Query: `SELECT to_id FROM DOLT_DIFF((SELECT commit_hash FROM dolt.log), 'HEAD', 'bug6');`,
ExpectedErr: "more than",
ExpectedErrCode: "21000",
},
{
Query: `SELECT to_id FROM DOLT_DIFF((SELECT commit_hash FROM dolt.log WHERE 1 = 0), 'HEAD', 'bug6');`,
ExpectedErr: "received '<nil>' when expecting commit hash string",
},
{
Query: `SELECT to_id FROM DOLT_DIFF((SELECT commit_hash FROM dolt.log ORDER BY date DESC LIMIT 1)::text, 'HEAD', 'bug6');`,
ExpectedErr: "only literal values supported",
},
{
Query: `SELECT * FROM bug6 WHERE EXISTS (SELECT to_id FROM DOLT_DIFF((SELECT commit_hash FROM dolt.log WHERE message = bug6.v LIMIT 1), 'HEAD', 'bug6'));`,
ExpectedErr: "only literal values supported",
},
{
Query: `SELECT to_id FROM dolt_commit_diff_bug6 WHERE to_commit = (SELECT commit_hash FROM dolt.log WHERE 1 = 0) AND from_commit = dolt_hashof('HEAD~');`,
Expected: []sql.Row{},
},
{
Query: `SELECT count(*) FROM dolt_log('main') WHERE commit_hash = (SELECT commit_hash FROM dolt_log('main') LIMIT 1);`,
Expected: []sql.Row{{1}},
},
{
Query: `SELECT count(*) FROM dolt_log('main') WHERE commit_hash IN (SELECT commit_hash FROM dolt_log('main'));`,
Expected: []sql.Row{{4}},
},
},
},
{
Expand Down
10 changes: 5 additions & 5 deletions testing/go/pgcatalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6191,9 +6191,8 @@ ORDER BY 1;`,
{"Project"},
{" ├─ columns: [i.indrelid]"},
{" └─ Sort(i.indrelid ASC)"},
{" └─ Filter"},
{" ├─ i.indexrelid = Subquery"},
{" │ ├─ cacheable: true"},
{" └─ LookupJoin"},
{" ├─ Max1Row"},
{" │ └─ Project"},
{" │ ├─ columns: [c.oid]"},
{" │ └─ Filter"},
Expand All @@ -6203,8 +6202,9 @@ ORDER BY 1;`,
{" │ ├─ index: [pg_class.relname,pg_class.relnamespace]"},
{" │ └─ filters: [{[t1_pkey, t1_pkey], [NULL, ∞)}]"},
{" └─ TableAlias(i)"},
{" └─ Table"},
{" └─ name: pg_index"},
{" └─ IndexedTableAccess(pg_index)"},
{" ├─ index: [pg_index.indexrelid]"},
{" └─ keys: c.oid"},
},
},
{
Expand Down
Loading