Skip to content

Commit

Permalink
single quoted default value in create table statements (#1036)
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifersp authored Jun 14, 2022
1 parent de8461d commit 51dc04e
Show file tree
Hide file tree
Showing 17 changed files with 228 additions and 115 deletions.
2 changes: 1 addition & 1 deletion enginetest/enginetests.go
Original file line number Diff line number Diff line change
Expand Up @@ -5047,7 +5047,7 @@ func TestColumnDefaults(t *testing.T, harness Harness) {
RunQuery(t, e, harness, "alter table t33 drop column name2")

TestQueryWithContext(t, ctx, e, "desc t33", []sql.Row{
{"pk", "varchar(100)", "NO", "PRI", "(replace(UUID(), \"-\", \"\"))", ""},
{"pk", "varchar(100)", "NO", "PRI", "(replace(UUID(), '-', ''))", ""},
{"v1_new", "timestamp", "YES", "", "NOW()", ""},
{"v2", "varchar(100)", "YES", "", "", ""},
}, nil, nil)
Expand Down
17 changes: 15 additions & 2 deletions enginetest/queries/create_table_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var CreateTableQueries = []WriteQueryTest{
WriteQuery: `CREATE TABLE t1 (a INTEGER, create_time timestamp(6) NOT NULL DEFAULT NOW(6), primary key (a))`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `a` int NOT NULL,\n `create_time` timestamp NOT NULL DEFAULT (NOW(6)),\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `a` int NOT NULL,\n `create_time` timestamp NOT NULL DEFAULT NOW(6),\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 LIKE mytable`,
Expand Down Expand Up @@ -133,6 +133,19 @@ var CreateTableQueries = []WriteQueryTest{
)`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `pk` int NOT NULL,\n `col1` blob DEFAULT (\"abc\"),\n `col2` json DEFAULT (JSON_OBJECT(\"a\", 1)),\n `col3` text DEFAULT (\"abc\"),\n PRIMARY KEY (`pk`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `pk` int NOT NULL,\n `col1` blob DEFAULT ('abc'),\n `col2` json DEFAULT (JSON_OBJECT('a', 1)),\n `col3` text DEFAULT ('abc'),\n PRIMARY KEY (`pk`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE td (
pk int PRIMARY KEY,
col2 int NOT NULL DEFAULT 2,
col3 double NOT NULL DEFAULT (round(-(1.58),0)),
col4 varchar(10) DEFAULT 'new row',
col5 float DEFAULT 33.33,
col6 int DEFAULT NULL
)`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE td",
ExpectedSelect: []sql.Row{sql.Row{"td", "CREATE TABLE `td` (\n `pk` int NOT NULL,\n `col2` int NOT NULL DEFAULT '2',\n `col3` double NOT NULL DEFAULT (ROUND(-1.58, 0)),\n `col4` varchar(10) DEFAULT 'new row',\n `col5` float DEFAULT '33.33',\n `col6` int DEFAULT NULL,\n PRIMARY KEY (`pk`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
}
57 changes: 40 additions & 17 deletions enginetest/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -3918,13 +3918,17 @@ var QueryTests = []QueryTest{
Expected: []sql.Row{{
"myview",
"CREATE VIEW `myview` AS SELECT * FROM mytable",
"utf8mb4",
"utf8mb4_0900_bin",
}},
},
{
Query: `SHOW CREATE VIEW myview`,
Expected: []sql.Row{{
"myview",
"CREATE VIEW `myview` AS SELECT * FROM mytable",
"utf8mb4",
"utf8mb4_0900_bin",
}},
},
{
Expand Down Expand Up @@ -7875,11 +7879,7 @@ var InfoSchemaScripts = []ScriptTest{
{
Name: "information_schema.columns shows default value with more types",
SetUpScript: []string{
"CREATE TABLE test_table (pk int primary key, fname varchar(20), lname varchar(20), height int)",
"ALTER TABLE test_table CHANGE fname col2 float NOT NULL DEFAULT 4.5",
"ALTER TABLE test_table CHANGE lname col3 double NOT NULL DEFAULT 3.14159",
"ALTER TABLE test_table CHANGE height col4 datetime NULL DEFAULT '2008-04-22 16:16:16'",
"ALTER TABLE test_table ADD COLUMN col5 boolean NULL DEFAULT FALSE",
"CREATE TABLE test_table (pk int primary key, col2 float NOT NULL DEFAULT 4.5, col3 double NOT NULL DEFAULT 3.14159, col4 datetime NULL DEFAULT '2008-04-22 16:16:16', col5 boolean NULL DEFAULT FALSE)",
},
Assertions: []ScriptTestAssertion{
{
Expand All @@ -7889,27 +7889,26 @@ var InfoSchemaScripts = []ScriptTest{
{"test_table", "col2", "4.5", "NO"},
{"test_table", "col3", "3.14159", "NO"},
{"test_table", "col4", "2008-04-22 16:16:16", "YES"},
{"test_table", "col5", "false", "YES"},
{"test_table", "col5", "0", "YES"},
},
},
},
},
{
Name: "information_schema.columns shows default value with more types",
SetUpScript: []string{
"CREATE TABLE test_table (pk int primary key)",
"ALTER TABLE test_table ADD COLUMN col2 float DEFAULT length('hello')",
"ALTER TABLE test_table ADD COLUMN col3 int DEFAULT greatest(`pk`, 2)",
"ALTER TABLE test_table ADD COLUMN col4 int DEFAULT (5 + 5)",
"CREATE TABLE test_table (pk int primary key, col2 float DEFAULT (length('he`Llo')), col3 int DEFAULT (greatest(`pk`, 2)), col4 int DEFAULT (5 + 5), col5 datetime default NOW(), create_time timestamp(6) NOT NULL DEFAULT NOW(6));",
},
Assertions: []ScriptTestAssertion{
{
Query: "SELECT table_name, column_name, column_default, is_nullable FROM information_schema.columns where table_name='test_table'",
Expected: []sql.Row{
{"test_table", "pk", nil, "NO"},
{"test_table", "col2", "LENGTH(\"hello\")", "YES"},
{"test_table", "col2", "LENGTH('he`Llo')", "YES"},
{"test_table", "col3", "GREATEST(pk, 2)", "YES"},
{"test_table", "col4", "(5 + 5)", "YES"},
{"test_table", "col5", "NOW()", "YES"},
{"test_table", "create_time", "NOW(6)", "NO"},
},
},
},
Expand Down Expand Up @@ -7960,8 +7959,8 @@ var InfoSchemaScripts = []ScriptTest{
{
Query: "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'foo'",
Expected: []sql.Row{
{"def", "foo", "t", "i", uint64(1), nil, "YES", "int", nil, nil, nil, nil, nil, nil, nil, "int", "", "", "select", "", "", "NULL"},
{"def", "foo", "v", "", uint64(0), nil, nil, nil, nil, nil, nil, nil, nil, "", "", "", "", "", "select", "", "", "NULL"},
{"def", "foo", "t", "i", uint32(1), nil, "YES", "int", nil, nil, nil, nil, nil, nil, nil, "int", "", "", "select", "", "", nil},
{"def", "foo", "v", "", uint32(0), nil, "", nil, nil, nil, nil, nil, nil, "", "", "", "", "", "select", "", "", nil},
},
},
},
Expand Down Expand Up @@ -8045,10 +8044,10 @@ var InfoSchemaScripts = []ScriptTest{
{
Query: "SELECT TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, COLUMN_TYPE, COLUMN_KEY, SRS_ID FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'stable'",
Expected: []sql.Row{
{"stable", "geo", "POINT(2, 5)", "NO", "geometry", "geometry", "", "NULL"},
{"stable", "line", nil, "NO", "linestring", "linestring", "", "NULL"},
{"stable", "pnt", nil, "YES", "point", "point", "", "4326"},
{"stable", "pol", nil, "NO", "polygon", "polygon", "", "0"},
{"stable", "geo", "POINT(2, 5)", "NO", "geometry", "geometry", "", nil},
{"stable", "line", nil, "NO", "linestring", "linestring", "", nil},
{"stable", "pnt", nil, "YES", "point", "point", "", uint32(4326)},
{"stable", "pol", nil, "NO", "polygon", "polygon", "", uint32(0)},
},
},
},
Expand Down Expand Up @@ -8523,6 +8522,30 @@ var ErrorQueries = []QueryErrorTest{
Query: `CREATE PROCEDURE proc1 (OUT out_count INT) READS SQL DATA SELECT COUNT(*) FROM mytable WHERE i = 1 AND s = 'first row' AND func1(i);`,
ExpectedErr: sql.ErrFunctionNotFound,
},
{
Query: "CREATE TABLE table_test (id int PRIMARY KEY, c float DEFAULT rand())",
ExpectedErr: sql.ErrInvalidColumnDefaultValue,
},
{
Query: "CREATE TABLE table_test (id int PRIMARY KEY, c float DEFAULT rand)",
ExpectedErr: sql.ErrInvalidColumnDefaultValue,
},
{
Query: "CREATE TABLE table_test (id int PRIMARY KEY, c float DEFAULT (select 1))",
ExpectedErr: sql.ErrColumnDefaultSubquery,
},
{
Query: "CREATE TABLE table_test (id int PRIMARY KEY, b int DEFAULT '2', c int DEFAULT `b`)",
ExpectedErr: sql.ErrInvalidColumnDefaultValue,
},
{
Query: "CREATE TABLE t0 (id INT PRIMARY KEY, v1 POINT DEFAULT POINT(1,2));",
ExpectedErr: sql.ErrSyntaxError,
},
{
Query: "CREATE TABLE t0 (id INT PRIMARY KEY, v1 JSON DEFAULT JSON_ARRAY(1,2));",
ExpectedErr: sql.ErrSyntaxError,
},
}

// WriteQueryTest is a query test for INSERT, UPDATE, etc. statements. It has a query to run and a select query to
Expand Down
18 changes: 9 additions & 9 deletions enginetest/queries/query_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ var PlanTests = []QueryPlanTest{
ExpectedPlan: "Insert(i, s)\n" +
" ├─ Table(mytable)\n" +
" └─ Project(i, s)\n" +
" └─ Project(t1.i, \"hello\")\n" +
" └─ Project(t1.i, 'hello')\n" +
" └─ IndexedJoin(t1.i = (t2.i + 1))\n" +
" ├─ Filter(t2.i = 1)\n" +
" │ └─ TableAlias(t2)\n" +
Expand Down Expand Up @@ -214,7 +214,7 @@ var PlanTests = []QueryPlanTest{
{
Query: `SELECT i, i2, s2 FROM mytable INNER JOIN othertable ON i = i2 OR SUBSTRING_INDEX(s, ' ', 1) = s2`,
ExpectedPlan: "Project(mytable.i, othertable.i2, othertable.s2)\n" +
" └─ IndexedJoin((mytable.i = othertable.i2) OR (SUBSTRING_INDEX(mytable.s, \" \", 1) = othertable.s2))\n" +
" └─ IndexedJoin((mytable.i = othertable.i2) OR (SUBSTRING_INDEX(mytable.s, ' ', 1) = othertable.s2))\n" +
" ├─ Table(mytable)\n" +
" └─ Concat\n" +
" ├─ IndexedTableAccess(othertable on [othertable.i2])\n" +
Expand All @@ -224,7 +224,7 @@ var PlanTests = []QueryPlanTest{
{
Query: `SELECT i, i2, s2 FROM mytable INNER JOIN othertable ON i = i2 OR SUBSTRING_INDEX(s, ' ', 1) = s2 OR SUBSTRING_INDEX(s, ' ', 2) = s2`,
ExpectedPlan: "Project(mytable.i, othertable.i2, othertable.s2)\n" +
" └─ IndexedJoin(((mytable.i = othertable.i2) OR (SUBSTRING_INDEX(mytable.s, \" \", 1) = othertable.s2)) OR (SUBSTRING_INDEX(mytable.s, \" \", 2) = othertable.s2))\n" +
" └─ IndexedJoin(((mytable.i = othertable.i2) OR (SUBSTRING_INDEX(mytable.s, ' ', 1) = othertable.s2)) OR (SUBSTRING_INDEX(mytable.s, ' ', 2) = othertable.s2))\n" +
" ├─ Table(mytable)\n" +
" └─ Concat\n" +
" ├─ Concat\n" +
Expand Down Expand Up @@ -502,7 +502,7 @@ var PlanTests = []QueryPlanTest{
Query: `SELECT a.* FROM mytable a inner join mytable b on (a.i = b.s) WHERE a.s not in ('1', '2', '3', '4')`,
ExpectedPlan: "Project(a.i, a.s)\n" +
" └─ IndexedJoin(a.i = b.s)\n" +
" ├─ Filter(NOT((a.s HASH IN (\"1\", \"2\", \"3\", \"4\"))))\n" +
" ├─ Filter(NOT((a.s HASH IN ('1', '2', '3', '4'))))\n" +
" │ └─ TableAlias(a)\n" +
" │ └─ IndexedTableAccess(mytable on [mytable.s] with ranges: [{(1, 2)}, {(2, 3)}, {(3, 4)}, {(4, ∞)}, {(-∞, 1)}])\n" +
" └─ TableAlias(b)\n" +
Expand Down Expand Up @@ -540,21 +540,21 @@ var PlanTests = []QueryPlanTest{
},
{
Query: `SELECT * from mytable where upper(s) IN ('FIRST ROW', 'SECOND ROW')`,
ExpectedPlan: "Filter(UPPER(mytable.s) HASH IN (\"FIRST ROW\", \"SECOND ROW\"))\n" +
ExpectedPlan: "Filter(UPPER(mytable.s) HASH IN ('FIRST ROW', 'SECOND ROW'))\n" +
" └─ Projected table access on [i s]\n" +
" └─ Table(mytable)\n" +
"",
},
{
Query: `SELECT * from mytable where cast(i as CHAR) IN ('a', 'b')`,
ExpectedPlan: "Filter(convert(mytable.i, char) HASH IN (\"a\", \"b\"))\n" +
ExpectedPlan: "Filter(convert(mytable.i, char) HASH IN ('a', 'b'))\n" +
" └─ Projected table access on [i s]\n" +
" └─ Table(mytable)\n" +
"",
},
{
Query: `SELECT * from mytable where cast(i as CHAR) IN ('1', '2')`,
ExpectedPlan: "Filter(convert(mytable.i, char) HASH IN (\"1\", \"2\"))\n" +
ExpectedPlan: "Filter(convert(mytable.i, char) HASH IN ('1', '2'))\n" +
" └─ Projected table access on [i s]\n" +
" └─ Table(mytable)\n" +
"",
Expand Down Expand Up @@ -1908,15 +1908,15 @@ var PlanTests = []QueryPlanTest{
ExpectedPlan: "Sort(othertable.i2 ASC)\n" +
" └─ Project(row_number() over ( order by [othertable.s2, idx=0, type=TEXT, nullable=false] ASC) as idx, othertable.i2, othertable.s2)\n" +
" └─ Window(row_number() over ( order by [othertable.s2, idx=0, type=TEXT, nullable=false] ASC), othertable.i2, othertable.s2)\n" +
" └─ Filter(NOT((othertable.s2 = \"second\")))\n" +
" └─ Filter(NOT((othertable.s2 = 'second')))\n" +
" └─ Projected table access on [i2 s2]\n" +
" └─ IndexedTableAccess(othertable on [othertable.s2] with ranges: [{(second, ∞)}, {(-∞, second)}])\n" +
"",
},
{
Query: `SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY s2 ASC) idx, i2, s2 FROM othertable ORDER BY i2 ASC) a WHERE s2 <> 'second'`,
ExpectedPlan: "SubqueryAlias(a)\n" +
" └─ Filter(NOT((othertable.s2 = \"second\")))\n" +
" └─ Filter(NOT((othertable.s2 = 'second')))\n" +
" └─ Sort(othertable.i2 ASC)\n" +
" └─ Project(row_number() over ( order by [othertable.s2, idx=0, type=TEXT, nullable=false] ASC) as idx, othertable.i2, othertable.s2)\n" +
" └─ Window(row_number() over ( order by [othertable.s2, idx=0, type=TEXT, nullable=false] ASC), othertable.i2, othertable.s2)\n" +
Expand Down
18 changes: 9 additions & 9 deletions enginetest/queries/script_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -1593,18 +1593,18 @@ var ScriptTests = []ScriptTest{
"alter table t2 add constraint t2du unique (d)",
"alter table t2 add constraint fk1 foreign key (d) references t1 (b)",
"create table t3 (a int, b varchar(100), c datetime, primary key (b,a))",
"create table t4 (a int default floor(1), b int default coalesce(a, 10))",
"create table t4 (a int default (floor(1)), b int default (coalesce(a, 10)))",
},
Assertions: []ScriptTestAssertion{
{
Query: "show create table t1",
Expected: []sql.Row{
{"t1", "CREATE TABLE `t1` (\n" +
" `a` int NOT NULL,\n" +
" `b` varchar(10) NOT NULL DEFAULT \"abc\",\n" +
" `b` varchar(10) NOT NULL DEFAULT 'abc',\n" +
" PRIMARY KEY (`a`),\n" +
" KEY `t1b` (`b`),\n" +
" CONSTRAINT `ck1` CHECK (`b` LIKE \"%abc%\")\n" +
" CONSTRAINT `ck1` CHECK (`b` LIKE '%abc%')\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
Expand Down Expand Up @@ -2019,7 +2019,7 @@ var SpatialScriptTests = []ScriptTest{
{
Name: "create table using default point value",
SetUpScript: []string{
"CREATE TABLE test (i int primary key, p point default point(123.456, 7.89));",
"CREATE TABLE test (i int primary key, p point default (point(123.456, 7.89)));",
"insert into test (i) values (0);",
},
Assertions: []ScriptTestAssertion{
Expand All @@ -2040,7 +2040,7 @@ var SpatialScriptTests = []ScriptTest{
{
Name: "create table using default linestring value",
SetUpScript: []string{
"CREATE TABLE test (i int primary key, l linestring default linestring(point(1,2), point(3,4)));",
"CREATE TABLE test (i int primary key, l linestring default (linestring(point(1,2), point(3,4))));",
"insert into test (i) values (0);",
},
Assertions: []ScriptTestAssertion{
Expand All @@ -2061,7 +2061,7 @@ var SpatialScriptTests = []ScriptTest{
{
Name: "create table using default polygon value",
SetUpScript: []string{
"CREATE TABLE test (i int primary key, p polygon default polygon(linestring(point(0,0), point(1,1), point(2,2), point(0,0))));",
"CREATE TABLE test (i int primary key, p polygon default (polygon(linestring(point(0,0), point(1,1), point(2,2), point(0,0)))));",
"insert into test (i) values (0);",
},
Assertions: []ScriptTestAssertion{
Expand All @@ -2082,7 +2082,7 @@ var SpatialScriptTests = []ScriptTest{
{
Name: "create geometry table using default point value",
SetUpScript: []string{
"CREATE TABLE test (i int primary key, g geometry default point(123.456, 7.89));",
"CREATE TABLE test (i int primary key, g geometry default (point(123.456, 7.89)));",
"insert into test (i) values (0);",
},
Assertions: []ScriptTestAssertion{
Expand All @@ -2103,7 +2103,7 @@ var SpatialScriptTests = []ScriptTest{
{
Name: "create geometry table using default linestring value",
SetUpScript: []string{
"CREATE TABLE test (i int primary key, g geometry default linestring(point(1,2), point(3,4)));",
"CREATE TABLE test (i int primary key, g geometry default (linestring(point(1,2), point(3,4))));",
"insert into test (i) values (0);",
},
Assertions: []ScriptTestAssertion{
Expand All @@ -2124,7 +2124,7 @@ var SpatialScriptTests = []ScriptTest{
{
Name: "create geometry table using default polygon value",
SetUpScript: []string{
"CREATE TABLE test (i int primary key, g geometry default polygon(linestring(point(0,0), point(1,1), point(2,2), point(0,0))));",
"CREATE TABLE test (i int primary key, g geometry default (polygon(linestring(point(0,0), point(1,1), point(2,2), point(0,0)))));",
"insert into test (i) values (0);",
},
Assertions: []ScriptTestAssertion{
Expand Down
27 changes: 23 additions & 4 deletions sql/analyzer/resolve_column_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package analyzer
import (
"strings"

"github.com/dolthub/vitess/go/sqltypes"

"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/expression"
"github.com/dolthub/go-mysql-server/sql/parse"
Expand Down Expand Up @@ -672,16 +674,33 @@ func resolveColumnDefaultsOnWrapper(ctx *sql.Context, col *sql.Column, e *expres
err = sql.ErrInvalidColumnDefaultFunction.New(funcName, col.Name)
return false
}
if (funcName == "now" || funcName == "current_timestamp") &&
newDefault.IsLiteral() &&
(!sql.IsTime(col.Type) || sql.Date == col.Type) {
err = sql.ErrColumnDefaultDatetimeOnlyFunc.New()
if newDefault.IsLiteral() {
if funcName == "now" || funcName == "current_timestamp" {
if col.Type.Type() == sqltypes.Datetime || col.Type.Type() == sqltypes.Timestamp {
return true
} else {
err = sql.ErrColumnDefaultDatetimeOnlyFunc.New()
return false
}
}
err = sql.ErrInvalidColumnDefaultValue.New(col.Name)
return false
}

return true
case *plan.Subquery:
err = sql.ErrColumnDefaultSubquery.New(col.Name)
return false
case *deferredColumn:
err = sql.ErrInvalidColumnDefaultValue.New(col.Name)
return false
case *expression.GetField:
if newDefault.IsLiteral() {
err = sql.ErrInvalidColumnDefaultValue.New(col.Name)
return false
} else {
return true
}
default:
return true
}
Expand Down
5 changes: 2 additions & 3 deletions sql/analyzer/resolve_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,10 @@ func resolveTable(ctx *sql.Context, t sql.UnresolvedTable, a *Analyzer) (sql.Nod
}

a.Log("table resolved: %s", t.Name())
res := plan.NewResolvedTable(rt, database, nil)
if asofBindVar {
return plan.NewDeferredAsOfTable(res, t.AsOf()), nil
return plan.NewDeferredAsOfTable(resolvedTableNode, t.AsOf()), nil
}
return res, nil
return resolvedTableNode, nil
}

// handleInfoSchemaColumnsTable modifies the detected information_schema.columns table and adds a large set of colums
Expand Down
3 changes: 3 additions & 0 deletions sql/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ var (
// ErrColumnDefaultSubquery is returned when a default value contains a subquery.
ErrColumnDefaultSubquery = errors.NewKind("default value on column `%s` may not contain subqueries")

// ErrInvalidColumnDefaultValue is returned when column default function value is not wrapped in parentheses for column types excluding datetime and timestamp
ErrInvalidColumnDefaultValue = errors.NewKind("Invalid default value for '%s'")

// ErrInvalidDefaultValueOrder is returned when a default value references a column that comes after it and contains a default expression.
ErrInvalidDefaultValueOrder = errors.NewKind(`default value of column "%s" cannot refer to a column defined after it if those columns have an expression default value`)

Expand Down
2 changes: 1 addition & 1 deletion sql/expression/function/math_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestRandWithSeed(t *testing.T) {
assert.Equal(t, f64, f642)

r, _ = NewRand(expression.NewLiteral("not a number", sql.LongText))
assert.Equal(t, `RAND("not a number")`, r.String())
assert.Equal(t, `RAND('not a number')`, r.String())

f, err = r.Eval(nil, nil)
require.NoError(t, err)
Expand Down
Loading

0 comments on commit 51dc04e

Please sign in to comment.