Are there any alternatives when TiDB does not support MySQL triggers?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 在tidb不支持mysql触发器的情况下,有无可代替方案?

| username: TiDBer_UfzQKQ1w

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version] 6.6
[Reproduction Path] Operations performed that led to the issue: None
[Encountered Issue: Issue Phenomenon and Impact: In the case where TiDB does not support MySQL triggers, is there an alternative solution? The requirement is to trigger SQL to insert data into the log table whenever a new row is added to the table.
[Resource Configuration] Enter TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots / Logs / Monitoring]

| username: tidb菜鸟一只 | Original post link

  1. Modify the application to insert data into the log table when adding new data.
  2. Use TiCDC to synchronize database changes to Kafka, then have the server consume Kafka messages to insert data into the log table.
| username: redgame | Original post link

Similar to my situation… I am a stored procedure.

| username: TiDBer_UfzQKQ1w | Original post link

Bro, please help.

| username: yiduoyunQ | Original post link

ticdc + kafka + application on-demand consumption

| username: zhanggame1 | Original post link

Foreign keys will only be available in version 6.6, and I estimate that triggers and stored procedures will be available in version 10 or later.

| username: Anna | Original post link

  1. Modify the application to insert data into the log table when adding new data.
  2. Use TiCDC to synchronize database changes to Kafka, then have the server consume Kafka messages to insert data into the log table.
| username: Jiawei | Original post link

The simplest way is to just make a small change to the code. It’s very easy to implement; just call a function to write to the log table when inserting. This requires minimal changes. Otherwise, using TiCDC Kafka would be more complicated.

| username: yulei7633 | Original post link

This requires an official release of a new version to support it, right?

| username: linnana | Original post link

It needs to be implemented at the application layer.