TiDB Optimistic Transactions/Pessimistic Transactions C/C++ Examples

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

Original topic: tidb 乐观事务/悲观事务c/c++范例

| username: ljh_wxy

【TiDB Usage Environment】TiDB Feature Research Environment
【TiDB Version】v5.4.1
【Encountered Problem】Is there a usage example for C/C++ API interface? How to enable optimistic/pessimistic transactions?
【Reproduction Path】None
【Problem Phenomenon and Impact】None

【Attachment】None

| username: Min_Chen | Original post link

Hello, which API are you referring to? The MySQL client or the TiDB server HTTP API?

| username: ljh_wxy | Original post link

Yes, mysql client

| username: ShawnYan | Original post link

Here are examples in Java/Golang that you can refer to:

# Pessimistic Transaction
connection.createStatement().executeUpdate(txnComment + "begin pessimistic");
# Optimistic Transaction
connection.createStatement().executeUpdate(txnComment + "begin optimistic");
| username: system | Original post link

This topic was automatically closed 1 minute after the last reply. No new replies are allowed.