Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable larger statements for dolt_procedures #8650

Merged
merged 3 commits into from
Dec 11, 2024
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
40 changes: 40 additions & 0 deletions go/libraries/doltcore/sqle/enginetest/dolt_procedure_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,44 @@ end
},
},
},

{
Name: "create and call procedure which exceeds 1024 bytes",
SetUpScript: []string{
`CREATE PROCEDURE long_proc()
BEGIN
DECLARE long_text TEXT;
SET long_text = CONCAT(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ',
'Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ',
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris ',
'nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in ',
'reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ',
'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia ',
'deserunt mollit anim id est laborum.',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ',
'Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ',
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris ',
'nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in ',
'reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ',
'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia ',
'deserunt mollit anim id est laborum.',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ',
'Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ',
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris ',
'nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in ',
'reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ',
'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia ',
'deserunt mollit anim id est laborum.');
SELECT SHA2(long_text,256) AS checksum, LENGTH(long_text) AS length;
END
`,
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "call long_proc();",
Expected: []sql.Row{{"a702e99e5ee2dc03095bb2efd58e28330b6ea085d036249de82977a5c0dbb4be", 1335}},
},
},
},
}
17 changes: 16 additions & 1 deletion go/libraries/doltcore/sqle/procedures_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ import (
"time"

"github.com/dolthub/go-mysql-server/sql"
gmstypes "github.com/dolthub/go-mysql-server/sql/types"
"github.com/dolthub/vitess/go/sqltypes"
"gopkg.in/src-d/go-errors.v1"

"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
"github.com/dolthub/dolt/go/libraries/doltcore/schema/typeinfo"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil"
Expand Down Expand Up @@ -130,9 +133,21 @@ func ProceduresTableSqlSchema() sql.PrimaryKeySchema {

// The fixed dolt schema for the `dolt_procedures` table.
func ProceduresTableSchema() schema.Schema {
// Max len is 8K - big enough to be useful, but not too big to exceed max total row len of 64K.
t, err := gmstypes.CreateStringWithDefaults(sqltypes.VarChar, typeinfo.MaxVarcharLength/2)
if err != nil {
panic(err) // should never happen. All constants.
}
ti := typeinfo.CreateVarStringTypeFromSqlType(t)

stmtCol, err := schema.NewColumnWithTypeInfo(doltdb.ProceduresTableCreateStmtCol, schema.DoltProceduresCreateStmtTag, ti, false, "", false, "")
if err != nil {
panic(err) // should never happen.
}

colColl := schema.NewColCollection(
schema.NewColumn(doltdb.ProceduresTableNameCol, schema.DoltProceduresNameTag, types.StringKind, true, schema.NotNullConstraint{}),
schema.NewColumn(doltdb.ProceduresTableCreateStmtCol, schema.DoltProceduresCreateStmtTag, types.StringKind, false),
stmtCol,
schema.NewColumn(doltdb.ProceduresTableCreatedAtCol, schema.DoltProceduresCreatedAtTag, types.TimestampKind, false),
schema.NewColumn(doltdb.ProceduresTableModifiedAtCol, schema.DoltProceduresModifiedAtTag, types.TimestampKind, false),
schema.NewColumn(doltdb.ProceduresTableSqlModeCol, schema.DoltProceduresSqlModeTag, types.StringKind, false),
Expand Down
Loading