Skip to main content

Posts

Showing posts from August, 2023

Tutorial: Add a QRCODE() function to TiDB

The code for this tutorial is available here . Objectives This tutorial demonstrates how easy it is to add a new function to TiDB that can be used in a SQL-statement. We want to add a function for creating QRCodes. TiDB is aiming to be compatible with MySQL . However as the functionality we’re adding doesn’t exist in MySQL this isn’t a real concern. For reference here is the architecture of a TiDB cluster: We’re only going to add the function to TiDB (in red in the above image), which means this can’t be pushed down to TiKV or TiFlash , however for this function that’s fine. The TiDB Development Guide has a page that describes some of this and more. When adding functions to TiDB you should aim for things that can be merged into upstream TiDB instead of running and maintaining your own fork. Might be good to discuss your plans in a GitHub issue before actually starting to do any work. Step 1: Adding the function to the parser For this open parser/ast/functions.go and add th...