tencent cloud

Feedback

Passthrough SQL

Last updated: 2024-01-06 17:34:56
TDSQL for MySQL parses SQL syntax, which restricts SQL execution. If you want to execute SQL statements supported by MySQL but not by TDSQL on a set, you can pass through the SQL statements.
Note:
The proxy will not parse an SQL statement that is passed through. If it is a passthrough write operation to two sets, distributed transactions will not be used, which may cause inconsistency in extreme cases. Therefore, we recommend you pass through only to one set in a single write operation.
To ensure that the passthrough syntax takes effect, add the -c parameter when connecting to MySQL.
MySQL [test]> repair table test.t1;
ERROR 664 (HY000): Proxy ERROR:SQL is too complex, only applicable to noshard table: Shard table do not support repair
MySQL [test]> /*sets:allsets*/repair table test.t1;
+---------+--------+----------+----------+------------------+
| Table | Op | Msg_type | Msg_text | info |
+---------+--------+----------+----------+------------------+
| test.t1 | repair | status | OK | set_1544429866_3 |
| test.t1 | repair | status | OK | set_1544429718_1 |
+---------+--------+----------+----------+------------------+
2 rows in set (0.01 sec)
Syntax:
sets:set_1,set_2: it is used to specify the sets to which SQL statements will be passed through. The set name can be queried by /*proxy*/show status.
sets:allsets: it indicates that SQL statements will be passed through to all sets.
shardkey:10: it indicates that SQL statements will be passed through to the set according to the specified shardkey.
shardkey_hash:10: it indicates that SQL statements will be passed through to the set where its specified hash value is 10. If shardkey_hash is set to 0, SQL statements will be passed through to the first set.
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support