|
|
@@ -196,7 +196,7 @@ public class TdEngineService {
|
|
196
|
196
|
|
|
197
|
197
|
// 创建超级表:固定 ts + surfacename,无 ext_data 列
|
|
198
|
198
|
String stableSql = String.format(
|
|
199
|
|
- "CREATE STABLE IF NOT EXISTS %s.%s (ts TIMESTAMP, surfacename VARCHAR(64)) TAGS (location BINARY(64))",
|
|
|
199
|
+ "CREATE STABLE IF NOT EXISTS %s.%s (ts TIMESTAMP, surfacename VARCHAR(64)) TAGS (location VARCHAR(255))",
|
|
200
|
200
|
wrapName(dbName),
|
|
201
|
201
|
wrapName(superTableName)
|
|
202
|
202
|
);
|
|
|
@@ -540,8 +540,8 @@ public class TdEngineService {
|
|
540
|
540
|
}
|
|
541
|
541
|
|
|
542
|
542
|
try (Connection conn = getConnection()) {
|
|
543
|
|
- // 检查超级表是否存在 — 使用 PreparedStatement 防止 SQL 注入
|
|
544
|
|
- String checkStableSql = "SELECT * FROM information_schema.ins_tables WHERE table_name = ? AND db_name = ?";
|
|
|
543
|
+ // 检查超级表是否存在(stable_name 字段标识超级表)
|
|
|
544
|
+ String checkStableSql = "SELECT * FROM information_schema.ins_tables WHERE stable_name = ? AND db_name = ?";
|
|
545
|
545
|
try (PreparedStatement pStmt = conn.prepareStatement(checkStableSql)) {
|
|
546
|
546
|
pStmt.setString(1, superTableName);
|
|
547
|
547
|
pStmt.setString(2, dbName);
|
|
|
@@ -555,9 +555,9 @@ public class TdEngineService {
|
|
555
|
555
|
}
|
|
556
|
556
|
}
|
|
557
|
557
|
|
|
558
|
|
- // 检查子表是否存在 — 使用 PreparedStatement 防止 SQL 注入
|
|
|
558
|
+ // 检查子表是否存在
|
|
559
|
559
|
String checkTableSql = "SELECT * FROM information_schema.ins_tables " +
|
|
560
|
|
- "WHERE table_name = ? AND db_name = ? AND table_type = 'CHILD_TABLE'";
|
|
|
560
|
+ "WHERE table_name = ? AND db_name = ? AND type = 'CHILD_TABLE'";
|
|
561
|
561
|
try (PreparedStatement pStmt = conn.prepareStatement(checkTableSql)) {
|
|
562
|
562
|
pStmt.setString(1, table);
|
|
563
|
563
|
pStmt.setString(2, dbName);
|