Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
be358f8f
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
be358f8f
编写于
8月 25, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master' into feature/d1
上级
d04dd464
93f5ff2e
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
207 addition
and
11 deletion
+207
-11
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+1
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+7
-5
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+16
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java
...src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java
+1
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
+10
-3
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiConnectionWithDifferentDbTest.java
...osdata/jdbc/cases/MultiConnectionWithDifferentDbTest.java
+101
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/DatabaseSpecifiedTest.java
...test/java/com/taosdata/jdbc/rs/DatabaseSpecifiedTest.java
+69
-0
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+2
-2
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
be358f8f
...
...
@@ -191,6 +191,7 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo);
void
tscFieldInfoCopy
(
SFieldInfo
*
pFieldInfo
,
const
SFieldInfo
*
pSrc
,
const
SArray
*
pExprList
);
static
FORCE_INLINE
int32_t
tscNumOfFields
(
SQueryInfo
*
pQueryInfo
)
{
return
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
}
int32_t
tscGetFirstInvisibleFieldPos
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscFieldInfoCompare
(
const
SFieldInfo
*
pFieldInfo1
,
const
SFieldInfo
*
pFieldInfo2
,
int32_t
*
diffSize
);
void
tscInsertPrimaryTsSourceColumn
(
SQueryInfo
*
pQueryInfo
,
uint64_t
uid
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
be358f8f
...
...
@@ -7232,8 +7232,6 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
}
}
size_t
size
=
tscNumOfExprs
(
pQueryInfo
);
if
(
TSDB_COL_IS_TAG
(
pColIndex
->
flag
))
{
int32_t
f
=
TSDB_FUNC_TAG
;
...
...
@@ -7241,8 +7239,10 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
f
=
TSDB_FUNC_TAGPRJ
;
}
int32_t
pos
=
tscGetFirstInvisibleFieldPos
(
pQueryInfo
);
SColumnIndex
index
=
{.
tableIndex
=
pQueryInfo
->
groupbyExpr
.
tableIndex
,
.
columnIndex
=
colIndex
};
SExprInfo
*
pExpr
=
tscExpr
Append
(
pQueryInfo
,
f
,
&
index
,
s
->
type
,
s
->
bytes
,
getNewResColId
(
pCmd
),
s
->
bytes
,
true
);
SExprInfo
*
pExpr
=
tscExpr
Insert
(
pQueryInfo
,
pos
,
f
,
&
index
,
s
->
type
,
s
->
bytes
,
getNewResColId
(
pCmd
),
s
->
bytes
,
true
);
memset
(
pExpr
->
base
.
aliasName
,
0
,
sizeof
(
pExpr
->
base
.
aliasName
));
tstrncpy
(
pExpr
->
base
.
aliasName
,
s
->
name
,
sizeof
(
pExpr
->
base
.
aliasName
));
...
...
@@ -7252,13 +7252,15 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
// NOTE: tag column does not add to source column list
SColumnList
ids
=
createColumnList
(
1
,
0
,
pColIndex
->
colIndex
);
insertResultField
(
pQueryInfo
,
(
int32_t
)
size
,
&
ids
,
s
->
bytes
,
(
int8_t
)
s
->
type
,
s
->
name
,
pExpr
);
insertResultField
(
pQueryInfo
,
pos
,
&
ids
,
s
->
bytes
,
(
int8_t
)
s
->
type
,
s
->
name
,
pExpr
);
}
else
{
// if this query is "group by" normal column, time window query is not allowed
if
(
isTimeWindowQuery
(
pQueryInfo
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
size_t
size
=
tscNumOfExprs
(
pQueryInfo
);
bool
hasGroupColumn
=
false
;
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
j
);
...
...
src/client/src/tscUtil.c
浏览文件 @
be358f8f
...
...
@@ -2120,6 +2120,22 @@ TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes) {
return
f
;
}
int32_t
tscGetFirstInvisibleFieldPos
(
SQueryInfo
*
pQueryInfo
)
{
if
(
pQueryInfo
->
fieldsInfo
.
numOfOutput
<=
0
||
pQueryInfo
->
fieldsInfo
.
internalField
==
NULL
)
{
return
0
;
}
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
SInternalField
*
pField
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
internalField
,
i
);
if
(
!
pField
->
visible
)
{
return
i
;
}
}
return
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
}
SInternalField
*
tscFieldInfoAppend
(
SFieldInfo
*
pFieldInfo
,
TAOS_FIELD
*
pField
)
{
assert
(
pFieldInfo
!=
NULL
);
pFieldInfo
->
numOfOutput
++
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java
浏览文件 @
be358f8f
...
...
@@ -18,7 +18,7 @@ public class RestfulConnection extends AbstractConnection {
private
final
String
url
;
private
final
String
database
;
private
final
String
token
;
/******************************************************/
private
boolean
isClosed
;
private
final
DatabaseMetaData
metadata
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
浏览文件 @
be358f8f
...
...
@@ -88,17 +88,24 @@ public class RestfulStatement extends AbstractStatement {
}
private
String
getUrl
()
throws
SQLException
{
String
dbname
=
conn
.
getClientInfo
(
TSDBDriver
.
PROPERTY_KEY_DBNAME
);
if
(
dbname
==
null
||
dbname
.
trim
().
isEmpty
())
{
dbname
=
""
;
}
else
{
dbname
=
"/"
+
dbname
.
toLowerCase
();
}
TimestampFormat
timestampFormat
=
TimestampFormat
.
valueOf
(
conn
.
getClientInfo
(
TSDBDriver
.
PROPERTY_KEY_TIMESTAMP_FORMAT
).
trim
().
toUpperCase
());
String
url
;
switch
(
timestampFormat
)
{
case
TIMESTAMP:
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sqlt"
;
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sqlt"
+
dbname
;
break
;
case
UTC:
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sqlutc"
;
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sqlutc"
+
dbname
;
break
;
default
:
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sql"
;
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sql"
+
dbname
;
}
return
url
;
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiConnectionWithDifferentDbTest.java
0 → 100644
浏览文件 @
be358f8f
package
com.taosdata.jdbc.cases
;
import
org.junit.Before
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
public
class
MultiConnectionWithDifferentDbTest
{
private
static
String
host
=
"127.0.0.1"
;
private
static
String
db1
=
"db1"
;
private
static
String
db2
=
"db2"
;
private
long
ts
;
@Test
public
void
test
()
{
List
<
Thread
>
threads
=
IntStream
.
range
(
1
,
3
).
mapToObj
(
i
->
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
queryDb
();
try
{
TimeUnit
.
SECONDS
.
sleep
(
1
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
private
void
queryDb
()
{
String
url
=
"jdbc:TAOS-RS://"
+
host
+
":6041/db"
+
i
+
"?user=root&password=taosdata"
;
try
(
Connection
connection
=
DriverManager
.
getConnection
(
url
))
{
Statement
stmt
=
connection
.
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
"select * from weather"
);
assertNotNull
(
rs
);
rs
.
next
();
long
actual
=
rs
.
getTimestamp
(
"ts"
).
getTime
();
assertEquals
(
ts
,
actual
);
int
f1
=
rs
.
getInt
(
"f1"
);
assertEquals
(
i
,
f1
);
String
loc
=
i
==
1
?
"beijing"
:
"shanghai"
;
String
loc_actual
=
rs
.
getString
(
"loc"
);
assertEquals
(
loc
,
loc_actual
);
stmt
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
},
"thread-"
+
i
)).
collect
(
Collectors
.
toList
());
threads
.
forEach
(
Thread:
:
start
);
for
(
Thread
t
:
threads
)
{
try
{
t
.
join
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
@Before
public
void
before
()
{
ts
=
System
.
currentTimeMillis
();
try
{
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists "
+
db1
);
stmt
.
execute
(
"create database if not exists "
+
db1
);
stmt
.
execute
(
"use "
+
db1
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int) tags(loc nchar(10))"
);
stmt
.
execute
(
"insert into t1 using weather tags('beijing') values("
+
ts
+
", 1)"
);
stmt
.
execute
(
"drop database if exists "
+
db2
);
stmt
.
execute
(
"create database if not exists "
+
db2
);
stmt
.
execute
(
"use "
+
db2
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int) tags(loc nchar(10))"
);
stmt
.
execute
(
"insert into t1 using weather tags('shanghai') values("
+
ts
+
", 2)"
);
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/DatabaseSpecifiedTest.java
0 → 100644
浏览文件 @
be358f8f
package
com.taosdata.jdbc.rs
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
java.sql.*
;
import
static
org
.
junit
.
Assert
.*;
public
class
DatabaseSpecifiedTest
{
private
static
String
host
=
"127.0.0.1"
;
private
static
String
dbname
=
"test_db_spec"
;
private
Connection
connection
;
private
long
ts
;
@Test
public
void
test
()
throws
SQLException
{
// when
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/"
+
dbname
+
"?user=root&password=taosdata"
);
try
(
Statement
stmt
=
connection
.
createStatement
();)
{
ResultSet
rs
=
stmt
.
executeQuery
(
"select * from weather"
);
//then
assertNotNull
(
rs
);
rs
.
next
();
long
now
=
rs
.
getTimestamp
(
"ts"
).
getTime
();
assertEquals
(
ts
,
now
);
int
f1
=
rs
.
getInt
(
2
);
assertEquals
(
1
,
f1
);
String
loc
=
rs
.
getString
(
"loc"
);
assertEquals
(
"beijing"
,
loc
);
}
connection
.
close
();
}
@Before
public
void
before
()
{
ts
=
System
.
currentTimeMillis
();
try
{
Connection
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
Statement
stmt
=
connection
.
createStatement
();
stmt
.
execute
(
"drop database if exists "
+
dbname
);
stmt
.
execute
(
"create database if not exists "
+
dbname
);
stmt
.
execute
(
"use "
+
dbname
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int) tags(loc nchar(10))"
);
stmt
.
execute
(
"insert into t1 using weather tags('beijing') values( "
+
ts
+
", 1)"
);
stmt
.
close
();
connection
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@After
public
void
after
()
{
try
{
if
(
connection
!=
null
)
connection
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
src/kit/taosdemo/taosdemo.c
浏览文件 @
be358f8f
...
...
@@ -7957,12 +7957,12 @@ static int insertTestProcess() {
end
=
taosGetTimestampMs
();
fprintf
(
stderr
,
"Spent %.4f seconds to create %"
PRId64
" table(s) with %d thread(s), actual %"
PRId64
" table(s) created
\n\n
"
,
"
\n
Spent %.4f seconds to create %"
PRId64
" table(s) with %d thread(s), actual %"
PRId64
" table(s) created
\n\n
"
,
(
end
-
start
)
/
1000
.
0
,
g_totalChildTables
,
g_Dbs
.
threadCountByCreateTbl
,
g_actualChildTables
);
if
(
g_fpOfInsertResult
)
{
fprintf
(
g_fpOfInsertResult
,
"Spent %.4f seconds to create %"
PRId64
" table(s) with %d thread(s), actual %"
PRId64
" table(s) created
\n\n
"
,
"
\n
Spent %.4f seconds to create %"
PRId64
" table(s) with %d thread(s), actual %"
PRId64
" table(s) created
\n\n
"
,
(
end
-
start
)
/
1000
.
0
,
g_totalChildTables
,
g_Dbs
.
threadCountByCreateTbl
,
g_actualChildTables
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录