@@ -44,10 +44,41 @@ type StoredProcedureDetails struct {
4444// or deleted by a user. In addition, they're implemented as a function taking standard parameters, compared to stored
4545// procedures being implemented as expressions.
4646type ExternalStoredProcedureDetails struct {
47- Function interface {}
48- Name string
49- Schema Schema
50- ReadOnly bool
47+ // Function is the implementation of the external stored procedure. All functions should have the following definition:
48+ // `func(*Context, <PARAMETERS>) (RowIter, error)`. The <PARAMETERS> may be any of the following types: `bool`,
49+ // `string`, `[]byte`, `int8`-`int64`, `uint8`-`uint64`, `float32`, `float64`, `time.Time`, or `Decimal`
50+ // (shopspring/decimal). The architecture-dependent types `int` and `uint` (without a number) are also supported.
51+ // It is valid to return a nil RowIter if there are no rows to be returned.
52+ //
53+ // Each parameter, by default, is an IN parameter. If the parameter type is a pointer, e.g. `*int32`, then it
54+ // becomes an INOUT parameter. INOUT parameters will be given their zero value if the parameter's value is nil.
55+ // There is no way to set a parameter as an OUT parameter.
56+ //
57+ // Values are converted to their nearest type before being passed in, following the conversion rules of their
58+ // related SQL types. The exceptions are `time.Time` (treated as a `DATETIME`), string (treated as a `LONGTEXT` with
59+ // the default collation) and Decimal (treated with a larger precision and scale). Take extra care when using decimal
60+ // for an INOUT parameter, to ensure that the returned value fits the original's precision and scale, else an error
61+ // will occur.
62+ //
63+ // As functions support overloading, each variant must have a completely unique function signature to prevent
64+ // ambiguity. Uniqueness is determined by the number of parameters. If two functions are returned that have the same
65+ // name and same number of parameters, then an error is thrown. If the last parameter is variadic, then the stored
66+ // procedure functions as though it has the integer-max number of parameters. When an exact match is not found for
67+ // overloaded functions, the largest function is used (which in this case will be the variadic function). Also, due
68+ // to the usage of the integer-max for the parameter count, only one variadic function is allowed per function name.
69+ // The type of the variadic parameter may not have a pointer type.
70+ Function interface {}
71+ // Name is the name of the external stored procedure. If two external stored procedures share a name, then they're
72+ // considered overloaded. Standard stored procedures do not support overloading.
73+ Name string
74+ // Schema describes the row layout of the RowIter returned from Function.
75+ Schema Schema
76+ // If true, the procedure is ReadOnly and can be run against a locked or read-only server.
77+ ReadOnly bool
78+ // If true, then this procedure's access control requires that the user must have explicit Execute permissions
79+ // on the procedure in question. If false, then the user will be granted access to the procedure if they have Execute
80+ // permissions on the DB. MySQL does not support anything like this, but it is useful for Dolt procedures which
81+ // grant elevated access.
5182 AdminOnly bool
5283}
5384
0 commit comments