Skip to content

expression: enable SHA2 function pushdown to TiKV coprocessor #67087

@joechenrh

Description

@joechenrh

Feature Request

Enable the SHA2 function to be pushed down to TiKV for coprocessor evaluation.

Background

TiKV already implements SHA2 in its coprocessor (components/tidb_query_expr/src/impl_encryption.rs), supporting all hash lengths (SHA-0/224/256/384/512). The TiDB side also has:

  • PbCode mapping: tipb.ScalarFuncSig_SHA2 (in builtin_encryption.go)
  • distsql deserialization support (in distsql_builtin.go)

However, SHA2 is missing from the scalarExprSupportedByTiKV allowlist in infer_pushdown.go, so it is never pushed down to TiKV. MD5 and SHA1 are already in the list.

Motivation

Pushing SHA2 down to TiKV reduces data transfer and allows TiKV to evaluate SHA2 in WHERE clauses locally, improving query performance for SHA2-based filtering.

Related: pingcap/tidb-tools#886

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions