Source file src/database/sql/convert.go

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Type conversions for Scan.
     6  
     7  package sql
     8  
     9  import (
    10  	"bytes"
    11  	"database/sql/driver"
    12  	"database/sql/internal"
    13  	"errors"
    14  	"fmt"
    15  	"reflect"
    16  	"strconv"
    17  	"time"
    18  	"unicode"
    19  	"unicode/utf8"
    20  	_ "unsafe" // for linkname
    21  	"uuid"
    22  )
    23  
    24  var errNilPtr = errors.New("destination pointer is nil") // embedded in descriptive error
    25  
    26  func describeNamedValue(nv *driver.NamedValue) string {
    27  	if len(nv.Name) == 0 {
    28  		return fmt.Sprintf("$%d", nv.Ordinal)
    29  	}
    30  	return fmt.Sprintf("with name %q", nv.Name)
    31  }
    32  
    33  func validateNamedValueName(name string) error {
    34  	if len(name) == 0 {
    35  		return nil
    36  	}
    37  	r, _ := utf8.DecodeRuneInString(name)
    38  	if unicode.IsLetter(r) {
    39  		return nil
    40  	}
    41  	return fmt.Errorf("name %q does not begin with a letter", name)
    42  }
    43  
    44  // ccChecker wraps the driver.ColumnConverter and allows it to be used
    45  // as if it were a NamedValueChecker. If the driver ColumnConverter
    46  // is not present then the NamedValueChecker will return driver.ErrSkip.
    47  type ccChecker struct {
    48  	cci  driver.ColumnConverter
    49  	want int
    50  }
    51  
    52  func (c ccChecker) CheckNamedValue(nv *driver.NamedValue) error {
    53  	if c.cci == nil {
    54  		return driver.ErrSkip
    55  	}
    56  	// The column converter shouldn't be called on any index
    57  	// it isn't expecting. The final error will be thrown
    58  	// in the argument converter loop.
    59  	index := nv.Ordinal - 1
    60  	if c.want >= 0 && c.want <= index {
    61  		return nil
    62  	}
    63  
    64  	// First, see if the value itself knows how to convert
    65  	// itself to a driver type. For example, a NullString
    66  	// struct changing into a string or nil.
    67  	if vr, ok := nv.Value.(driver.Valuer); ok {
    68  		sv, err := callValuerValue(vr)
    69  		if err != nil {
    70  			return err
    71  		}
    72  		if !driver.IsValue(sv) {
    73  			return fmt.Errorf("non-subset type %T returned from Value", sv)
    74  		}
    75  		nv.Value = sv
    76  	}
    77  
    78  	// Second, ask the column to sanity check itself. For
    79  	// example, drivers might use this to make sure that
    80  	// an int64 values being inserted into a 16-bit
    81  	// integer field is in range (before getting
    82  	// truncated), or that a nil can't go into a NOT NULL
    83  	// column before going across the network to get the
    84  	// same error.
    85  	var err error
    86  	arg := nv.Value
    87  	nv.Value, err = c.cci.ColumnConverter(index).ConvertValue(arg)
    88  	if err != nil {
    89  		return err
    90  	}
    91  	if !driver.IsValue(nv.Value) {
    92  		return fmt.Errorf("driver ColumnConverter error converted %T to unsupported type %T", arg, nv.Value)
    93  	}
    94  	return nil
    95  }
    96  
    97  // defaultCheckNamedValue wraps the default ColumnConverter to have the same
    98  // function signature as the CheckNamedValue in the driver.NamedValueChecker
    99  // interface.
   100  func defaultCheckNamedValue(nv *driver.NamedValue) (err error) {
   101  	nv.Value, err = driver.DefaultParameterConverter.ConvertValue(nv.Value)
   102  	return err
   103  }
   104  
   105  // driverArgsConnLocked converts arguments from callers of Stmt.Exec and
   106  // Stmt.Query into driver Values.
   107  //
   108  // The statement ds may be nil, if no statement is available.
   109  //
   110  // ci must be locked.
   111  func driverArgsConnLocked(ci driver.Conn, ds *driverStmt, args []any) ([]driver.NamedValue, error) {
   112  	nvargs := make([]driver.NamedValue, len(args))
   113  
   114  	// -1 means the driver doesn't know how to count the number of
   115  	// placeholders, so we won't sanity check input here and instead let the
   116  	// driver deal with errors.
   117  	want := -1
   118  
   119  	var si driver.Stmt
   120  	var cc ccChecker
   121  	if ds != nil {
   122  		si = ds.si
   123  		want = ds.si.NumInput()
   124  		cc.want = want
   125  	}
   126  
   127  	// Check all types of interfaces from the start.
   128  	// Drivers may opt to use the NamedValueChecker for special
   129  	// argument types, then return driver.ErrSkip to pass it along
   130  	// to the column converter.
   131  	nvc, ok := si.(driver.NamedValueChecker)
   132  	if !ok {
   133  		nvc, _ = ci.(driver.NamedValueChecker)
   134  	}
   135  	cci, ok := si.(driver.ColumnConverter)
   136  	if ok {
   137  		cc.cci = cci
   138  	}
   139  
   140  	// Loop through all the arguments, checking each one.
   141  	// If no error is returned simply increment the index
   142  	// and continue. However, if driver.ErrRemoveArgument
   143  	// is returned the argument is not included in the query
   144  	// argument list.
   145  	var err error
   146  	var n int
   147  	for _, arg := range args {
   148  		nv := &nvargs[n]
   149  		if np, ok := arg.(NamedArg); ok {
   150  			if err = validateNamedValueName(np.Name); err != nil {
   151  				return nil, err
   152  			}
   153  			arg = np.Value
   154  			nv.Name = np.Name
   155  		}
   156  		nv.Ordinal = n + 1
   157  		nv.Value = arg
   158  
   159  		// Checking sequence has four routes:
   160  		// A: 1. Default
   161  		// B: 1. NamedValueChecker 2. Column Converter 3. Default
   162  		// C: 1. NamedValueChecker 3. Default
   163  		// D: 1. Column Converter 2. Default
   164  		//
   165  		// The only time a Column Converter is called is first
   166  		// or after NamedValueConverter. If first it is handled before
   167  		// the nextCheck label. Thus for repeats tries only when the
   168  		// NamedValueConverter is selected should the Column Converter
   169  		// be used in the retry.
   170  		checker := defaultCheckNamedValue
   171  		nextCC := false
   172  		switch {
   173  		case nvc != nil:
   174  			nextCC = cci != nil
   175  			checker = nvc.CheckNamedValue
   176  		case cci != nil:
   177  			checker = cc.CheckNamedValue
   178  		}
   179  
   180  	nextCheck:
   181  		err = checker(nv)
   182  		switch err {
   183  		case nil:
   184  			n++
   185  			continue
   186  		case driver.ErrRemoveArgument:
   187  			nvargs = nvargs[:len(nvargs)-1]
   188  			continue
   189  		case driver.ErrSkip:
   190  			if nextCC {
   191  				nextCC = false
   192  				checker = cc.CheckNamedValue
   193  			} else {
   194  				checker = defaultCheckNamedValue
   195  			}
   196  			goto nextCheck
   197  		default:
   198  			return nil, fmt.Errorf("sql: converting argument %s type: %w", describeNamedValue(nv), err)
   199  		}
   200  	}
   201  
   202  	// Check the length of arguments after conversion to allow for omitted
   203  	// arguments.
   204  	if want != -1 && len(nvargs) != want {
   205  		return nil, fmt.Errorf("sql: expected %d arguments, got %d", want, len(nvargs))
   206  	}
   207  
   208  	return nvargs, nil
   209  }
   210  
   211  // convertAssign is the same as convertAssignRows, but without the optional
   212  // rows argument.
   213  //
   214  // convertAssign should be an internal detail,
   215  // but widely used packages access it using linkname.
   216  // Notable members of the hall of shame include:
   217  //   - ariga.io/entcache
   218  //
   219  // Do not remove or change the type signature.
   220  // See go.dev/issue/67401.
   221  //
   222  //go:linkname convertAssign
   223  func convertAssign(dest any, src any) error {
   224  	return convertAssignRows(dest, src, nil)
   225  }
   226  
   227  // ConvertAssign copies the value in src to the value pointed at by dest.
   228  // See the documentation on [Rows.Scan] for details on conversions.
   229  // dest must be a pointer or must implement [Scanner].
   230  //
   231  // Implementations of [driver.RowsColumnScanner] should pass through
   232  // their [driver.ScanContext] parameter.
   233  // In other cases, pass driver.ScanContext{} as the context.
   234  //
   235  // ConvertAssign is intended for use by driver implementations.
   236  // Most users should not need to use it directly.
   237  func ConvertAssign(scanCtx driver.ScanContext, dest any, src driver.Value) error {
   238  	rows, _ := internal.ScanContextValue(internal.ScanContext(scanCtx)).(*Rows)
   239  	return convertAssignRows(dest, src, rows)
   240  }
   241  
   242  // convertAssignRows copies to dest the value in src, converting it if possible.
   243  // An error is returned if the copy would result in loss of information.
   244  // dest should be a pointer type. If rows is passed in, the rows will
   245  // be used as the parent for any cursor values converted from a
   246  // driver.Rows to a *Rows.
   247  func convertAssignRows(dest, src any, rows *Rows) error {
   248  	// Common cases, without reflect.
   249  	switch s := src.(type) {
   250  	case string:
   251  		switch d := dest.(type) {
   252  		case *string:
   253  			if d == nil {
   254  				return errNilPtr
   255  			}
   256  			*d = s
   257  			return nil
   258  		case *[]byte:
   259  			if d == nil {
   260  				return errNilPtr
   261  			}
   262  			*d = []byte(s)
   263  			return nil
   264  		case *RawBytes:
   265  			if d == nil {
   266  				return errNilPtr
   267  			}
   268  			*d = rows.setrawbuf(append(rows.rawbuf(), s...))
   269  			return nil
   270  		case *uuid.UUID:
   271  			if d == nil {
   272  				return errNilPtr
   273  			}
   274  			u, err := uuid.Parse(s)
   275  			if err != nil {
   276  				return fmt.Errorf("converting driver.Value type string (%q) to a UUID: %v", s, err)
   277  			}
   278  			*d = u
   279  			return nil
   280  		}
   281  	case []byte:
   282  		switch d := dest.(type) {
   283  		case *string:
   284  			if d == nil {
   285  				return errNilPtr
   286  			}
   287  			*d = string(s)
   288  			return nil
   289  		case *any:
   290  			if d == nil {
   291  				return errNilPtr
   292  			}
   293  			*d = bytes.Clone(s)
   294  			return nil
   295  		case *[]byte:
   296  			if d == nil {
   297  				return errNilPtr
   298  			}
   299  			*d = bytes.Clone(s)
   300  			return nil
   301  		case *RawBytes:
   302  			if d == nil {
   303  				return errNilPtr
   304  			}
   305  			*d = s
   306  			return nil
   307  		case *uuid.UUID:
   308  			if d == nil {
   309  				return errNilPtr
   310  			}
   311  			if len(s) == len(*d) {
   312  				copy((*d)[:], s)
   313  				return nil
   314  			}
   315  			var u uuid.UUID
   316  			err := u.UnmarshalText(s)
   317  			if err != nil {
   318  				return fmt.Errorf("converting driver.Value type []byte (%q) to a UUID: %v", s, err)
   319  			}
   320  			*d = u
   321  			return nil
   322  		}
   323  	case time.Time:
   324  		switch d := dest.(type) {
   325  		case *time.Time:
   326  			*d = s
   327  			return nil
   328  		case *string:
   329  			*d = s.Format(time.RFC3339Nano)
   330  			return nil
   331  		case *[]byte:
   332  			if d == nil {
   333  				return errNilPtr
   334  			}
   335  			*d = s.AppendFormat(make([]byte, 0, len(time.RFC3339Nano)), time.RFC3339Nano)
   336  			return nil
   337  		case *RawBytes:
   338  			if d == nil {
   339  				return errNilPtr
   340  			}
   341  			*d = rows.setrawbuf(s.AppendFormat(rows.rawbuf(), time.RFC3339Nano))
   342  			return nil
   343  		}
   344  	case decimalDecompose:
   345  		switch d := dest.(type) {
   346  		case decimalCompose:
   347  			return d.Compose(s.Decompose(nil))
   348  		}
   349  	case nil:
   350  		switch d := dest.(type) {
   351  		case *any:
   352  			if d == nil {
   353  				return errNilPtr
   354  			}
   355  			*d = nil
   356  			return nil
   357  		case *[]byte:
   358  			if d == nil {
   359  				return errNilPtr
   360  			}
   361  			*d = nil
   362  			return nil
   363  		case *RawBytes:
   364  			if d == nil {
   365  				return errNilPtr
   366  			}
   367  			*d = nil
   368  			return nil
   369  		}
   370  	// The driver is returning a cursor the client may iterate over.
   371  	case driver.Rows:
   372  		d, ok := dest.(*Rows)
   373  		if ok {
   374  			if d == nil {
   375  				return errNilPtr
   376  			}
   377  			if rows == nil {
   378  				return errors.New("invalid context to convert cursor rows, missing parent *Rows")
   379  			}
   380  			// This is hazardous and not really correct: If the user provides us
   381  			// with the same *Rows for each Scan (which they very likely will),
   382  			// then this overwrites the previously-used Rows, including its mutexes.
   383  			// The chained row cancel function below will also repeatedly reference
   384  			// the same *Rows.
   385  			*d = Rows{
   386  				dc:          rows.dc,
   387  				releaseConn: func(error) {},
   388  				rowsi:       s,
   389  			}
   390  			// Chain the cancel function.
   391  			//
   392  			// This has problems:
   393  			//   - Repeatedly wrapping the cancel func is inefficient compared to
   394  			//     just storing a []*Rows of children.
   395  			//   - The cancel func is wrapped for each cursor read. If we scan N
   396  			//     rows, each with a child cursor, we end up with N chained cancel
   397  			//     funcs. (Also, if the user is reusing a Rows--see above--the cancel
   398  			//     funcs might all be referencing the same underlying Rows cursor.)
   399  			//   - It seems like it would be reasonable to invalidate a cursor
   400  			//     after advancing to the next parent row (the row which contains
   401  			//     the cursor). We don't do that now, and it isn't clear that we can
   402  			//     change this.
   403  			parentCancel := rows.cancel
   404  			rows.cancel = func() {
   405  				// When Rows.cancel is called, the closemu will be locked as well.
   406  				// So we can access rows.lasterr.
   407  				d.close(rows.lasterr)
   408  				if parentCancel != nil {
   409  					parentCancel()
   410  				}
   411  			}
   412  			return nil
   413  		}
   414  	}
   415  
   416  	var sv reflect.Value
   417  
   418  	switch d := dest.(type) {
   419  	case *string:
   420  		sv = reflect.ValueOf(src)
   421  		switch sv.Kind() {
   422  		case reflect.Bool,
   423  			reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
   424  			reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
   425  			reflect.Float32, reflect.Float64:
   426  			*d = asString(src)
   427  			return nil
   428  		}
   429  	case *[]byte:
   430  		sv = reflect.ValueOf(src)
   431  		if b, ok := asBytes(nil, sv); ok {
   432  			*d = b
   433  			return nil
   434  		}
   435  	case *RawBytes:
   436  		sv = reflect.ValueOf(src)
   437  		if b, ok := asBytes(rows.rawbuf(), sv); ok {
   438  			*d = rows.setrawbuf(b)
   439  			return nil
   440  		}
   441  	case *bool:
   442  		bv, err := driver.Bool.ConvertValue(src)
   443  		if err == nil {
   444  			*d = bv.(bool)
   445  		}
   446  		return err
   447  	case *any:
   448  		*d = src
   449  		return nil
   450  	}
   451  
   452  	if scanner, ok := dest.(Scanner); ok {
   453  		return scanner.Scan(src)
   454  	}
   455  
   456  	dpv := reflect.ValueOf(dest)
   457  	if dpv.Kind() != reflect.Pointer {
   458  		return errors.New("destination not a pointer")
   459  	}
   460  	if dpv.IsNil() {
   461  		return errNilPtr
   462  	}
   463  
   464  	if !sv.IsValid() {
   465  		sv = reflect.ValueOf(src)
   466  	}
   467  
   468  	dv := reflect.Indirect(dpv)
   469  	if sv.IsValid() && sv.Type().AssignableTo(dv.Type()) {
   470  		switch b := src.(type) {
   471  		case []byte:
   472  			dv.Set(reflect.ValueOf(bytes.Clone(b)))
   473  		default:
   474  			dv.Set(sv)
   475  		}
   476  		return nil
   477  	}
   478  
   479  	if dv.Kind() == sv.Kind() && sv.Type().ConvertibleTo(dv.Type()) {
   480  		dv.Set(sv.Convert(dv.Type()))
   481  		return nil
   482  	}
   483  
   484  	// The following conversions use a string value as an intermediate representation
   485  	// to convert between various numeric types.
   486  	//
   487  	// This also allows scanning into user defined types such as "type Int int64".
   488  	// For symmetry, also check for string destination types.
   489  	switch dv.Kind() {
   490  	case reflect.Pointer:
   491  		if src == nil {
   492  			dv.SetZero()
   493  			return nil
   494  		}
   495  		dv.Set(reflect.New(dv.Type().Elem()))
   496  		return convertAssignRows(dv.Interface(), src, rows)
   497  	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
   498  		if src == nil {
   499  			return fmt.Errorf("converting NULL to %s is unsupported", dv.Kind())
   500  		}
   501  		s := asString(src)
   502  		i64, err := strconv.ParseInt(s, 10, dv.Type().Bits())
   503  		if err != nil {
   504  			err = strconvErr(err)
   505  			return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err)
   506  		}
   507  		dv.SetInt(i64)
   508  		return nil
   509  	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
   510  		if src == nil {
   511  			return fmt.Errorf("converting NULL to %s is unsupported", dv.Kind())
   512  		}
   513  		s := asString(src)
   514  		u64, err := strconv.ParseUint(s, 10, dv.Type().Bits())
   515  		if err != nil {
   516  			err = strconvErr(err)
   517  			return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err)
   518  		}
   519  		dv.SetUint(u64)
   520  		return nil
   521  	case reflect.Float32, reflect.Float64:
   522  		if src == nil {
   523  			return fmt.Errorf("converting NULL to %s is unsupported", dv.Kind())
   524  		}
   525  		s := asString(src)
   526  		f64, err := strconv.ParseFloat(s, dv.Type().Bits())
   527  		if err != nil {
   528  			err = strconvErr(err)
   529  			return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err)
   530  		}
   531  		dv.SetFloat(f64)
   532  		return nil
   533  	case reflect.String:
   534  		if src == nil {
   535  			return fmt.Errorf("converting NULL to %s is unsupported", dv.Kind())
   536  		}
   537  		switch v := src.(type) {
   538  		case string:
   539  			dv.SetString(v)
   540  			return nil
   541  		case []byte:
   542  			dv.SetString(string(v))
   543  			return nil
   544  		}
   545  	}
   546  
   547  	return fmt.Errorf("unsupported Scan, storing driver.Value type %T into type %T", src, dest)
   548  }
   549  
   550  func strconvErr(err error) error {
   551  	if ne, ok := err.(*strconv.NumError); ok {
   552  		return ne.Err
   553  	}
   554  	return err
   555  }
   556  
   557  func asString(src any) string {
   558  	switch v := src.(type) {
   559  	case string:
   560  		return v
   561  	case []byte:
   562  		return string(v)
   563  	}
   564  	rv := reflect.ValueOf(src)
   565  	switch rv.Kind() {
   566  	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
   567  		return strconv.FormatInt(rv.Int(), 10)
   568  	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
   569  		return strconv.FormatUint(rv.Uint(), 10)
   570  	case reflect.Float64:
   571  		return strconv.FormatFloat(rv.Float(), 'g', -1, 64)
   572  	case reflect.Float32:
   573  		return strconv.FormatFloat(rv.Float(), 'g', -1, 32)
   574  	case reflect.Bool:
   575  		return strconv.FormatBool(rv.Bool())
   576  	}
   577  	return fmt.Sprintf("%v", src)
   578  }
   579  
   580  func asBytes(buf []byte, rv reflect.Value) (b []byte, ok bool) {
   581  	switch rv.Kind() {
   582  	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
   583  		return strconv.AppendInt(buf, rv.Int(), 10), true
   584  	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
   585  		return strconv.AppendUint(buf, rv.Uint(), 10), true
   586  	case reflect.Float32:
   587  		return strconv.AppendFloat(buf, rv.Float(), 'g', -1, 32), true
   588  	case reflect.Float64:
   589  		return strconv.AppendFloat(buf, rv.Float(), 'g', -1, 64), true
   590  	case reflect.Bool:
   591  		return strconv.AppendBool(buf, rv.Bool()), true
   592  	case reflect.String:
   593  		s := rv.String()
   594  		return append(buf, s...), true
   595  	}
   596  	return
   597  }
   598  
   599  var valuerReflectType = reflect.TypeFor[driver.Valuer]()
   600  
   601  // callValuerValue returns vr.Value(), with one exception:
   602  // If vr.Value is an auto-generated method on a pointer type and the
   603  // pointer is nil, it would panic at runtime in the panicwrap
   604  // method. Treat it like nil instead.
   605  // Issue 8415.
   606  //
   607  // This is so people can implement driver.Value on value types and
   608  // still use nil pointers to those types to mean nil/NULL, just like
   609  // string/*string.
   610  //
   611  // This function is mirrored in the database/sql/driver package.
   612  func callValuerValue(vr driver.Valuer) (v driver.Value, err error) {
   613  	if rv := reflect.ValueOf(vr); rv.Kind() == reflect.Pointer &&
   614  		rv.IsNil() &&
   615  		rv.Type().Elem().Implements(valuerReflectType) {
   616  		return nil, nil
   617  	}
   618  	return vr.Value()
   619  }
   620  
   621  // decimal composes or decomposes a decimal value to and from individual parts.
   622  // There are four parts: a boolean negative flag, a form byte with three possible states
   623  // (finite=0, infinite=1, NaN=2), a base-2 big-endian integer
   624  // coefficient (also known as a significand) as a []byte, and an int32 exponent.
   625  // These are composed into a final value as "decimal = (neg) (form=finite) coefficient * 10 ^ exponent".
   626  // A zero length coefficient is a zero value.
   627  // The big-endian integer coefficient stores the most significant byte first (at coefficient[0]).
   628  // If the form is not finite the coefficient and exponent should be ignored.
   629  // The negative parameter may be set to true for any form, although implementations are not required
   630  // to respect the negative parameter in the non-finite form.
   631  //
   632  // Implementations may choose to set the negative parameter to true on a zero or NaN value,
   633  // but implementations that do not differentiate between negative and positive
   634  // zero or NaN values should ignore the negative parameter without error.
   635  // If an implementation does not support Infinity it may be converted into a NaN without error.
   636  // If a value is set that is larger than what is supported by an implementation,
   637  // an error must be returned.
   638  // Implementations must return an error if a NaN or Infinity is attempted to be set while neither
   639  // are supported.
   640  //
   641  // NOTE(kardianos): This is an experimental interface. See https://golang.org/issue/30870
   642  type decimal interface {
   643  	decimalDecompose
   644  	decimalCompose
   645  }
   646  
   647  type decimalDecompose interface {
   648  	// Decompose returns the internal decimal state in parts.
   649  	// If the provided buf has sufficient capacity, buf may be returned as the coefficient with
   650  	// the value set and length set as appropriate.
   651  	Decompose(buf []byte) (form byte, negative bool, coefficient []byte, exponent int32)
   652  }
   653  
   654  type decimalCompose interface {
   655  	// Compose sets the internal decimal value from parts. If the value cannot be
   656  	// represented then an error should be returned.
   657  	Compose(form byte, negative bool, coefficient []byte, exponent int32) error
   658  }
   659  

View as plain text