Skip to content
Merged
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
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ go 1.26.2

require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a
github.com/cockroachdb/apd/v3 v3.2.3
github.com/cockroachdb/errors v1.7.5
github.com/dolthub/dolt/go v0.40.5-0.20260511182609-ab34f8c300fb
github.com/dolthub/dolt/go v0.40.5-0.20260514021628-29c8b0a35aa9
github.com/dolthub/eventsapi_schema v0.0.0-20260310172945-37a9265ade69
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.20.1-0.20260507202550-43d6daf5958b
github.com/dolthub/go-mysql-server v0.20.1-0.20260513232454-bbbd50eb8e47
github.com/dolthub/pg_query_go/v6 v6.0.0-20251215122834-fb20be4254d1
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216
github.com/dolthub/vitess v0.0.0-20260505163811-77e5224be390
Expand Down
13 changes: 6 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5 h1:6xNmx7iTtyBRev0+D/T
github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5/go.mod h1:KdCmV+x/BuvyMxRnYBlmVaq4OLiKW6iRQfvC62cvdkI=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a h1:9VFe4R5FRCUyidB1rdm3XdCRVuD/75P7Y4PtzEGhEE4=
github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw=
github.com/cockroachdb/apd/v3 v3.2.3 h1:4Zx+I3R35bFXMnltzmjP79i2cravE4jTRL6ps9Aux80=
github.com/cockroachdb/apd/v3 v3.2.3/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc=
github.com/cockroachdb/datadriven v1.0.0/go.mod h1:5Ib8Meh+jk1RlHIXej6Pzevx/NLlNvQB9pmSBZErGA4=
github.com/cockroachdb/errors v1.6.1/go.mod h1:tm6FTP5G81vwJ5lC0SizQo374JNCOPrHyXGitRJoDqM=
github.com/cockroachdb/errors v1.7.5 h1:ptyO1BLW+sBxwBTSKJfS6kGzYCVKhI7MyBhoXAnPIKM=
Expand Down Expand Up @@ -245,8 +245,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.4 h1:AyG5cw+fNWXDHXujtQnqUPZrpWtPg6FN6yYtjv1pP44=
github.com/dolthub/dolt-mcp v0.3.4/go.mod h1:bCZ7KHvDYs+M0e+ySgmGiNvLhcwsN7bbf5YCyillLrk=
github.com/dolthub/dolt/go v0.40.5-0.20260511182609-ab34f8c300fb h1:KUkux82SVxpTIRtuzbBIu9T3FDTs4zCmbrMMScwpCSo=
github.com/dolthub/dolt/go v0.40.5-0.20260511182609-ab34f8c300fb/go.mod h1:zQgkmBI5uIRpzo+liO3Q6by+rcLWGcvyJhAAI/rmkHE=
github.com/dolthub/dolt/go v0.40.5-0.20260514021628-29c8b0a35aa9 h1:PPYToX+QqSr89DiAKkxm5KxT7OIdwLJMPD9IujLTxjM=
github.com/dolthub/dolt/go v0.40.5-0.20260514021628-29c8b0a35aa9/go.mod h1:mhl/QwBfzZrITl6XsjaAamvfYnKWWqXvLs992+oFz3o=
github.com/dolthub/eventsapi_schema v0.0.0-20260310172945-37a9265ade69 h1:JShhbqMw26nKx3pqqu/cFxOpzBkN+4elVhzuUfgDw2k=
github.com/dolthub/eventsapi_schema v0.0.0-20260310172945-37a9265ade69/go.mod h1:SSLraQS/jGLYFgff3vuZ+JbVUct6vyEeMzjLBqWqoyM=
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww=
Expand All @@ -255,8 +255,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-20260412212219-49724d547866 h1:U6gSf5I0e6h6GP1/5Sa7D2lWW1CWfcVPtY5wkyHq6jY=
github.com/dolthub/go-icu-regex v0.0.0-20260412212219-49724d547866/go.mod h1:F3cnm+vMRK1HaU6+rNqQrOCyR03HHhR1GWG2gnPOqaE=
github.com/dolthub/go-mysql-server v0.20.1-0.20260507202550-43d6daf5958b h1:Ew5nacrGUHRVyae1+/0vUjt3ZbX/6vaDEZfeDNMCSj8=
github.com/dolthub/go-mysql-server v0.20.1-0.20260507202550-43d6daf5958b/go.mod h1:55n1yslSIZ5uewFbtd82DsYt3f9vUKwnRN5GZJie+nE=
github.com/dolthub/go-mysql-server v0.20.1-0.20260513232454-bbbd50eb8e47 h1:59cpEXHrN4oubATtax1ybjHWDorO6h1nE5GRudFCyVc=
github.com/dolthub/go-mysql-server v0.20.1-0.20260513232454-bbbd50eb8e47/go.mod h1:uE//4hYOi/1zIgOYgr8D+u7OvDfI4yPXFsL4dTZWk5I=
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 Down Expand Up @@ -670,7 +670,6 @@ github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTw
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
# Format: one version tag per line, e.g. v0.8.0
# Keep this list reasonably short; each entry downloads a binary and runs the full
# test suite, so CI time grows linearly.
v0.55.0
v0.51.0
v0.56.0
2 changes: 1 addition & 1 deletion postgres/parser/encoding/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"math/big"
"unsafe"

