pingcap / pingcap/tidb

Why does `PBToExpr` build new field type but not use the existing one in pb?

Open
#37,435 2 comments 0 reactions 0 assignees View on GitHub
type/question
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## General Question

The function `(github.com/pingcap/tidb/expression).PBToExpr` receives an argument: `expr *tipb.Expr`. Some of the branches use the field type in `expr.FieldType`, but some of them (e.g. `ExprType_Int64`...) doesn't use, but build a new one through `types.NewFieldType(mysql.TypeLongLong)`.

Is it correct to always use the field type converted from `PbTypeToFieldType`? As the current implementation will loss all flag information.

In #37404, I'll use `PbTypeToFieldType` for `Int64`. If it's right to always use `PbTypeToFieldType` to get the type (rather than build a new one), I'll submit another PR to migrate all of them.

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.