@@ -98,65 +98,6 @@ func resolveInsertRows(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Sc
9898 return transform .NodeWithCtx (n , selFunc , ctxFunc )
9999}
100100
101- func validateInsertRows (ctx * sql.Context , a * Analyzer , n sql.Node , scope * plan.Scope , sel RuleSelector , qFlags * sql.QueryFlags ) (sql.Node , transform.TreeIdentity , error ) {
102- if _ , ok := n .(* plan.TriggerExecutor ); ok {
103- return n , transform .SameTree , nil
104- } else if _ , ok := n .(* plan.CreateProcedure ); ok {
105- return n , transform .SameTree , nil
106- }
107- // We capture all INSERTs along the tree, such as those inside of block statements.
108- var err error
109- transform .Inspect (n , func (n sql.Node ) bool {
110- insert , ok := n .(* plan.InsertInto )
111- if ! ok {
112- return true
113- }
114-
115- var insertable sql.InsertableTable
116- table := getResolvedTable (insert .Destination )
117- insertable , err = plan .GetInsertable (table )
118- if err != nil {
119- return false
120- }
121-
122- source := insert .Source
123- dstSchema := insertable .Schema ()
124-
125- // normalize the column name
126- columnNames := make ([]string , len (insert .ColumnNames ))
127- for i , name := range insert .ColumnNames {
128- columnNames [i ] = strings .ToLower (name )
129- }
130-
131- // If no columns are given and value tuples are not all empty, use the full schema
132- if len (columnNames ) == 0 && existsNonZeroValueCount (source ) {
133- columnNames = make ([]string , len (dstSchema ))
134- for i , f := range dstSchema {
135- columnNames [i ] = f .Name
136- }
137- }
138-
139- for _ , col := range dstSchema {
140- colIdx := findColIdx (col .Name , columnNames )
141- if colIdx != - 1 {
142- continue
143- }
144-
145- if _ , isTrigExec := source .(* plan.TriggerExecutor ); ! isTrigExec && ! col .AutoIncrement && ! col .Nullable && col .Default == nil && col .Generated == nil {
146- err = sql .ErrInsertIntoNonNullableDefaultNullColumn .New (col .Name )
147- return false
148- }
149- }
150-
151- return true
152- })
153-
154- if err != nil {
155- return nil , transform .SameTree , err
156- }
157- return n , transform .SameTree , nil
158- }
159-
160101// Ensures that the number of elements in each Value tuple is empty
161102func existsNonZeroValueCount (values sql.Node ) bool {
162103 switch node := values .(type ) {
0 commit comments