How to Read TiDB Source Code (Part 3)

In the previous article, we introduced methods for viewing syntax and configurations. In this article, we will discuss how to view system variables, including default values, scopes, and how to monitor metrics. System Variables The system variable names in TiDB are defined in tidb_vars.go. This file also includes some default values for variables, but the place where they are actually assembled is defaultSysVars. This large struct array defines the scope, variable names, and default values for all variables in TiDB. Besides TiDB’s own system variables, it also includes compatibility with MySQL’s system variables. ...

July 28, 2020 · 8 min · 1648 words · Jack Yu

How to Read TiDB Source Code (Part 2)

Continuing from the previous article, we learned how to set up the environment for reading code and where to start reading the code. In this part, we’ll introduce methods for viewing code based on some common needs. How to Check the Support Level of a Syntax There are usually two methods: Check through the parser repo Directly check within the TiDB repo Both of these methods require the environment setup from the previous article. If you haven’t tried that yet, give it a go. ...

July 12, 2020 · 4 min · 791 words · Jack Yu

How to Read TiDB Source Code (Part 1)

Background There are many articles on reading the source code of TiDB, often referred to as the “Twenty-Four Chapters Scriptures”. However, these introductions typically proceed from a macro to a micro perspective. This series attempts to introduce how to read TiDB’s source code from an easier angle. The goals we aim to achieve are: Enable readers to start reading TiDB’s code themselves, rather than understanding it passively through pre-written articles. Provide some common examples of looking into the details of the code, such as examining the scope of a variable. After all, teaching people to fish is better than giving them fish. While the code changes often, the methods remain mostly unchanged. ...

July 6, 2020 · 6 min · 1247 words · Jack Yu