Skip to content

Commit

Permalink
sql/parser: fix the action for empty rules
Browse files Browse the repository at this point in the history
A yacc-generated parser is a giant switch in a loop and the data
structure is a stack implemented as indexes into an array. Each
occurrence of `$$.val` is really `thestack[curpos].val`. Unless one
nils things out in the rule action the previous value remains.

(That's true of all yacc generators that don't provide destructors for
values. GNU Bison and Lemon provide destructors, for example, goyacc
and old Bison don't)

Release note (bug fix): the `WITH` operand of
import/export/backup/restore was sometimes processed improperly. This
has been corrected.

Release note (bug fix): common table expressions with `WITH` in larger
queries were sometimes processed improperly. This has been corrected.
  • Loading branch information
knz committed Sep 13, 2018
1 parent 40ec553 commit 9f1e6a9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,10 @@ opt_with_options:
{
$$.val = $4.kvOptions()
}
| /* EMPTY */ {}
| /* EMPTY */
{
$$.val = nil
}
copy_from_stmt:
COPY table_name opt_column_list FROM STDIN
Expand Down Expand Up @@ -5255,7 +5258,10 @@ opt_with_clause:
{
$$.val = $1.with()
}
| /* EMPTY */ {}
| /* EMPTY */
{
$$.val = nil
}

opt_table:
TABLE {}
Expand Down

0 comments on commit 9f1e6a9

Please sign in to comment.