Skip to main content
Version: v2.6

Seata-go AT Mode SQL Support

This document details the current support status of Seata-go for DML statements, SQL clauses and modifiers, and various functions in AT mode. It is recommended to write business SQL within the limits of this article to ensure the stability and data consistency of distributed transactions.

Usage restrictions

  • Nested queries are not supported
  • Stored procedures and triggers are not supported
  • Does not support multi-table complex SQL (Currently, only MySQL database supports the UPDATE JOIN statement; other multi-table complex joins are not yet supported)
  • Some databases do not support batch updates. Batch updates are supported when using MySQL as the database.

DML Statement Support

The AT mode currently supports the core functions of three types of DML syntax: INSERT, UPDATE, and DELETE.

TypeSQL ExamplesSupport
INSERTINSERT INTO tb1 (col_name,...) VALUES (...);Yes
INSERT ON DUPLICATEINSERT INTO tb1 (...) VALUES (...) ON DUPLICATE KEY UPDATE ...;Yes
UPDATEUPDATE tb1 SET col_name1=expr1 WHERE where_definition;Yes
UPDATE JOINUPDATE tb1 JOIN tb2 ON tb1.id=tb2.id SET tb1.col=expr;Yes (Supported by MySQL)
DELETEDELETE FROM tb1 WHERE where_definition;Yes
SELECTSELECT select_expr, ... FROM tb1 WHERE where_definition;Yes
REPLACEREPLACE INTO tb1 (...) VALUES (...);No
TRUNCATETRUNCATE TABLE tb1;No

SQL Clauses and Modifiers

Seata-go's transaction isolation level defaults to read uncommitted. In this mode, the SQL modifiers usage of select statements in this article's table is supported; using the FOR UPDATE proxy can make Seata achieve read committed. In this mode, the usage of select statements can only be partially supported.

DML Statement Support

In the WHERE condition of UPDATE or DELETE statements, the following conditions are supported:

TypeDescription
AND & ORSupports multi-condition logical combinations
LIKESupports fuzzy queries and wildcards (e.g., LIKE 'NE%')
BETWEENSupports range condition queries

Select Statement Support

TypeSQL ExamplesRead UncommittedRead Committed
Basic conditionsSELECT ... WHERE col1=ex1 AND col2=ex2YesYes
Sorting and groupingORDER BY / GROUP BYYesYes
Fuzzy queriesLIKE / Wildcard %YesYes
Sub-conditions/rangesEXISTS / IN / BETWEENYesYes
Aliases mechanismSELECT t1.col FROM tb1 AS t1YesYes
Result set paginationTOP / LIMITYesYes
Join queriesINNER / LEFT / RIGHT / FULL JOINYesNo
Union resultsUNION / UNION ALLYesNo

Functions Support

It is important to note that when using functions in DML statements, they cannot be used as primary key columns or applied to primary key fields, otherwise it will cause Seata-go to fail to accurately locate data rows when building the before/after image of the data.

Scalar Functions

In DQL statements and DML statements (non-primary key column assignment and condition filtering), the following standard functions are supported:

  • String functions: CONCAT, INSTR, LCASE, UCASE, LEFT, RIGHT, LENGTH, LOCATE, LPAD, RPAD, LTRIM, RTRIM, TRIM, REPEAT, REPLACE, STRCMP, SUBSTRING, SPACE, LOAD_FILE
  • Numeric functions: ABS, BIN, CEILING, FLOOR, CONV, FORMAT, HEX, LEAST, MOD, POWER, RAND, ROUND, SIGN, SQRT
  • Date and time functions: NOW, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DATE, DATE_ADD, DATE_SUB, DATE_FORMAT, STR_TO_DATE, DATEDIFF, TIMEDIFF, TIME_TO_SEC, SEC_TO_TIME, ADDTIME, CONVERT_TZ, EXTRACT, LAST_DAY, MAKEDATE, MAKETIME, YEAR, MONTH, MONTHNAME, DAY, DAYNAME, HOUR, MINUTE, MICROSECOND, DAYOFMONTH, DAYOFWEEK, DAYOFYEAR, WEEK

Aggregate Functions

Aggregate functions (such as SUM, COUNT, etc.) will change the structure of the returned result set, and their support is limited by the current transaction isolation level:

TypeIn DML StatementsRead UncommittedRead Committed
FIRST()NoYesNo
LAST()NoYesNo
MIN()NoYesNo
MAX()NoYesNo
AVG()NoYesNo
SUM()NoYesNo
COUNT()NoYesNo

Complex Scenarios and Restrictions Not Yet Supported

  1. Multi-database ecosystem support
    • Java: Supports MySQL, Oracle, PostgreSQL, TiDB, MariaDB, Dameng DB, and SQLServer.
    • Go: Only supports MySQL.
  2. SQL nesting and complex subqueries
    • Java: Supports embedding simple subqueries in the WHERE condition to lock rows.
    • Go: Not supported. It cannot complete correct row positioning and snapshot assembly when encountering nested AST trees.
  3. Primary key generation strategies in non-MySQL ecosystems
    • Java: Can proxy and recognize Oracle's SEQUENCE and PostgreSQL's SERIAL mechanisms.
    • Go: Not supported. Due to the lack of corresponding driver adaptation, the backfilled primary keys cannot be captured in these non-MySQL scenarios.
  4. Complex aliases and keyword parsing
    • Java: Can clearly identify multi-layer AS alias nesting and accurately map it back to the physical original table.
    • Go: When facing multi-layer AS nesting or field names that happen to hit MySQL keywords (such as key, desc) with complex aliases, it is prone to parsing errors of "cannot find the original column name".
  5. Differences in REPLACE INTO statements
    • Java: Strict interception at the entry point. Once this syntax is recognized during parsing, an unsupported exception will be thrown directly.
    • Go: Although the parser can recognize this syntax, the underlying execution and rollback files are not written, and business calls may cause distributed dirty data in the second phase.