@@ -242,8 +242,6 @@ __hidden int add_selection(struct sqlhist_bison *sb, void *select,
case EXPR_FIELD:
break;
case EXPR_COMPARE:
- if (!name)
- return -1;
expr->compare.name = name;
break;
case EXPR_NUMBER:
@@ -692,6 +690,9 @@ static int build_compare(struct tracefs_synth *synth,
enum tracefs_synth_calc calc;
int ret;
+ if (!compare->name)
+ return -1;
+
lval = &compare->lval->field;
rval = &compare->rval->field;
@@ -1069,6 +1070,14 @@ static void compare_error(struct tep_handle *tep,
{
struct compare *compare = &expr->compare;
+ if (!compare->name) {
+ sb->line_no = expr->line;
+ sb->line_idx = expr->idx + strlen("no name");
+
+ parse_error(sb, "no name",
+ "Field calculations must be labeled 'AS name'\n");
+ }
+
switch (errno) {
case ENODEV:
case EBADE: