vitessio / vitess

Vitess is a database clustering system for horizontal scaling of MySQL.
http://vitess.io
Apache License 2.0
18.23k stars 2.07k forks source link

Bug Report: evalengine TypeOf for Columns #13149

Closed systay closed 10 months ago

systay commented 1 year ago

While working on other parts of Vitess, we encountered this issue. The faulty code is:

func (c *Column) typeof(env *ExpressionEnv, fields []*querypb.Field) (sqltypes.Type, typeFlag) {
    // if we have an active row in the expression Env, use that as an authoritative source
    if c.Offset < len(env.Row) {
        value := env.Row[c.Offset]
        if value.IsNull() {
            return sqltypes.Null, flagNull | flagNullable
        }
        return value.Type(), typeFlag(0)
    }
// cut for brevity

The issue with this code is the NULL handling - for queries with outer joins, some rows can contain null values for a given column, and some will not. We need a better fallback for these situations.

vmg commented 10 months ago

We actually fixed this!