Skip to content

Commit f16cf8c

Browse files
authored
Merge pull request #1473 from dolthub/zachmu/name-resolution
Bug fixes for `EXISTS`, prepared statement typing
2 parents 0a7ba9d + c1d0e48 commit f16cf8c

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ require (
1010
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241119094239-f4e529af734d
1111
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
1212
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad
13-
github.com/dolthub/go-mysql-server v0.19.1-0.20250512071951-e13f1e516493
13+
github.com/dolthub/go-mysql-server v0.20.1-0.20250514213318-e116aa682aaf
1414
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216
15-
github.com/dolthub/vitess v0.0.0-20250508181115-8941c8d71af1
15+
github.com/dolthub/vitess v0.0.0-20250512224608-8fb9c6ea092c
1616
github.com/fatih/color v1.13.0
1717
github.com/goccy/go-json v0.10.2
1818
github.com/gogo/protobuf v1.3.2

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
266266
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
267267
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad h1:66ZPawHszNu37VPQckdhX1BPPVzREsGgNxQeefnlm3g=
268268
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad/go.mod h1:ylU4XjUpsMcvl/BKeRRMXSH7e7WBrPXdSLvnRJYrxEA=
269-
github.com/dolthub/go-mysql-server v0.19.1-0.20250512071951-e13f1e516493 h1:0bC4Bi4lnP5WOQzZFK/McYk9kFty3+tJfmsRwWYRGnQ=
270-
github.com/dolthub/go-mysql-server v0.19.1-0.20250512071951-e13f1e516493/go.mod h1:3ItecPpGxpYrvkofINdXpIXMS7SH1NXAeOSfPFj03wE=
269+
github.com/dolthub/go-mysql-server v0.20.1-0.20250514213318-e116aa682aaf h1:sYBhIXdvdBww8Xw6K1QMjmGbuFEfYefNBie65TOxdm0=
270+
github.com/dolthub/go-mysql-server v0.20.1-0.20250514213318-e116aa682aaf/go.mod h1:5ZdrW0fHZbz+8CngT9gksqSX4H3y+7v1pns7tJCEpu0=
271271
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
272272
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
273273
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
276276
github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71/go.mod h1:2/2zjLQ/JOOSbbSboojeg+cAwcRV0fDLzIiWch/lhqI=
277277
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216 h1:JWkKRE4EHUcEVQCMRBej8DYxjYjRz/9MdF/NNQh0o70=
278278
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216/go.mod h1:e/FIZVvT2IR53HBCAo41NjqgtEnjMJGKca3Y/dAmZaA=
279-
github.com/dolthub/vitess v0.0.0-20250508181115-8941c8d71af1 h1:kH6+SaEzpm9QFKqWsznzwxcYrXIB4HZq6yOaZSXwsng=
280-
github.com/dolthub/vitess v0.0.0-20250508181115-8941c8d71af1/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
279+
github.com/dolthub/vitess v0.0.0-20250512224608-8fb9c6ea092c h1:imdag6PPCHAO2rZNsFoQoR4I/vIVTmO/czoOl5rUnbk=
280+
github.com/dolthub/vitess v0.0.0-20250512224608-8fb9c6ea092c/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
281281
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
282282
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
283283
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=

server/analyzer/type_sanitizer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ func TypeSanitizer(ctx *sql.Context, a *analyzer.Analyzer, node sql.Node, scope
7474
}
7575
}
7676
}
77+
case *plan.ExistsSubquery:
78+
return pgexprs.NewGMSCast(expr), transform.NewTree, nil
7779
case *sql.ColumnDefaultValue:
7880
// Due to how interfaces work, we sometimes pass (*ColumnDefaultValue)(nil), so we have to check for it
7981
if expr != nil && expr.Expr != nil {

server/connection_data.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ func extractBindVarTypes(queryPlan sql.Node) ([]uint32, error) {
132132
switch n.(type) {
133133
case *plan.Limit:
134134
typOid = uint32(oid.T_int4)
135+
case *plan.Offset:
136+
typOid = uint32(oid.T_int4)
135137
default:
136138
typOid, err = VitessTypeToObjectID(e.Type().Type())
137139
if err != nil {
@@ -241,6 +243,8 @@ func VitessTypeToObjectID(typ query.Type) (uint32, error) {
241243
return uint32(oid.T_text), nil // NULL is treated as TEXT on the wire
242244
case query.Type_ENUM:
243245
return uint32(oid.T_text), nil // TODO: temporary solution until we support CREATE TYPE
246+
case query.Type_EXPRESSION:
247+
return uint32(oid.T_text), nil // this most closely matches the behavior in postgres, which treats any unresolved type as a string (unless it has special handling)
244248
default:
245249
return 0, errors.Errorf("unsupported type: %s", typ)
246250
}

testing/go/prepared_statement_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ var preparedStatementTests = []ScriptTest{
4848
{3},
4949
},
5050
},
51+
{
52+
Query: "select $1 as test",
53+
BindVars: []any{"hello"},
54+
Expected: []sql.Row{
55+
{"hello"},
56+
},
57+
},
5158
},
5259
},
5360
{
@@ -56,18 +63,21 @@ var preparedStatementTests = []ScriptTest{
5663
{
5764
Query: "SELECT EXISTS(SELECT 1 FROM pg_namespace WHERE nspname = $1);",
5865
BindVars: []any{"public"},
59-
Expected: []sql.Row{{1}},
66+
Expected: []sql.Row{{"t"}},
6067
},
6168
{
6269
Query: "SELECT nspname FROM pg_namespace LIMIT $1;",
6370
BindVars: []any{1},
6471
Expected: []sql.Row{{"dolt"}},
6572
},
6673
{
67-
Skip: true, // TODO: ERROR: unsupported syntax: <nil>
6874
Query: "SELECT nspname FROM pg_namespace OFFSET $1;",
6975
BindVars: []any{1},
70-
Expected: []sql.Row{{"dolt"}},
76+
Expected: []sql.Row{
77+
{"information_schema"},
78+
{"pg_catalog"},
79+
{"public"},
80+
},
7181
},
7282
},
7383
},

0 commit comments

Comments
 (0)