-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Function description:
This function is added to TiDB for PostgreSQL as a new function point. At present, only a few common interfaces are implemented, and some need to be implemented. Such as NominalSort, basePhysicalAgg, PhysicalBroadCastJoin and other structures also need to implement this method.
The function of this function is to find the parameter type in the plan tree and save it to prepared.Param in the global variable sessionVars. It is expected that these types of data will be used in the subsequent stages of the expansion query.
This is a brand new feature, and there is no similar requirement in TiDB. This is a new requirement caused by the difference between PostgreSQL extended query and MySQL pre-query message protocol.
The main modification directory is the planner/core directory, which is the most centralized directory. Here is the definition file of each sub-plan, and also contains the declaration to implement SetParamType(). There are already some interface methods for sub-projects. For example, SetParamType() of LogicalSelection.
According to the current situation of implementing the interface, it can meet the needs of general expansion queries, because we have implemented part of the interface logic. But if you encounter something that has not been implemented, such as an extended query that contains a sub-plan: PhysicalHashAgg, because the SetParamType() method of PhysicalHashAgg is not implemented, there is no way to get the parameter type data from it.
Therefore, after the function is fully implemented, it is expected that even if the plan contains rare sub-plans such as PhysicalBroadCastJoin, PhysicalIndexLookUpReader, etc., the correct data type can still be obtained.
Task list:
-
Implement the SetParamType() method of LogicalPlan
-
Implement the SetParamType() method of PhysicalPlan
The above two codes are concentrated in planner/core/plan.go. If you are using goland, you can click the "implementation" item on the left side of the interface method in the LogicalPlan or PhysicalPlan interface, and you can see the sub-plans that need to implement SetParamType.
To be implemented
The following is the implementation of the setparamType method in the sub-plan. The ticked description has been completed. The rest has yet to be implemented.
- BatchPointGetPlan
- NominalSort
- PhysicalApply
- PhysicalBroadCastJoin
- PhysicalHashAgg
- PhysicalHashJoin
- PhysicalIndexJoin
- PhysicalIndexLookUpReader
- PhysicalIndexMergeReader
- PhysicalIndexReader
- PhysicalIndexScan
- PhysicalLimit
- PhysicalLock
- PhysicalMaxOneRow
- PhysicalMemTable
- PhysicalMergeJoin
- PhysicalProjection
- PhysicalSelection
- PhysicalShow
- PhysicalShowDDLJobs
- PhysicalShuffle
- PhysicalShuffleDataSourceStub
- PhysicalSort
- PhysicalStreamAgg
- PhysicalTableDual
- PhysicalTableReader
- PhysicalTableScan
- PhysicalTopN
- PhysicalUnionAll
- PhysicalUnionScan
- PhysicalWindow
- PointGetPlan
- basePhysicalAgg
- DataSource
- LogicalAggregation
- LogicalIndexScan
- LogicalJoin
- LogicalLimit
- LogicalLock
- LogicalMaxOneRow
- LogicalMemTable
- LogicalProjection
- LogicalSelection
- LogicalShow
- LogicalShowDDLJobs
- LogicalSort
- LogicalTableDual
- LogicalTableScan
- LogicalTopN
- LogicalUnionAll
- LogicalUnionScan
- LogicalWindow
- TiKVSingleGather
Besides, PostgreSQL extend query :https://www.postgresql.org/docs/current/protocol.htm
Expected Results
Parameter types can be obtained from all sub-plans