@@ -233,7 +233,7 @@ def longname_idx(self, stbname):
233233 # ------------------- 2 ----------------
234234 #
235235 def prepareData (self ):
236- self .dbname = 'db '
236+ self .dbname = 'db_ts4403 '
237237 self .stbname = 'st'
238238 # db
239239 tdSql .execute ("create database {};" .format (self .dbname ))
@@ -284,6 +284,51 @@ def do_ts4403(self):
284284 # add index for multiple tags(TD-28078)
285285 tdSql .error ("create index tt on {} (t2, t3);" .format (self .stbname ))
286286 tdLog .debug ("Verify add index for multiple tags successfully" )
287+
288+ def do_tag_column_comparison (self ):
289+ """Test that tag-to-tag comparison does not crash taosd
290+
291+ Bug: When executing query like 'select * from st where tag1=tag2',
292+ the index filter sifSetFltParam would crash because right->condValue is NULL.
293+ The fix skips the index filter for column-to-column comparisons,
294+ allowing the query to execute via fallback path without crash.
295+ """
296+ tdSql .execute ("create database if not exists test_tag_col;" )
297+ tdSql .execute ("use test_tag_col;" )
298+ tdSql .execute ("create stable st(ts timestamp, val int) tags(tag1 int, tag2 int);" )
299+ tdSql .execute ("create table ct1 using st tags(1, 2);" )
300+ tdSql .execute ("create table ct2 using st tags(3, 3);" )
301+ tdSql .execute ("create table ct3 using st tags(5, 6);" )
302+ tdSql .execute ("insert into ct1 values(now, 1);" )
303+ tdSql .execute ("insert into ct2 values(now, 2);" )
304+ tdSql .execute ("insert into ct3 values(now, 3);" )
305+
306+ # tag1=tag2 should work without crash (fallback to non-index filter path)
307+ tdSql .query ("select * from st where tag1=tag2;" )
308+ tdSql .checkRows (1 ) # ct2 where tag1=3, tag2=3
309+ tdLog .info ("tag1=tag2 query works correctly (no crash)" )
310+
311+ # tag1<tag2 should also work
312+ tdSql .query ("select * from st where tag1<tag2;" )
313+ tdSql .checkRows (2 ) # ct1 and ct3
314+ tdLog .info ("tag1<tag2 query works correctly (no crash)" )
315+
316+ # tag1>tag2 should also work
317+ tdSql .query ("select * from st where tag1>tag2;" )
318+ tdSql .checkRows (0 ) # no matching rows
319+ tdLog .info ("tag1>tag2 query works correctly (no crash)" )
320+ # Normal tag=value queries should still work
321+ tdSql .query ("select * from st where tag1=1;" )
322+ tdSql .checkRows (1 )
323+ tdLog .info ("tag1=1 query works correctly" )
324+
325+ tdSql .query ("select * from st where tag2=3;" )
326+ tdSql .checkRows (1 )
327+ tdLog .info ("tag2=3 query works correctly" )
328+
329+ # Cleanup
330+ tdSql .execute ("drop database test_tag_col;" )
331+ tdLog .info ("Tag-to-tag comparison test passed" )
287332
288333
289334 #
@@ -304,6 +349,7 @@ def test_index_tag_basic(self):
304349 8. Drop all tag indexes
305350 9. Attempt to create tag index with excessively long name and verify error
306351 10. bug TS-4403: Create/drop tag index on supertable and verify behavior
352+ 11. Verify tag-to-tag comparison does not crash taosd
307353
308354 Since: v3.0.0.0
309355
@@ -334,6 +380,7 @@ def test_index_tag_basic(self):
334380 self .longname_idx (stable )
335381
336382 self .do_ts4403 ()
383+ self .do_tag_column_comparison ()
337384
338385
339386
0 commit comments