pingcap / pingcap/tidb

planner: output an error for `create global binding using ... if(col=?) ...`

Open
#68,805 1 comment 0 reactions 0 assignees View on GitHub
component/spm report/customer sig/planner type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

See the case below, `if(col=?)` is a wrong syntax, so the optimizer should return an error in this case.
And we can see that for normal statements and bindings with actual values, the optimizer returns the error, which is correct.
But when changing the `if(col=1)` to `if(col=?)`, the optimizer doesn't return an error, which is unexpected.

```
mysql> select * from t where if(a=1);
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'if'
mysql> create global binding using select * from t where if(a=1);
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'if'
mysql> create global binding using select * from t where if(a=?);
Query OK, 0 rows affected (0.006 sec)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.