"github.com/cockroachdb/apd/v2"
"github.com/cockroachdb/apd/v3"
"github.com/cockroachdb/errors"
)

Expand Down
2 changes: 1 addition & 1 deletion postgres/parser/encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"fmt"
"unsafe"

"github.com/cockroachdb/apd/v2"
"github.com/cockroachdb/apd/v3"
"github.com/cockroachdb/errors"

"github.com/dolthub/doltgresql/postgres/parser/uuid"
Expand Down
2 changes: 1 addition & 1 deletion postgres/parser/json/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package json

import (
"github.com/cockroachdb/apd/v2"
"github.com/cockroachdb/apd/v3"
"github.com/cockroachdb/errors"

"github.com/dolthub/doltgresql/postgres/parser/encoding"
Expand Down
2 changes: 1 addition & 1 deletion postgres/parser/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"unicode/utf8"
"unsafe"

"github.com/cockroachdb/apd/v2"
"github.com/cockroachdb/apd/v3"
"github.com/cockroachdb/errors"

"github.com/dolthub/doltgresql/postgres/parser/encoding"
Expand Down
4 changes: 2 additions & 2 deletions postgres/parser/sem/tree/datum.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"unicode"
"unsafe"

"github.com/cockroachdb/apd/v2"
"github.com/cockroachdb/apd/v3"
"github.com/cockroachdb/errors"
"github.com/lib/pq/oid"

Expand Down Expand Up @@ -563,7 +563,7 @@ func (d *DDecimal) IsComposite() bool {

// Check if d is divisible by 10.
var r big.Int
r.Rem(&d.Decimal.Coeff, bigTen)
r.Rem((&d.Decimal.Coeff).MathBigInt(), bigTen)
return r.Sign() == 0
}

Expand Down
2 changes: 1 addition & 1 deletion postgres/parser/sem/tree/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"fmt"
"math"

"github.com/cockroachdb/apd/v2"
"github.com/cockroachdb/apd/v3"

"github.com/dolthub/doltgresql/postgres/parser/pgcode"
"github.com/dolthub/doltgresql/postgres/parser/pgerror"
Expand Down
2 changes: 1 addition & 1 deletion server/analyzer/resolve_values_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func ResolveValuesTypes(ctx *sql.Context, a *analyzer.Analyzer, node sql.Node, s
// MIN now returns numeric, so GroupBy produces numeric. But the
// Project's GetField still says int4 because its tableId=GroupBy,
// which wasn't in transformedVDTs. At runtime this causes a panic
// because the actual value is decimal.Decimal but the type says int32.
// because the actual value is *apd.Decimal but the type says int32.
//
// This pass catches those: for each GetField, check if its type
// disagrees with what the child node actually produces.
Expand Down
4 changes: 2 additions & 2 deletions server/analyzer/type_sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"strings"
"time"

"github.com/cockroachdb/apd/v3"
"github.com/cockroachdb/errors"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/analyzer"
Expand All @@ -27,7 +28,6 @@ import (
"github.com/dolthub/go-mysql-server/sql/transform"
"github.com/dolthub/go-mysql-server/sql/types"
"github.com/dolthub/vitess/go/vt/proto/query"
"github.com/shopspring/decimal"

pgexprs "github.com/dolthub/doltgresql/server/expression"
"github.com/dolthub/doltgresql/server/functions/framework"
Expand Down Expand Up @@ -173,7 +173,7 @@ func typeSanitizerLiterals(ctx *sql.Context, gmsLiteral *expression.Literal) (sq
}
return pgexprs.NewRawLiteralFloat64(newVal.(float64)), transform.NewTree, nil
case query.Type_DECIMAL:
dec, ok := gmsLiteral.Value().(decimal.Decimal)
dec, ok := gmsLiteral.Value().(*apd.Decimal)
if !ok {
return nil, transform.NewTree, errors.Errorf("SANITIZER: expected decimal type: %T", gmsLiteral.Value())
}
Expand Down
10 changes: 1 addition & 9 deletions server/ast/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/cockroachdb/errors"
"github.com/dolthub/go-mysql-server/sql/expression"
vitess "github.com/dolthub/vitess/go/vt/sqlparser"
"github.com/shopspring/decimal"
"github.com/sirupsen/logrus"

"github.com/dolthub/doltgresql/core/id"
Expand Down Expand Up @@ -518,15 +517,8 @@ func nodeExpr(ctx *Context, node tree.Expr) (vitess.Expr, error) {
Expression: pgexprs.NewRawLiteralDate(t),
}, nil
case *tree.DDecimal:
// TODO: should we use apd.Decimal for Numeric type values?
// |Coeff| is always positive, so need to |Negative| to negate the big.Int
bigInt := &node.Coeff
if node.Negative {
bigInt = bigInt.Neg(bigInt)
}
return vitess.InjectedExpr{
Expression: pgexprs.NewRawLiteralNumeric(decimal.NewFromBigInt(bigInt, node.Exponent)),
}, nil
Expression: pgexprs.NewRawLiteralNumeric(&node.Decimal)}, nil
case *tree.DEnum:
return nil, errors.Errorf("the statement is not yet supported")
case *tree.DFloat:
Expand Down
9 changes: 7 additions & 2 deletions server/cast/float32.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package cast
import (
"math"

"github.com/cockroachdb/apd/v3"
"github.com/cockroachdb/errors"
"github.com/dolthub/go-mysql-server/sql"
"github.com/shopspring/decimal"

"github.com/dolthub/doltgresql/server/functions/framework"
pgtypes "github.com/dolthub/doltgresql/server/types"
Expand Down Expand Up @@ -70,7 +70,12 @@ func float32Assignment() {
FromType: pgtypes.Float32,
ToType: pgtypes.Numeric,
Function: func(ctx *sql.Context, val any, targetType *pgtypes.DoltgresType) (any, error) {
return pgtypes.GetNumericValueWithTypmod(decimal.NewFromFloat(float64(val.(float32))), targetType.GetAttTypMod())
d := new(apd.Decimal)
err := d.Scan(float64(val.(float32)))
if err != nil {
return nil, err
}
return pgtypes.GetNumericValueWithTypmod(d, targetType.GetAttTypMod())
},
})
}
Expand Down
9 changes: 7 additions & 2 deletions server/cast/float64.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package cast
import (
"math"

"github.com/cockroachdb/apd/v3"
"github.com/cockroachdb/errors"
"github.com/dolthub/go-mysql-server/sql"
"github.com/shopspring/decimal"

"github.com/dolthub/doltgresql/server/functions/framework"
pgtypes "github.com/dolthub/doltgresql/server/types"
Expand Down Expand Up @@ -76,7 +76,12 @@ func float64Assignment() {
FromType: pgtypes.Float64,
ToType: pgtypes.Numeric,
Function: func(ctx *sql.Context, val any, targetType *pgtypes.DoltgresType) (any, error) {
return pgtypes.GetNumericValueWithTypmod(decimal.NewFromFloat(val.(float64)), targetType.GetAttTypMod())
d := new(apd.Decimal)
err := d.Scan(val.(float64))
if err != nil {
return nil, err
}
return pgtypes.GetNumericValueWithTypmod(d, targetType.GetAttTypMod())
},
})
}
4 changes: 2 additions & 2 deletions server/cast/int16.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package cast

