Skip to content

Commit 8ddcf07

Browse files
authored
fix:test_sql_length_boundary (#35144)
1 parent 175850f commit 8ddcf07

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/system-test/1-insert/boundary.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def init(self, conn, logSql, replicaVar=1):
2626
self.replicaVar = int(replicaVar)
2727
tdLog.debug("start to execute %s" % __file__)
2828
tdSql.init(conn.cursor())
29+
tdSql.execute("alter local 'maxSQLLength' '1048576'")
2930
self.boundary = DataBoundary()
3031
self.dbname_length_boundary = self.boundary.DBNAME_MAX_LENGTH
3132
self.tbname_length_boundary = self.boundary.TBNAME_MAX_LENGTH
@@ -313,6 +314,9 @@ def test_sql_length_boundary(self):
313314
tdSql.execute("drop database if exists db_maxsql_large")
314315
tdSql.execute("create database db_maxsql_large")
315316
tdSql.execute("use db_maxsql_large")
317+
318+
# Fixed base timestamp (ms) to avoid duplicate ts from now+offset
319+
base_ts_ms = 1704067200000 # 2024-01-01 00:00:00.000
316320

317321
cols = []
318322
for i in range(100):
@@ -324,7 +328,7 @@ def test_sql_length_boundary(self):
324328
insert_sql = "insert into t1 values "
325329
values = []
326330
for i in range(1000):
327-
val_cols = [f"now+{i}s"] + [str(j) for j in range(100)]
331+
val_cols = [str(base_ts_ms + i)] + [str(j) for j in range(100)]
328332
values.append(f"({', '.join(val_cols)})")
329333
insert_sql += ", ".join(values)
330334

@@ -342,7 +346,7 @@ def test_sql_length_boundary(self):
342346
base_len = len(base_sql)
343347
tdLog.info(f"10MB sql length: {base_len}")
344348
num_values = (target_length - base_len) // 16
345-
values = [f"(now+{i}s,{i})" for i in range(num_values)]
349+
values = [f"({base_ts_ms + i},{i})" for i in range(num_values)]
346350
insert_sql = base_sql + ",".join(values)
347351
current_len = len(insert_sql)
348352
if current_len < target_length:
@@ -363,15 +367,16 @@ def test_sql_length_boundary(self):
363367
tdSql.execute("alter local 'maxSQLLength' '10485760'")
364368
tdSql.execute(insert_sql)
365369
tdSql.query("select * from t2")
366-
tdSql.checkRows(509902)
370+
tdSql.checkRows(460732)
367371

368372
# Test with 64MB limit - generate INSERT SQL with length slightly less than 64MB
369373
target_length_64mb = 64 * 1024 * 1024 - 100 # 64MB minus 100 bytes (slightly less)
370374
base_sql_64mb = "insert into t2 values "
371375
base_len_64mb = len(base_sql_64mb)
372376
tdLog.info(f"64MB sql length: {base_len_64mb}")
373377
num_values_64mb = (target_length_64mb - base_len_64mb) // 16
374-
values_64mb = [f"(now+{i}s,{i})" for i in range(num_values_64mb)]
378+
base_ts_64mb = base_ts_ms + num_values
379+
values_64mb = [f"({base_ts_64mb + i},{i})" for i in range(num_values_64mb)]
375380
insert_sql_64mb = base_sql_64mb + ",".join(values_64mb)
376381

377382
# Adjust to target length
@@ -395,7 +400,7 @@ def test_sql_length_boundary(self):
395400
tdSql.execute("alter local 'maxSQLLength' '67108864'")
396401
tdSql.execute(insert_sql_64mb)
397402
tdSql.query("select * from t2")
398-
tdSql.checkRows(3524291)
403+
tdSql.checkRows(3303225)
399404

400405
# test out of boundary value
401406
tdSql.error("alter local 'maxSQLLength' '67108865'")

0 commit comments

Comments
 (0)