diff --git a/planner/core/preprocess.go b/planner/core/preprocess.go index 1ec6008c5bc65..628658515d413 100644 --- a/planner/core/preprocess.go +++ b/planner/core/preprocess.go @@ -562,6 +562,11 @@ func (p *preprocessor) checkCreateTableGrammar(stmt *ast.CreateTableStmt) { p.err = ddl.ErrWrongTableName.GenWithStackByArgs(tName) return } + enableNoopFuncs := p.ctx.GetSessionVars().EnableNoopFuncs + if stmt.IsTemporary && !enableNoopFuncs { + p.err = expression.ErrFunctionsNoopImpl.GenWithStackByArgs("CREATE TEMPORARY TABLE") + return + } countPrimaryKey := 0 for _, colDef := range stmt.Cols { if err := checkColumn(colDef); err != nil { @@ -669,6 +674,11 @@ func (p *preprocessor) checkDropSequenceGrammar(stmt *ast.DropSequenceStmt) { func (p *preprocessor) checkDropTableGrammar(stmt *ast.DropTableStmt) { p.checkDropTableNames(stmt.Tables) + enableNoopFuncs := p.ctx.GetSessionVars().EnableNoopFuncs + if stmt.IsTemporary && !enableNoopFuncs { + p.err = expression.ErrFunctionsNoopImpl.GenWithStackByArgs("DROP TEMPORARY TABLE") + return + } } func (p *preprocessor) checkDropTableNames(tables []*ast.TableName) { diff --git a/planner/core/preprocess_test.go b/planner/core/preprocess_test.go index 394a3fe273f4c..14b006c836ca9 100644 --- a/planner/core/preprocess_test.go +++ b/planner/core/preprocess_test.go @@ -288,6 +288,10 @@ func (s *testValidatorSuite) TestValidator(c *C) { {"select CONVERT( 2, DECIMAL(30,65) )", true, types.ErrMBiggerThanD.GenWithStackByArgs("2")}, {"select CONVERT( 2, DECIMAL(66,99) )", true, types.ErrMBiggerThanD.GenWithStackByArgs("2")}, + // https://github.com/pingcap/parser/issues/609 + {"CREATE TEMPORARY TABLE t (a INT);", false, expression.ErrFunctionsNoopImpl.GenWithStackByArgs("CREATE TEMPORARY TABLE")}, + {"DROP TEMPORARY TABLE t;", false, expression.ErrFunctionsNoopImpl.GenWithStackByArgs("DROP TEMPORARY TABLE")}, + // TABLESAMPLE {"select * from t tablesample bernoulli();", false, expression.ErrInvalidTableSample}, {"select * from t tablesample bernoulli(10 rows);", false, expression.ErrInvalidTableSample},