Skip to main content

polardbx-sql-compat

MySQL to PolarDB-X compatibility checks, Sequence usage, and distributed transactions for PolarDB-X 2.0 Enterprise Edition AUTO mode. Use when migrating MySQL SQL to PolarDB-X, checking compatibility differences, using Sequence, or understanding distributed transaction behavior. Triggers: "MySQL兼容性", "MySQL compatibility", "迁移PolarDB-X", "migrate to PolarDB-X", "Sequence", "自增", "AUTO_INCREMENT", "分布式事务", "distributed transaction", "不支持的语法", "unsupported syntax", "TSO", "XA"

설치로 이동

소스 정보

저장소
polardb/polardbx-sql
최근 소스 활동
2026년 9월 20일 04:37
감지된 SKILL.md 언어
영어
스타
1,686
포크
337

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

파일 탐색기
5 개 파일

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
polardbx-sql-compat
description
MySQL to PolarDB-X compatibility checks, Sequence usage, and distributed transactions for PolarDB-X 2.0 Enterprise Edition AUTO mode. Use when migrating MySQL SQL to PolarDB-X, checking compatibility differences, using Sequence, or understanding distributed transaction behavior. Triggers: "MySQL兼容性", "MySQL compatibility", "迁移PolarDB-X", "migrate to PolarDB-X", "Sequence", "自增", "AUTO_INCREMENT", "分布式事务", "distributed transaction", "不支持的语法", "unsupported syntax", "TSO", "XA"
metadata
{"version":"0.2.0"}
# PolarDB-X SQL Compatibility & Diagnostics MySQL to PolarDB-X compatibility checks, Sequence usage, and distributed transactions for PolarDB-X 2.0 Enterprise Edition AUTO mode. **Scope**: PolarDB-X 2.0 Enterprise Edition + AUTO mode database only. Not applicable to: - PolarDB-X 1.0 (DRDS 1.0) - PolarDB-X 2.0 Standard Edition - PolarDB-X 2.0 Enterprise Edition DRDS mode databases ## Core Workflow 1. **Confirm the target engine and version**: - Run `SELECT VERSION();` to determine the instance type: - Result contains `TDDL` with version > 5.4.12 → **2.0 Enterprise Edition**, this skill applies. - Result contains `TDDL` with version <= 5.4.12 → **DRDS 1.0**. **HARD STOP — refuse.** - Result contains `X-Cluster` → **2.0 Standard Edition**. **HARD STOP — refuse.** - Run `SHOW CREATE DATABASE db_name;` to verify AUTO mode (MODE = 'auto'). - Parse the version number (e.g., 5.4.19) — affects feature availability (NEW SEQUENCE requires 5.4.14+). 2. **MySQL SQL compatibility check** (when user provides MySQL SQL): - Identify unsupported features and provide PolarDB-X alternatives. - Clearly mark behavioral differences and version requirements. - Common unsupported features: stored procedures, triggers, EVENTs, SPATIAL, NATURAL JOIN, `:=` assignment, subqueries in HAVING/JOIN ON. 3. **Sequence usage** (when user needs auto-increment/unique IDs): - Default type: `NEW SEQUENCE` (5.4.14+), globally ordered, distributed alternative to AUTO_INCREMENT. - Other types: GROUP (high-performance batch), SIMPLE (single-point), TIME (time-based). - Creation: `CREATE [NEW|GROUP|SIMPLE|TIME] SEQUENCE seq_name [START WITH n]` ## Key Differences Quick Reference - **Sequence**: Globally unique sequence, default `NEW SEQUENCE` (5.4.14+). Types: NEW (globally ordered) / GROUP (high-performance batch) / SIMPLE (single-point monotone) / TIME (timestamp-based). - **Distributed transactions**: Based on TSO global clock + MVCC + 2PC, strong consistency by default. Single-shard transactions automatically optimized to local transactions. Isolation levels: READ_COMMITTED (default), REPEATABLE_READ. - **Unsupported MySQL features**: - Stored procedures / triggers / EVENTs / SPATIAL / GEOMETRY - LOAD XML / HANDLER - STRAIGHT_JOIN / NATURAL JOIN → use standard JOIN syntax - `:=` assignment operator → move logic to application layer - Subqueries in HAVING/JOIN ON clauses → rewrite as JOINs or CTEs - **Behavioral differences**: - AUTO_INCREMENT with Sequence: globally unique but may have gaps; not necessarily monotone within single connection. - LAST_INSERT_ID(): returns the first value of the batch, not the last. - REPLACE INTO / INSERT ... ON DUPLICATE KEY: works correctly but may have different locking behavior. ## Best Practices 1. **Avoid unsupported MySQL syntax**: Don't use stored procedures, triggers, EVENTs, SPATIAL, NATURAL JOIN, `:=`, etc. 2. **Rewrite HAVING/JOIN ON subqueries**: Use JOINs or CTEs instead. 3. **Check long transactions before DDL**: Long transactions can block DDL via MDL locks. 4. **Prefer NEW SEQUENCE**: Use `NEW SEQUENCE` (5.4.14+) for globally ordered unique IDs; use GROUP for high-throughput scenarios where global ordering is not required. 5. **Test compatibility before migration**: Run MySQL SQL through PolarDB-X compatibility check before going live. 6. **For EXPLAIN diagnostics**: Use `plan-analysis` skill for execution plan interpretation and slow query diagnosis. ## Reference Links | Reference | Description | |-----------|-------------| | [references/mysql-compatibility-notes.md](references/mysql-compatibility-notes.md) | MySQL vs PolarDB-X compatibility differences and development limitations | | [references/sequence.md](references/sequence.md) | Sequence types (NEW/GROUP/SIMPLE/TIME), creation and usage | | [references/transactions.md](references/transactions.md) | Distributed transaction model, isolation levels, and considerations |
GitHub에서 보기