import (
"github.com/cockroachdb/apd/v3"
"github.com/dolthub/go-mysql-server/sql"
"github.com/shopspring/decimal"

"github.com/dolthub/doltgresql/core/id"
"github.com/dolthub/doltgresql/server/functions/framework"
Expand Down Expand Up @@ -62,7 +62,7 @@ func int16Implicit() {
FromType: pgtypes.Int16,
ToType: pgtypes.Numeric,
Function: func(ctx *sql.Context, val any, targetType *pgtypes.DoltgresType) (any, error) {
return decimal.NewFromInt(int64(val.(int16))), nil
return pgtypes.GetNumericValueWithTypmod(apd.New(int64(val.(int16)), 0), targetType.GetAttTypMod())
},
})
framework.MustAddImplicitTypeCast(framework.TypeCast{
Expand Down
4 changes: 2 additions & 2 deletions server/cast/int32.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
package cast

import (
"github.com/cockroachdb/apd/v3"
"github.com/cockroachdb/errors"

"github.com/dolthub/go-mysql-server/sql"
"github.com/shopspring/decimal"

"github.com/dolthub/doltgresql/core/id"
"github.com/dolthub/doltgresql/server/functions/framework"
Expand Down Expand Up @@ -84,7 +84,7 @@ func int32Implicit() {
FromType: pgtypes.Int32,
ToType: pgtypes.Numeric,
Function: func(ctx *sql.Context, val any, targetType *pgtypes.DoltgresType) (any, error) {
return decimal.NewFromInt(int64(val.(int32))), nil
return pgtypes.GetNumericValueWithTypmod(apd.New(int64(val.(int32)), 0), targetType.GetAttTypMod())
},
})
framework.MustAddImplicitTypeCast(framework.TypeCast{
Expand Down
15 changes: 8 additions & 7 deletions server/cast/int64.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
package cast

import (
"github.com/cockroachdb/errors"
"math"

"github.com/cockroachdb/apd/v3"
"github.com/cockroachdb/errors"
"github.com/dolthub/go-mysql-server/sql"
"github.com/shopspring/decimal"

"github.com/dolthub/doltgresql/core/id"
"github.com/dolthub/doltgresql/server/functions/framework"
Expand Down Expand Up @@ -75,14 +76,14 @@ func int64Implicit() {
FromType: pgtypes.Int64,
ToType: pgtypes.Numeric,
Function: func(ctx *sql.Context, val any, targetType *pgtypes.DoltgresType) (any, error) {
return decimal.NewFromInt(val.(int64)), nil
return pgtypes.GetNumericValueWithTypmod(apd.New(val.(int64), 0), targetType.GetAttTypMod())
},
})
framework.MustAddImplicitTypeCast(framework.TypeCast{
FromType: pgtypes.Int64,
ToType: pgtypes.Oid,
Function: func(ctx *sql.Context, val any, targetType *pgtypes.DoltgresType) (any, error) {
if val.(int64) > pgtypes.MaxUint32 || val.(int64) < 0 {
if val.(int64) > int64(math.MaxUint32) || val.(int64) < 0 {
return nil, errOutOfRange.New(targetType.String())
}
if internalID := id.Cache().ToInternal(uint32(val.(int64))); internalID.IsValid() {
Expand All @@ -95,7 +96,7 @@ func int64Implicit() {
FromType: pgtypes.Int64,
ToType: pgtypes.Regclass,
Function: func(ctx *sql.Context, val any, targetType *pgtypes.DoltgresType) (any, error) {
if val.(int64) > pgtypes.MaxUint32 || val.(int64) < 0 {
if val.(int64) > int64(math.MaxUint32) || val.(int64) < 0 {
return nil, errOutOfRange.New(targetType.String())
}
if internalID := id.Cache().ToInternal(uint32(val.(int64))); internalID.IsValid() {
Expand All @@ -108,7 +109,7 @@ func int64Implicit() {
FromType: pgtypes.Int64,
ToType: pgtypes.Regproc,
Function: func(ctx *sql.Context, val any, targetType *pgtypes.DoltgresType) (any, error) {
if val.(int64) > pgtypes.MaxUint32 || val.(int64) < 0 {
if val.(int64) > int64(math.MaxUint32) || val.(int64) < 0 {
return nil, errOutOfRange.New(targetType.String())
}
if internalID := id.Cache().ToInternal(uint32(val.(int64))); internalID.IsValid() {
Expand All @@ -121,7 +122,7 @@ func int64Implicit() {
FromType: pgtypes.Int64,
ToType: pgtypes.Regtype,
Function: func(ctx *sql.Context, val any, targetType *pgtypes.DoltgresType) (any, error) {
if val.(int64) > pgtypes.MaxUint32 || val.(int64) < 0 {
if val.(int64) > int64(math.MaxUint32) || val.(int64) < 0 {
return nil, errOutOfRange.New(targetType.String())
}
if internalID := id.Cache().ToInternal(uint32(val.(int64))); internalID.IsValid() {
Expand Down
Loading
Loading