未验证 提交 5a3e52ff 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #7281 from taosdata/fix/TD-5921

[TD-5921]<fix>:fix case problem in 'tbname in' syntax
......@@ -3468,6 +3468,7 @@ void filterPrepare(void* expr, void* param) {
SArray *arr = (SArray *)(pCond->arr);
for (size_t i = 0; i < taosArrayGetSize(arr); i++) {
char* p = taosArrayGetP(arr, i);
strtolower(varDataVal(p), varDataVal(p));
taosHashPut(pObj, varDataVal(p),varDataLen(p), &dummy, sizeof(dummy));
}
} else {
......
......@@ -382,6 +382,7 @@ python3 test.py -f alter/alter_create_exception.py
python3 ./test.py -f insert/flushwhiledrop.py
python3 ./test.py -f insert/schemalessInsert.py
python3 ./test.py -f alter/alterColMultiTimes.py
python3 ./test.py -f query/queryTbnameUpperLower.py
#======================p4-end===============
......
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
from util.common import tdCom
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def checkStbWhereIn(self):
'''
where in ---> upper lower mixed
'''
tdCom.cleanTb()
table_name = tdCom.getLongName(8, "letters_mixed")
table_name_sub = f'{table_name}_sub'
tb_name_lower = table_name_sub.lower()
tb_name_upper = table_name_sub.upper()
## create stb and tb
tdSql.execute(f'CREATE TABLE {table_name} (ts timestamp, id int, bi1 binary(20)) tags (si1 binary(20))')
tdSql.execute(f'create table {table_name_sub}1 using {table_name} tags ("{table_name_sub}1")')
tdSql.execute(f'create table {tb_name_lower}2 using {table_name} tags ("{tb_name_lower}2")')
tdSql.execute(f'create table {tb_name_upper}3 using {table_name} tags ("{tb_name_upper}3")')
## insert values
tdSql.execute(f'insert into {table_name_sub}1 values (now-1s, 1, "{table_name_sub}1")')
tdSql.execute(f'insert into {tb_name_lower}2 values (now-2s, 2, "{tb_name_lower}21")')
tdSql.execute(f'insert into {tb_name_lower}2 values (now-3s, 3, "{tb_name_lower}22")')
tdSql.execute(f'insert into {tb_name_upper}3 values (now-4s, 4, "{tb_name_upper}31")')
tdSql.execute(f'insert into {tb_name_upper}3 values (now-5s, 5, "{tb_name_upper}32")')
tdSql.execute(f'insert into {tb_name_upper}3 values (now-6s, 6, "{tb_name_upper}33")')
## query where tbname in single
tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub}1")')
tdSql.checkRows(1)
tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub.upper()}1")')
tdSql.checkRows(1)
tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub.lower()}1")')
tdSql.checkRows(1)
tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_lower}2")')
tdSql.checkRows(2)
tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_lower.upper()}2")')
tdSql.checkRows(2)
tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_upper}3")')
tdSql.checkRows(3)
tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_upper.lower()}3")')
tdSql.checkRows(3)
## query where tbname in multi
tdSql.query(f'select * from {table_name} where id=5 and tbname in ("{table_name_sub}1", "{tb_name_lower.upper()}2", "{tb_name_upper.lower()}3")')
tdSql.checkRows(1)
tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub}1", "{tb_name_lower.upper()}2", "{tb_name_upper.lower()}3")')
tdSql.checkRows(6)
def run(self):
tdSql.prepare()
self.checkStbWhereIn()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
......@@ -53,6 +53,9 @@ class TDTestCase:
"select * from cars where id=0 and tbname in ('carzero', 'cartwo')")
tdSql.checkRows(1)
tdSql.query("select * from cars where tbname in ('carZero', 'CARONE')")
tdSql.checkRows(2)
"""
tdSql.query("select * from cars where tbname like 'car%'")
tdSql.checkRows(2)
......
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import random
import string
from util.sql import tdSql
class TDCom:
def init(self, conn, logSql):
tdSql.init(conn.cursor(), logSql)
def cleanTb(self):
query_sql = "show stables"
res_row_list = tdSql.query(query_sql, True)
stb_list = map(lambda x: x[0], res_row_list)
for stb in stb_list:
tdSql.execute(f'drop table if exists {stb}')
query_sql = "show tables"
res_row_list = tdSql.query(query_sql, True)
tb_list = map(lambda x: x[0], res_row_list)
for tb in tb_list:
tdSql.execute(f'drop table if exists {tb}')
def getLongName(self, len, mode = "mixed"):
"""
generate long name
mode could be numbers/letters/letters_mixed/mixed
"""
if mode == "numbers":
chars = ''.join(random.choice(string.digits) for i in range(len))
elif mode == "letters":
chars = ''.join(random.choice(string.ascii_letters.lower()) for i in range(len))
elif mode == "letters_mixed":
chars = ''.join(random.choice(string.ascii_letters.upper() + string.ascii_letters.lower()) for i in range(len))
else:
chars = ''.join(random.choice(string.ascii_letters.lower() + string.digits) for i in range(len))
return chars
def close(self):
self.cursor.close()
tdCom = TDCom()
\ No newline at end of file
......@@ -101,6 +101,30 @@ if $data11 != 2 then
return -1
endi
## tbname in can accpet Upper case table name
sql select count(*) from $stb where tbname in ('ti_tb0', 'TI_tb1', 'TI_TB2') group by t1 order by t1
if $rows != 3 then
return -1
endi
if $data00 != 10 then
return -1
endi
if $data01 != 0 then
return -1
endi
if $data10 != 10 then
return -1
endi
if $data11 != 1 then
return -1
endi
if $data20 != 10 then
return -1
endi
if $data21 != 2 then
return -1
endi
# multiple tbname in is not allowed NOW
sql_error select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and tbname in ('ti_tb5', 'ti_tb1000') group by t1 order by t1 asc
#if $rows != 4 then
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册