mirror of
https://github.com/taosdata/TDengine
synced 2026-05-24 10:09:01 +00:00
* migrate system-test/2-query * revert file * update case.task * resolve script migrate * run new test framework on new_testcases * migrate system-test/2-query * format docstring * fix test validation * fix test validation * fix error * migrate army case * migrate army case * fix error * migrate system-test/2-query * migrate system-test/2-query * migrate system-test/2-query * migrate system-test/2-query * test exe time * fix ci error * migrate system-test/1-insert * new common function * migrate system-test/1-insert * fix ci error * migrate system-test/1-insert * feat: add configuration and script for memory allocator settings * fix: correct HEAPPROFILE path and remove redundant metadata_thp setting in memory allocator script * fix ci error * migrate system-test/1-insert, 2-query * feat:insert into subquery (#31401) (#31710) * migrate system-test/99-TDcase * feat(gpt): add grant check for gpt. (#31708) * migrate system-test/99-TDcase * migrate system-test/99-TDcase * migrate system-test/99-TDcase * fix/send-heartbeat-statis (#31680) * migrate system-test/7-tmq * chore: support cmake option TAOSWS_GIT_TAG like taosadapter [skip ci] (#31486) * add system-test/6/cluster test * chore: move default branch from main to 3.3.6 for adapter/taosws * fix docstring validation * migrate system-test/7-tmq * migrate system-test/7-tmq * feat: add set_taos_malloc_env configuration and update related scripts * Update 03-kubernetes.md * enh: add log for snapshot (#31681) * simple test * more * migrate system-test/7-tmq * migrate system-test 0-others cases * migrate system-test/7-tmq * fix docstring validation * migrate system-test/7-tmq * fix docstring validation * fix: invalid queue * fix docstring validation * refactor: reorganize memory allocator script constants and improve mode descriptions * enh: TD-36324-improve-sync-heartbeat-log (#31727) * recover log level * fix: taosd crush in query when insufficient memory (#31746) Co-authored-by: Tony Zhang <tonyzhang@taosdata.com> * fix: overflow check in snprintf (#31780) * migrate system-test/7-tmq * migrate some cases * migrate system-test/7-tmq * fix failed cases * fix failed cases * migrate some cases * fix failed cases * fix failed cases * migrate testcases * fix: update environment file path in taosd.service and adjust set_taos_malloc.sh configuration * fix: set lcn before do s3 migrate. (#31782) * migrate testcases * fix failed cases * fix: add condition to set default malloc config for taosd service * fix: update usage message in set_taos_malloc.sh to include quiet mode option * fix: add quiet mode option to set malloc config in install script * fix: update set_taos_malloc.sh to improve output messages and adjust default malloc config invocation * recover log level * fix(tmq): [TS-6569]tdb error if write tmq meta data in multi thread (#31808) * fix: the calculation of dnode uptime (#31832) * migrate testcase * fix: correct timediff function bug and redress docs (#31798) * fix: enhance malloc configuration for taosd and taosadapter in install script * fix: TD-36442 show full condition (#31796) * enh/TD-36466-sync-heartbeat (#31805) * fix(plan) virtual table support BI moudle when use in select (#31787) * fix failed cases * enh: TS-5926-force-repair-wal (#31828) * migrate testcase * rename taos & taosd (#31855) * migrate testcase * migrate testcase * fix failed cases * fix: update environment file paths in taosd.service and set_taos_malloc.sh * feat: add performance tuning documentation for memory optimization and set_taos_malloc.sh usage * fix: update file paths in performance tuning documentation for consistency * feat: add performance tuning documentation for memory allocator configuration script * fix: add missing line breaks for improved readability in performance tuning documentation * fix: adjust heading levels for consistency in performance tuning documentation * fix cases * fix new_testcases * fix failed cases * fix(query): support show tags on virtual table (#31831) * fix failed cases * docs: replace mysql screenshot (#31888) * feat: use the new TDengine product name (#31859) * merge 3.0 * fix failed cases * fix failed cases * merge 3.0 * fix cases * fix cases * doc: Update 03-stream.md (#31675) * chore(deps): bump requests from 2.27.1 to 2.32.4 in /test (#31326) Bumps [requests](https://github.com/psf/requests) from 2.27.1 to 2.32.4. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](https://github.com/psf/requests/compare/v2.27.1...v2.32.4) --- updated-dependencies: - dependency-name: requests dependency-version: 2.32.4 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix new cases * fix:Convert line endings from LF to CRLF for ans file * build(deps): bump golang.org/x/net in /tools/keeper (#30811) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.36.0 to 0.38.0. - [Commits](https://github.com/golang/net/compare/v0.36.0...v0.38.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-version: 0.38.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump urllib3 from 1.26.20 to 2.5.0 in /test (#31414) Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.20 to 2.5.0. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst) - [Commits](https://github.com/urllib3/urllib3/compare/1.26.20...2.5.0) --- updated-dependencies: - dependency-name: urllib3 dependency-version: 2.5.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump org.apache.tomcat.embed:tomcat-embed-core (#31392) Bumps org.apache.tomcat.embed:tomcat-embed-core from 9.0.104 to 9.0.106. --- updated-dependencies: - dependency-name: org.apache.tomcat.embed:tomcat-embed-core dependency-version: 9.0.106 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump org.apache.tomcat.embed:tomcat-embed-core (#31393) Bumps org.apache.tomcat.embed:tomcat-embed-core from 9.0.104 to 9.0.106. --- updated-dependencies: - dependency-name: org.apache.tomcat.embed:tomcat-embed-core dependency-version: 9.0.106 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump org.apache.kafka:kafka-clients (#31341) Bumps org.apache.kafka:kafka-clients from 3.9.0 to 3.9.1. --- updated-dependencies: - dependency-name: org.apache.kafka:kafka-clients dependency-version: 3.9.1 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix: add lock when calculating log buffer start/end (#31883) * fix new cases * fix new cases * fix failed cases * feat: new stream (#31678) * fix: windows compile issue * test: add vtable cases (#31829) * fix: windows compile issues * test:add test cases * fix: windows compile issue * case: em-4 stream case submit * test: stream4_sub1 found bug2 * test: submit test_scene_meters_bug2.py * add stream parameters example * feat: [TS-6100] Do not translate const value as column. * Feat/ts 6100 3.0 zlv (#31747) * modify asan exampel * modify asan exampel * add example * add example * modify case example --------- Co-authored-by: zelv01 <1101510017@qq.com> * feat(stream): fix memory leak * modify sliding example * test: update test case. * feat(stream): fix conflicts * fix: add offset case 10a 10s 10m 10h 10d * feat(stream): fix conflicts * chore(stream): rename case name #TS-6100 * add case * modify example * fix: windows compile issues * fix: data null check * feat: [TS-6100] Forbid where when using %%trows (#31827) * feat: [TS-6100] Forbid where when using %%trows * test: update cases * feat: [TS-6100] Fix leaks. --------- Co-authored-by: Simon Guan <guanshengliang@qq.com> * test: reproduce bugs * test: update test case. * test: update test case. * feat: [TS-6100] Fix leaks. * test: add cases * Feat/ts 6100 3.0.pw10 (#31841) * enh: add operator reset func * fix: merge join reset issue * fix: memory issues * fix: add debug assert * fix: memory issues * fix: memory leak * fix: memory issues * fix taos log miss * fix: case issue * fix: case issue * fix: case issues * fix: drop dnode issue * fix: memory issues * fix: memory issues * fix: memory leak issues * fix: recalculate time range issue * fix: add debug log * fix: memory issues * fix: enable case asan * Update streamlist_for_ci.task * fix: case asan issue * fix: stream name issue * fix: external window compile issues * fix: deploy memory issue * fix: ahandle issue * fix: ahandle issue * fix: ahandle issue * fix: virtual table reader list issue * fix: log info * fix: msg error * fix: virtual table addr list issue * fix: memory issues * fix: memory leak issue * fix: memory issues * fix: memory free issues * fix: memory issues * fix: snode deploy issue * fix: mnode reader issue * fix: memory issues * fix: add debug test * enh: add ignore nodata trigger * fix: memory leaks * fix: configuration issue * fix: memory issue * fix: external window issue * fix: external window issues * fix: external window placeholder issue * fix: placeholder function init issues * fix: memory leak issue * fix: add debug log * fix: compile issues * fix: double free issue * fix: runner addr update issue * fix: msg rsp issue * fix: external window reset issue * fix: configuration issue * fix: deploy msg issue * fix: compile issue --------- Co-authored-by: huohong <sallyhuo@taosdata.com> * test: reproduce bugs * fix: add sliding interval combine case * test: add cases * test: add recalc test. * test: reproduce bugs * case : add vt ts is null check * modify case * bug: submit test_idmp_meters_bug3.py * test: add test for recalc. * test: add cases * fix: error code check * test: add cases * fix(stream): scan wal with schema in that version * add case * test: add cases * test: update test case. * fix: windows compile issues * add case * test: add cases (#31845) * modify case * fix: reset interpPrev * test: add test_idmp_meters bug4 and bug3 * add case * fix(stream): opti wal interface * fix: remove test_idmp_meters_bug5.py * test: add cases * fix(stream): fix ts data fetch for virtual tables * cancel asan case * test: update test case. * test: update test case. * add case * test: add cases * test: add cases * test: add case test_idmp_meters_bug5.py * test: update test case. * fix(stream): tmq error * test: add cases * feat: [TS-6100] Restore deleted code in mndSma.c since they are still in use. * fix(stream): optimize val scan logic * test: add test_recalc_expired_time.py to ci. * test: update test case. * test: update test case. * feat: [TS-6100] Fix fill range check * fix(stream): optimize val scan logic * add case * test: modify for partition by %%1 * test: add fun case stream4_sub7 * fix(stream): optimize val scan logic * add case * feat: [TS-6100] Rename OPTIONS to STREAM_OPTIONS. * test: add test for recalc. * test: use stream_options. * fix: some cases error. * test: remove recalc from ci. * fix: ci case issues (#31880) * enh: add operator reset func * fix: merge join reset issue * fix: memory issues * fix: add debug assert * fix: memory issues * fix: memory leak * fix: memory issues * fix taos log miss * fix: case issue * fix: case issue * fix: case issues * fix: drop dnode issue * fix: memory issues * fix: memory issues * fix: memory leak issues * fix: recalculate time range issue * fix: add debug log * fix: memory issues * fix: enable case asan * Update streamlist_for_ci.task * fix: case asan issue * fix: stream name issue * fix: external window compile issues * fix: deploy memory issue * fix: ahandle issue * fix: ahandle issue * fix: ahandle issue * fix: virtual table reader list issue * fix: log info * fix: msg error * fix: virtual table addr list issue * fix: memory issues * fix: memory leak issue * fix: memory issues * fix: memory free issues * fix: memory issues * fix: snode deploy issue * fix: mnode reader issue * fix: memory issues * fix: add debug test * enh: add ignore nodata trigger * fix: memory leaks * fix: configuration issue * fix: memory issue * fix: external window issue * fix: external window issues * fix: external window placeholder issue * fix: placeholder function init issues * fix: memory leak issue * fix: add debug log * fix: compile issues * fix: double free issue * fix: runner addr update issue * fix: msg rsp issue * fix: external window reset issue * fix: configuration issue * fix: deploy msg issue * fix: compile issue * fix: external window idx issue * fix: ci issues --------- Co-authored-by: huohong <sallyhuo@taosdata.com> * fix(stream): fix compilation error * fix(stream): optimize val scan logic * test:add test cases * test: modify case * fix: external agg error * test(stream): tobacco scene testing #TD-36514 * test: add stream cases (#31885) * fix: windows compile issue * fix: calc timerange * fix: windows compile issue * modify case * fix(stream): compile error * test: remove one debug test case file * test: modify * test: add test cases * test: reproduce bugs * test: reproduce bugs * feat: [TS-6100] Placeholder function should only appera in SELECT and… (#31868) * feat: [TS-6100] Placeholder function should only appera in SELECT and WHERE and FROM. * test: update case --------- Co-authored-by: Simon Guan <guanshengliang@qq.com> * add example * add example * modify case example * modify case * test:alter sql * test: add stream5 case * fix(stream): get schema error with version * test: add delete recalc test py. * test: remove bug cases * test: stream5 case test passed * test: add state cases (#31893) * fix(stream): compile error * test: modify case * test: add cases * test: add test. * test: update test case. * chore(test): fix case err * test: update test case. * fix: align data get * fix(stream): fix row index of datablock written into data cache * fix: put align data * test: update test case. * test: add test cases for virtual table * chore(test): fix case err #TD-36514 * add case * test: add test for water mark. * test: add meters bug6 for stream5 * test: add cases (#31903) * test: add test for recalc. * feat: [TS-6100] %%trows can only be used when event type is window close. * test: add precision of database for ms/us/ns * modify case * add case * add case * test: add test to ci. * modify case * fix: ci case issues (#31904) * enh: add operator reset func * fix: merge join reset issue * fix: memory issues * fix: add debug assert * fix: memory issues * fix: memory leak * fix: memory issues * fix taos log miss * fix: case issue * fix: case issue * fix: case issues * fix: drop dnode issue * fix: memory issues * fix: memory issues * fix: memory leak issues * fix: recalculate time range issue * fix: add debug log * fix: memory issues * fix: enable case asan * Update streamlist_for_ci.task * fix: case asan issue * fix: stream name issue * fix: external window compile issues * fix: deploy memory issue * fix: ahandle issue * fix: ahandle issue * fix: ahandle issue * fix: virtual table reader list issue * fix: log info * fix: msg error * fix: virtual table addr list issue * fix: memory issues * fix: memory leak issue * fix: memory issues * fix: memory free issues * fix: memory issues * fix: snode deploy issue * fix: mnode reader issue * fix: memory issues * fix: add debug test * enh: add ignore nodata trigger * fix: memory leaks * fix: configuration issue * fix: memory issue * fix: external window issue * fix: external window issues * fix: external window placeholder issue * fix: placeholder function init issues * fix: memory leak issue * fix: add debug log * fix: compile issues * fix: double free issue * fix: runner addr update issue * fix: msg rsp issue * fix: external window reset issue * fix: configuration issue * fix: deploy msg issue * fix: compile issue * fix: external window idx issue * fix: ci issues * fix: ci case issues * fix: drop dnode issue --------- Co-authored-by: huohong <sallyhuo@taosdata.com> * fix(stream): ci error * test: update test case. * feat: [TS-6100] Disable some failed UT. * feat: [TS-6100] Fix virtual table * test: add bug 5. * test: add test delete recalc to ci. * test: add bug 6. * test(stream): tobacco scene #TD-36514 * fix: reqCids,reqCols memory leak in SSTriggerRealtimeContext Co-authored-by: Tony Zhang <tonyzhang@taosdata.com> * test: add case stream6 * fix(stream): implement some pending features in trigger task * modify case * modify case * fix: case issues * modify case * test: add recalc for warter mark. * fix(stream): fix count window trigger of virtual tables * fix(stream): memory leak * test: fix run err. * test: add stream6 bug7 * fix: adjust format * test(stream): tobacco scene testing #TD-36514 * test: change bug7 with update window1 and 2 * test: add test bug 7. * case: restore write 3 window * fix: windows compile issue * fix: notify * test: add cases * modify case * test: update test case. * test(stream): toobacco scene testing #TD-36514 --------- Co-authored-by: Simon Guan <slguan@taosdata.com> Co-authored-by: plum-lihui <huili@taosdata.com> Co-authored-by: Alex Duan <417921451@qq.com> Co-authored-by: zelv01 <1101510017@qq.com> Co-authored-by: Jing Sima <simondominic9997@outlook.com> Co-authored-by: xiangyang guo <66111494+happyguoxy@users.noreply.github.com> Co-authored-by: wangmm0220 <wangmm0220@gmail.com> Co-authored-by: Haojun Liao <hjliao@taosdata.com> Co-authored-by: zyyang90 <zyyang@taosdata.com> Co-authored-by: Alex Duan <51781608+DuanKuanJun@users.noreply.github.com> Co-authored-by: facetosea <285808407@qq.com> Co-authored-by: Simon Guan <guanshengliang@qq.com> Co-authored-by: huohong <sallyhuo@taosdata.com> Co-authored-by: Li Hui <52318143+plum-lihui@users.noreply.github.com> Co-authored-by: Jinqing Kuang <kuangjinqingcn@gmail.com> Co-authored-by: xiao-77 <berylbao@taosdata.com> Co-authored-by: Zhixiao Bao <62235797+xiao-77@users.noreply.github.com> Co-authored-by: happyguoxy <happy_guoxy@163.com> Co-authored-by: Tony Zhang <34825804+Tony2h@users.noreply.github.com> Co-authored-by: Tony Zhang <tonyzhang@taosdata.com> * test: rename TSDB * docs: fix rust examples (#31908) * docs: modify rust native test case * docs: modify rust ws test case * docs: modify rust examples * docs: update rust pool docs * fix new cases * migrate test case * feat: support reading sub table names and tag values from CSV files to create sub tables (#31909) * feat: add obtaining table names from tag files * feat: add write data table control * feat: add table params to write * feat: delete log file * feat: modify test case csv path * feat: resolve memory leakage in the table building thread * feat: resolve compilation errors * feat: resolve table name copy len error * feat: modify create table log level * feat: modifying query configuration parameter array out of bounds * feat: support custom primary key names * feat: modify log level * feat: add set primary key name case * feat: add column keywords case * feat: add keywords case data * feat: modify primaryKeyName value len * feat: modify primaryKeyName value define * feat: modify primaryKeyName value size * fix: compile issue (#31943) Co-authored-by: taos-support <it@taosdata.com> * package: fix error * package: fix error * fix failed cases * merge 3.0 * rename create_table_keywords.py to test_create_table_keywords.py * fix failed cases * fix new cases * docs: update stream (#31957) * docs: update jdbc out-dated descripiton (#31959) * fix: TD-36560 refactor arbitrator group function name and log (#31852) * feat: support BLOB data type (#31704) * rename 0-others/mounts.py to 0-others/test_mounts.py * fix failed cases * docs: update gpt (#31975) * fix failed cases * fix failed cases * package: fix error * feat: add taosBenchmark command line parameters (#31967) * feat: add command line parameters * feat: add command line parameter test cases * fix: tableName len error * enh: set TD Release build in tdengine-build.yml * Update tdengine-build.yml * fix: add json file path log * fix: streamline TD_CONFIG export in build steps * fix: Restore the build configuration --------- Co-authored-by: haoranchen <haoran920c@163.com> * fix: tableName len error (#31977) * fix: tableName len error * fix: modify TD_CONFIG=Release * fix: code format * fix: Restore the build configuration * enh: set TD Release build in tdengine-build.yml (#31980) * enh: set TD Release build in tdengine-build.yml * Update tdengine-build.yml * fix: update cache key for externals to include debug build version * fix: remove verbose flag from build commands in tdengine-build.yml * skip memleak cases * fix failed case * fix failed cases * package: fix error * fix(stmt2):tbname error output (#31997) * fix: possible memory leak (#31972) * feat: create connect add dbname params (#32002) * feat: create connect add dbname params * fix: connect param error * skip failed cases * fix cases on windows * fix cases * support connect bi mode and fix log level * unique sql connect username and password * fix log level * enh: mounted vnode may have no tq (#31916) * fix: subquery memleak (#32024) * fix failed case * fix cases * rename 2-query/test_insert_select.py to 2-query/test_system_insert_select.py * skip memleak cases * enh: rename data forecast/detect to forecasting/anomaly detection (#32021) * package: unique product name * package: update for main * skip tsim cases * chore: update jdbc connection pool validation query sql (#32056) * refactor: quotes usage in bash scripts Signed-off-by: WANG Xu <feici02@outlook.com> * enhn(mqtt/rawblock): new format for msg payload (#31801) * fix: fix broken link in 14-stream.md * docs: 15-spark.md is missing end semicolon (#32068) * chore: bump dev version to 3.3.7.0.alpha (#32066) * fix: blob test (#32020) * fix blob query error * fix blob query error * fix blob query error * fix blob query error * fix blob query error * opt query * opt write * opt write * opt write * opt bse * opt write * opt write * opt write * opt write * opt write * opt write * opt write * opt write * opt write * opt write * opt write * opt write * opt write * add cache * opt query * opt query * opt bse * add data iter * add data iter * add more compress * add more compress * add more compress * add more compress * add more compress * add more compress * opt blob transfer * opt blob transfer * opt blob transfer * opt write * avoid unordered data write * avoid unordered data write * opt read * refactor log * fix invalid write * refactor code * fix merge error * fix merge error * add error code * support blob type len * support blob type len * support blob type len * support blob type len * support blob type len * support blob type len * support blob type len * support blob type len * support blob type len * support blob type len * Merge remote-tracking branch 'origin/3.0' into enh/blob * refactor code * support blob type len * refactor code * refactor code * benchmark support blob type * benchmark support blob type * add log * handle sort and merge row * change file set * change file set * change file set * change file set * change file set * change file set * change file set * opt code * opt read * add restart error and add unit test * add restart error and add unit test * add restart error and add unit test * add restart error and add unit test * add restart error and add unit test * refactor code * add restart error and add unit test * opt code * refactor code * fix invalid write * blob test * blob test * blob test * blob test * blob test * support blob * add str trim * add str trim * Merge remote-tracking branch 'origin/3.0' into feat/blob * Merge remote-tracking branch 'origin/3.0' into feat/blob * update test case * fix invalid read * fix invalid read * fix invalid read * add stmt2 * add stmt2 * add stmt2 * update parameter * refactor test case * refactor test case * support blob * support stmt2 * add sub * support blob * support blob * support sub * fix tmq crash * support windows/darwin * fix stmt2 bind row * fix blob crash * fix blob crash * fix blob query error * fix blob crash * fix merge error * refactor bse * add blob transfer * add blob transfer * add transfer snapshot * refactor code * change log level * change log level * add test case * refactor code * revert taosBenchmark * revert taosbench * fix: improve error handling and encoding for file reading in grep_asserts_in_file function * rm assert * fix mem leak * fix compile error * fix conflict * fix conflict * fix compile error * fix compile error * fix pre check error * fix pre check error * fix compile error on windows * fix error on window * fix error on windows * fix error on windows * opt no-blob sql * fix compile error on dawain * fix compile error on dawain * fix invalid read * fix mem leak * fix invalid read * fix invalid read * fix error on windows * remove unused code * refactor code * fix mem leak * fix mem leak * rm unused code * rm unused code * fix invalid copy * fix invalid copy * fix invalid copy * fix invalid copy * fix invalid copy * refactor code * make ci happy * refactor code * change make * update test case * update ignore code * update bse snapshot and test case * update bse snapshot and test case * refactor code * change unit test * update bse snapshot * update bse snapshot * fix test case * fix bse snapshot * fix bse snapshot * fix snapshot transfer * remove unused log * support func query * add test case * forbidden unsupport code * merge 3.0 * merge 3.0 * change test case * add forbidden code * add forbidden code * add code * support length func * support length func * taosBenchmark support blob * support blob raw block * support write raw block * support more query * Merge branch 'feat/blob' into feat/blob_test * SBlobRow2 * change bse commit change * refactor code * rm exe test * refactor code * checke return code * rename blob name * refactor code * refactor code * refactor code * refactor code * fix unordere write * fix unordere write * fix row merge error * fix row merge error * fix row merge error * fix row merge error * support ordered data * support ordered data * Merge remote-tracking branch 'origin/3.0' into feat/blob_test * fix stmt2 blob crash * add not support write type * add not support write type * add not support write type * rm exe * fix col-formate error * fix col-formate error * fix mem leak * refactor code * add error code for single blob column restriction and update error message * add error code for single blob column restriction and update error message * add error code for single blob column restriction and update error message * refactor code * change error code * make ci happy --------- Co-authored-by: yihaoDeng <yhdeng@taosdata.com> Co-authored-by: chenhaoran <haoran920c@163.com> * package: update for main (#32091) * fix compile error on windows (#32089) * fix: source code merge issues --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: WANG Xu <feici02@outlook.com> Co-authored-by: minhuinie <nminhui@163.com> Co-authored-by: huohong <sallyhuo@taosdata.com> Co-authored-by: chenhaoran <haoran920c@163.com> Co-authored-by: Nie Minhui <143420805+minhuinie@users.noreply.github.com> Co-authored-by: Mario Peng <48949600+Pengrongkun@users.noreply.github.com> Co-authored-by: Haojun Liao <hjxilinx@users.noreply.github.com> Co-authored-by: dongming chen <cademfly@hotmail.com> Co-authored-by: Linhe Huo <linhehuo@gmail.com> Co-authored-by: huohong <346479823@qq.com> Co-authored-by: Joel Brass <joel@jbrass.com> Co-authored-by: WANG Xu <feici02@outlook.com> Co-authored-by: Hongze Cheng <hzcheng@taosdata.com> Co-authored-by: Tony Zhang <34825804+Tony2h@users.noreply.github.com> Co-authored-by: Tony Zhang <tonyzhang@taosdata.com> Co-authored-by: Kaili Xu <klxu@taosdata.com> Co-authored-by: Zhixiao Bao <62235797+xiao-77@users.noreply.github.com> Co-authored-by: WANG MINGMING <wangmm0220@gmail.com> Co-authored-by: hongzhenliu <wluckyjob@gmail.com> Co-authored-by: Daniel Clow <106956386+danielclow@users.noreply.github.com> Co-authored-by: She Yanjie <57549981+sheyanjie-qq@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Simon Guan <slguan@taosdata.com> Co-authored-by: plum-lihui <huili@taosdata.com> Co-authored-by: Alex Duan <417921451@qq.com> Co-authored-by: zelv01 <1101510017@qq.com> Co-authored-by: Jing Sima <simondominic9997@outlook.com> Co-authored-by: xiangyang guo <66111494+happyguoxy@users.noreply.github.com> Co-authored-by: Haojun Liao <hjliao@taosdata.com> Co-authored-by: zyyang90 <zyyang@taosdata.com> Co-authored-by: Alex Duan <51781608+DuanKuanJun@users.noreply.github.com> Co-authored-by: facetosea <285808407@qq.com> Co-authored-by: Simon Guan <guanshengliang@qq.com> Co-authored-by: Li Hui <52318143+plum-lihui@users.noreply.github.com> Co-authored-by: Jinqing Kuang <kuangjinqingcn@gmail.com> Co-authored-by: xiao-77 <berylbao@taosdata.com> Co-authored-by: happyguoxy <happy_guoxy@163.com> Co-authored-by: guozhenwei <2227465945@qq.com> Co-authored-by: kevin men <men_shi_bin@163.com> Co-authored-by: taos-support <it@taosdata.com> Co-authored-by: Yihao Deng <luomoxyz@126.com> Co-authored-by: Minglei Jin <49711132+stephenkgu@users.noreply.github.com> Co-authored-by: yihaoDeng <yhdeng@taosdata.com>
3231 lines
95 KiB
C
3231 lines
95 KiB
C
// TAOS standard API example. The same syntax as MySQL, but only a subet
|
|
// to compile: gcc -o prepare prepare.c -ltaos
|
|
|
|
#include <pthread.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/time.h>
|
|
#include <unistd.h>
|
|
#include "../../../../include/client/taos.h"
|
|
|
|
#define FUNCTION_TEST_IDX 1
|
|
#define TIME_PRECISION_MILLI 0
|
|
#define TIME_PRECISION_MICRO 1
|
|
#define TIME_PRECISION_NANO 2
|
|
|
|
int32_t shortColList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_INT};
|
|
int32_t fullColList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_BOOL, TSDB_DATA_TYPE_TINYINT,
|
|
TSDB_DATA_TYPE_UTINYINT, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_USMALLINT,
|
|
TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_UINT, TSDB_DATA_TYPE_BIGINT,
|
|
TSDB_DATA_TYPE_UBIGINT, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_DOUBLE,
|
|
TSDB_DATA_TYPE_BINARY, TSDB_DATA_TYPE_NCHAR};
|
|
int32_t bindColTypeList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_NCHAR};
|
|
int32_t optrIdxList[] = {5, 11};
|
|
|
|
typedef struct {
|
|
char *oper;
|
|
int32_t paramNum;
|
|
bool enclose;
|
|
} OperInfo;
|
|
|
|
typedef struct {
|
|
char *funcName;
|
|
int32_t paramNum;
|
|
} FuncInfo;
|
|
|
|
typedef enum {
|
|
BP_BIND_COL = 1,
|
|
BP_BIND_TAG,
|
|
} BP_BIND_TYPE;
|
|
|
|
#define BP_BIND_TYPE_STR(t) (((t) == BP_BIND_COL) ? "column" : "tag")
|
|
|
|
OperInfo operInfo[] = {
|
|
{">", 2, false}, {">=", 2, false}, {"<", 2, false}, {"<=", 2, false},
|
|
{"=", 2, false}, {"<>", 2, false}, {"in", 2, true}, {"not in", 2, true},
|
|
|
|
{"like", 2, false}, {"not like", 2, false}, {"match", 2, false}, {"nmatch", 2, false},
|
|
};
|
|
|
|
int32_t operatorList[] = {0, 1, 2, 3, 4, 5, 6, 7};
|
|
int32_t varoperatorList[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
|
|
|
|
FuncInfo funcInfo[] = {
|
|
{"count", 1},
|
|
{"sum", 1},
|
|
{"min", 1},
|
|
};
|
|
|
|
#define BP_STARTUP_TS 1591060628000
|
|
|
|
char *bpStbPrefix = "st";
|
|
char *bpTbPrefix = "t";
|
|
int32_t bpDefaultStbId = 1;
|
|
int64_t bpTs;
|
|
|
|
// char *operatorList[] = {">", ">=", "<", "<=", "=", "<>", "in", "not in"};
|
|
// char *varoperatorList[] = {">", ">=", "<", "<=", "=", "<>", "in", "not in", "like", "not like", "match", "nmatch"};
|
|
|
|
#define tListLen(x) (sizeof(x) / sizeof((x)[0]))
|
|
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
|
|
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
|
|
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
|
|
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
|
|
|
|
typedef struct {
|
|
bool singleTbInsert;
|
|
int32_t singleTbIdx;
|
|
|
|
int64_t *tsData;
|
|
bool *boolData;
|
|
int8_t *tinyData;
|
|
uint8_t *utinyData;
|
|
int16_t *smallData;
|
|
uint16_t *usmallData;
|
|
int32_t *intData;
|
|
uint32_t *uintData;
|
|
int64_t *bigData;
|
|
uint64_t *ubigData;
|
|
float *floatData;
|
|
double *doubleData;
|
|
char *binaryData;
|
|
char *isNull;
|
|
int32_t *binaryLen;
|
|
TAOS_STMT2_BIND *pBind;
|
|
TAOS_STMT2_BIND *pTags;
|
|
char *sql;
|
|
int32_t *colTypes;
|
|
int32_t colNum;
|
|
} BindData;
|
|
|
|
int32_t gVarCharSize = 10;
|
|
int32_t gVarCharLen = 5;
|
|
|
|
int32_t gExecLoopTimes = 1; // no change
|
|
int32_t gFullColNum = tListLen(fullColList);
|
|
|
|
int insertMBSETest1(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertMBSETest2(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertMBMETest1(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertMBMETest2(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertMBMETest3(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertMBMETest4(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertMPMETest1(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertAUTOTest1(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertAUTOTest2(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertAUTOTest3(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int queryColumnTest(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int queryMiscTest(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertNonExistsTb(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertVarLenErr(TAOS_STMT2 *stmt, TAOS *taos);
|
|
int insertStbTest(TAOS_STMT2 *stmt, TAOS *taos);
|
|
|
|
enum {
|
|
TTYPE_INSERT = 1,
|
|
TTYPE_INSERT_NG,
|
|
TTYPE_QUERY,
|
|
};
|
|
|
|
typedef struct {
|
|
char caseDesc[128];
|
|
int32_t colNum;
|
|
int32_t *colList; // full table column list
|
|
int32_t testType;
|
|
int32_t autoCreateTbl;
|
|
bool duplicateValue;
|
|
bool fullCol;
|
|
int32_t (*runFn)(TAOS_STMT2 *, TAOS *);
|
|
int32_t tblNum;
|
|
int32_t rowNum;
|
|
int32_t bindRowNum;
|
|
int32_t bindColNum; // equal colNum in full column case
|
|
int32_t bindTagNum; // equal colNum in full column case
|
|
int32_t bindNullNum;
|
|
int32_t runTimes;
|
|
int32_t preCaseIdx;
|
|
bool stbInsert;
|
|
} CaseCfg;
|
|
|
|
CaseCfg gCase[] = {
|
|
{"insert:MBSE0-FULL", tListLen(shortColList), shortColList, TTYPE_INSERT, 0, false, true, insertMBSETest1, 1, 10,
|
|
10, 0, 0, 0, 1, -1, false},
|
|
{"insert:MBSE0-FULL", tListLen(shortColList), shortColList, TTYPE_INSERT, 0, false, true, insertMBSETest1, 10, 100,
|
|
10, 0, 0, 0, 1, -1, false},
|
|
|
|
{"insert:MBSE1-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, true, insertMBSETest1, 10, 10, 2,
|
|
0, 0, 0, 1, -1, false},
|
|
{"insert:MBSE1-C012", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBSETest1, 10, 10, 2,
|
|
12, 0, 0, 1, -1, false},
|
|
{"insert:MBSE1-C002", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBSETest1, 10, 10, 2,
|
|
2, 0, 0, 1, -1, false},
|
|
|
|
{"insert:MBSE2-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, true, insertMBSETest2, 10, 10, 2,
|
|
0, 0, 0, 1, -1, false},
|
|
{"insert:MBSE2-C012", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBSETest2, 10, 10, 2,
|
|
12, 0, 0, 1, -1, false},
|
|
{"insert:MBSE2-C002", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBSETest2, 10, 10, 2,
|
|
2, 0, 0, 1, -1, false},
|
|
|
|
{"insert:MBME1-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, true, insertMBMETest1, 10, 10, 2,
|
|
0, 0, 0, 1, -1, false},
|
|
{"insert:MBME1-C012", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBMETest1, 10, 10, 2,
|
|
12, 0, 0, 1, -1, false},
|
|
{"insert:MBME1-C002", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBMETest1, 10, 10, 2,
|
|
2, 0, 0, 1, -1, false},
|
|
|
|
// 11
|
|
{"insert:MBME2-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, true, insertMBMETest2, 10, 10, 2,
|
|
0, 0, 0, 1, -1, false},
|
|
{"insert:MBME2-C012", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBMETest2, 10, 10, 2,
|
|
12, 0, 0, 1, -1, false},
|
|
{"insert:MBME2-C002", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBMETest2, 10, 10, 2,
|
|
2, 0, 0, 1, -1, false},
|
|
|
|
{"insert:MBME3-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, true, insertMBMETest3, 10, 10, 2,
|
|
0, 0, 0, 1, -1, false},
|
|
{"insert:MBME3-C012", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBMETest3, 10, 10, 2,
|
|
12, 0, 0, 1, -1, false},
|
|
{"insert:MBME3-C002", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBMETest3, 10, 10, 2,
|
|
2, 0, 0, 1, -1, false},
|
|
|
|
{"insert:MBME4-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, true, insertMBMETest4, 10, 10, 2,
|
|
0, 0, 0, 1, -1, false},
|
|
{"insert:MBME4-C012", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBMETest4, 10, 10, 2,
|
|
12, 0, 0, 1, -1, false},
|
|
{"insert:MBME4-C002", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMBMETest4, 10, 10, 2,
|
|
2, 0, 0, 1, -1, false},
|
|
|
|
{"insert:MPME1-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, true, insertMPMETest1, 10, 10, 2,
|
|
0, 0, 0, 1, -1, false},
|
|
{"insert:MPME1-C012", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, false, insertMPMETest1, 10, 10, 2,
|
|
12, 0, 0, 1, -1, false},
|
|
|
|
{"insert:STBI-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, false, true, insertStbTest, 10, 10, 2, 0,
|
|
0, 0, 1, -1, true},
|
|
|
|
// 23
|
|
{"insert:AUTO1-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, 1, false, true, insertAUTOTest1, 10, 10, 2,
|
|
0, 0, 0, 1, -1, false},
|
|
{"insert:AUTO2-TBEXISTS", tListLen(fullColList), fullColList, TTYPE_INSERT, 3, false, true, insertAUTOTest2, 10, 10,
|
|
2, 0, 0, 0, 1, -1, false},
|
|
// {"insert:AUTO3-NTB", tListLen(fullColList), fullColList, TTYPE_INSERT, 0, true, true, insertAUTOTest3, 10, 10,
|
|
// 2, 0, 0, 0, 1, -1, false},
|
|
|
|
{"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryColumnTest, 10, 10, 1,
|
|
3, 0, 0, 1, 2, false},
|
|
{"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryMiscTest, 10, 10, 1, 3,
|
|
0, 0, 1, 2, false},
|
|
|
|
{"query:NG-TBNEXISTS", tListLen(fullColList), fullColList, TTYPE_INSERT_NG, 0, false, false, insertNonExistsTb, 10,
|
|
10, 1, 3, 0, 0, 1, -1, false},
|
|
{"query:NG-VARLENERR", tListLen(fullColList), fullColList, TTYPE_INSERT_NG, 0, false, true, insertVarLenErr, 10, 10,
|
|
1, 3, 0, 0, 1, -1, false},
|
|
|
|
// {"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryColumnTest, 1, 10,
|
|
// 1, 1, 0, 0, 1, 2, false},
|
|
// {"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryMiscTest, 2, 10, 1,
|
|
// 1, 0, 0, 1, 2, false},
|
|
|
|
};
|
|
|
|
CaseCfg *gCurCase = NULL;
|
|
|
|
typedef struct {
|
|
char caseCatalog[255];
|
|
int32_t bindNullNum;
|
|
bool checkParamNum;
|
|
bool printRes;
|
|
bool printCreateTblSql;
|
|
bool printQuerySql;
|
|
bool printStmtSql;
|
|
bool printVerbose;
|
|
bool autoCreateTbl;
|
|
bool numericParam;
|
|
uint8_t precision;
|
|
int32_t rowNum; // row num for one table
|
|
int32_t bindColNum;
|
|
int32_t bindTagNum;
|
|
int32_t bindRowNum; // row num for once bind
|
|
int32_t bindColTypeNum;
|
|
int32_t *bindColTypeList;
|
|
int32_t bindTagTypeNum;
|
|
int32_t *bindTagTypeList;
|
|
int32_t optrIdxListNum;
|
|
int32_t *optrIdxList;
|
|
int32_t funcIdxListNum;
|
|
int32_t *funcIdxList;
|
|
int32_t runTimes;
|
|
int32_t caseIdx; // static case idx
|
|
int32_t caseNum; // num in static case list
|
|
int32_t caseRunIdx; // runtime case idx
|
|
int32_t caseRunNum; // total run case num
|
|
} CaseCtrl;
|
|
|
|
#if 0
|
|
CaseCtrl gCaseCtrl = {
|
|
.precision = TIME_PRECISION_MILLI,
|
|
.bindNullNum = 0,
|
|
.printCreateTblSql = true,
|
|
.printQuerySql = true,
|
|
.printStmtSql = true,
|
|
.printVerbose = true,
|
|
.printRes = true,
|
|
.autoCreateTbl = false,
|
|
.numericParam = false,
|
|
.rowNum = 0,
|
|
.bindColNum = 0,
|
|
.bindTagNum = 0,
|
|
.bindRowNum = 0,
|
|
.bindColTypeNum = 0,
|
|
.bindColTypeList = NULL,
|
|
.bindTagTypeNum = 0,
|
|
.bindTagTypeList = NULL,
|
|
.optrIdxListNum = 0,
|
|
.optrIdxList = NULL,
|
|
.funcIdxListNum = 0,
|
|
.funcIdxList = NULL,
|
|
.checkParamNum = false,
|
|
.runTimes = 0,
|
|
.caseIdx = 20,
|
|
.caseNum = 1,
|
|
.caseRunIdx = -1,
|
|
.caseRunNum = -1,
|
|
};
|
|
#endif
|
|
|
|
#if 1
|
|
CaseCtrl gCaseCtrl = {
|
|
// default
|
|
.precision = TIME_PRECISION_MILLI,
|
|
.bindNullNum = 0,
|
|
.printCreateTblSql = true,
|
|
.printQuerySql = true,
|
|
.printStmtSql = true,
|
|
.printVerbose = false,
|
|
.printRes = true,
|
|
.autoCreateTbl = false,
|
|
.numericParam = false,
|
|
.rowNum = 0,
|
|
.bindColNum = 0,
|
|
.bindTagNum = 0,
|
|
.bindRowNum = 0,
|
|
.bindColTypeNum = 0,
|
|
.bindColTypeList = NULL,
|
|
.bindTagTypeNum = 0,
|
|
.bindTagTypeList = NULL,
|
|
.optrIdxListNum = 0,
|
|
.optrIdxList = NULL,
|
|
.funcIdxListNum = 0,
|
|
.funcIdxList = NULL,
|
|
.checkParamNum = false,
|
|
.runTimes = 0,
|
|
.caseIdx = -1,
|
|
.caseNum = -1,
|
|
.caseRunIdx = -1,
|
|
.caseRunNum = -1,
|
|
};
|
|
#endif
|
|
|
|
#if 0
|
|
CaseCtrl gCaseCtrl = { // query case with specified col&oper
|
|
.bindNullNum = 1,
|
|
.printCreateTblSql = false,
|
|
.printQuerySql = true,
|
|
.printStmtSql = true,
|
|
.rowNum = 0,
|
|
.bindColNum = 0,
|
|
.bindRowNum = 0,
|
|
.optrIdxListNum = tListLen(optrIdxList),
|
|
.optrIdxList = optrIdxList,
|
|
.bindColTypeNum = tListLen(bindColTypeList),
|
|
.bindColTypeList = bindColTypeList,
|
|
.checkParamNum = false,
|
|
.printRes = true,
|
|
.runTimes = 0,
|
|
.caseRunIdx = -1,
|
|
.caseIdx = 5,
|
|
.caseNum = 1,
|
|
.caseRunNum = 1,
|
|
};
|
|
#endif
|
|
|
|
#if 0
|
|
CaseCtrl gCaseCtrl = { // query case with specified col&oper
|
|
.bindNullNum = 0,
|
|
.printCreateTblSql = true,
|
|
.printQuerySql = true,
|
|
.printStmtSql = true,
|
|
.autoCreateTbl = true,
|
|
.rowNum = 0,
|
|
.bindColNum = 0,
|
|
.bindTagNum = 0,
|
|
.bindRowNum = 0,
|
|
.bindColTypeNum = 0,
|
|
.bindColTypeList = bindColTypeList,
|
|
.optrIdxListNum = 0,
|
|
.optrIdxList = optrIdxList,
|
|
.checkParamNum = false,
|
|
.printRes = true,
|
|
.runTimes = 0,
|
|
.caseRunIdx = -1,
|
|
.optrIdxListNum = tListLen(optrIdxList),
|
|
.optrIdxList = optrIdxList,
|
|
.bindColTypeNum = tListLen(bindColTypeList),
|
|
.bindColTypeList = bindColTypeList,
|
|
.caseRunIdx = -1,
|
|
.caseIdx = 24,
|
|
.caseNum = 1,
|
|
.caseRunNum = 1,
|
|
};
|
|
#endif
|
|
|
|
int32_t taosGetTimeOfDay(struct timeval *tv) { return gettimeofday(tv, NULL); }
|
|
void *taosMemoryMalloc(uint64_t size) { return malloc(size); }
|
|
|
|
void *taosMemoryCalloc(int32_t num, int32_t size) { return calloc(num, size); }
|
|
void taosMemoryFree(const void *ptr) {
|
|
if (ptr == NULL) return;
|
|
|
|
return free((void *)ptr);
|
|
}
|
|
|
|
static int64_t taosGetTimestampMs() {
|
|
struct timeval systemTime;
|
|
taosGetTimeOfDay(&systemTime);
|
|
return (int64_t)systemTime.tv_sec * 1000LL + (int64_t)systemTime.tv_usec / 1000;
|
|
}
|
|
|
|
static int64_t taosGetTimestampUs() {
|
|
struct timeval systemTime;
|
|
taosGetTimeOfDay(&systemTime);
|
|
return (int64_t)systemTime.tv_sec * 1000000LL + (int64_t)systemTime.tv_usec;
|
|
}
|
|
|
|
bool colExists(TAOS_STMT2_BIND *pBind, int32_t dataType) {
|
|
int32_t i = 0;
|
|
while (true) {
|
|
if (0 == pBind[i].buffer_type) {
|
|
return false;
|
|
}
|
|
|
|
if (pBind[i].buffer_type == dataType) {
|
|
return true;
|
|
}
|
|
|
|
++i;
|
|
}
|
|
}
|
|
|
|
void generateInsertSQL(BindData *data) {
|
|
int32_t len = 0;
|
|
if (gCurCase->tblNum > 1) {
|
|
if (data->singleTbInsert) {
|
|
len = sprintf(data->sql, "insert into %s%d ", bpTbPrefix, data->singleTbIdx);
|
|
} else {
|
|
len = sprintf(data->sql, "insert into ? ");
|
|
}
|
|
} else {
|
|
len = sprintf(data->sql, "insert into %s0 ", bpTbPrefix);
|
|
}
|
|
|
|
if (gCurCase->bindTagNum > 0) {
|
|
len += sprintf(data->sql + len, "using %s%d ", bpStbPrefix, bpDefaultStbId);
|
|
|
|
if (!gCurCase->fullCol) {
|
|
len += sprintf(data->sql + len, "(");
|
|
for (int c = 0; c < gCurCase->bindTagNum; ++c) {
|
|
if (c) {
|
|
len += sprintf(data->sql + len, ",");
|
|
}
|
|
switch (data->pTags[c].buffer_type) {
|
|
case TSDB_DATA_TYPE_BOOL:
|
|
len += sprintf(data->sql + len, "tbooldata");
|
|
break;
|
|
case TSDB_DATA_TYPE_TINYINT:
|
|
len += sprintf(data->sql + len, "ttinydata");
|
|
break;
|
|
case TSDB_DATA_TYPE_SMALLINT:
|
|
len += sprintf(data->sql + len, "tsmalldata");
|
|
break;
|
|
case TSDB_DATA_TYPE_INT:
|
|
len += sprintf(data->sql + len, "tintdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_BIGINT:
|
|
len += sprintf(data->sql + len, "tbigdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_FLOAT:
|
|
len += sprintf(data->sql + len, "tfloatdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_DOUBLE:
|
|
len += sprintf(data->sql + len, "tdoubledata");
|
|
break;
|
|
case TSDB_DATA_TYPE_VARCHAR:
|
|
len += sprintf(data->sql + len, "tbinarydata");
|
|
break;
|
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
|
len += sprintf(data->sql + len, "tts");
|
|
break;
|
|
case TSDB_DATA_TYPE_NCHAR:
|
|
len += sprintf(data->sql + len, "tnchardata");
|
|
break;
|
|
case TSDB_DATA_TYPE_UTINYINT:
|
|
len += sprintf(data->sql + len, "tutinydata");
|
|
break;
|
|
case TSDB_DATA_TYPE_USMALLINT:
|
|
len += sprintf(data->sql + len, "tusmalldata");
|
|
break;
|
|
case TSDB_DATA_TYPE_UINT:
|
|
len += sprintf(data->sql + len, "tuintdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_UBIGINT:
|
|
len += sprintf(data->sql + len, "tubigdata");
|
|
break;
|
|
default:
|
|
printf("!!!invalid tag type:%d", data->pTags[c].buffer_type);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
len += sprintf(data->sql + len, ") ");
|
|
}
|
|
|
|
len += sprintf(data->sql + len, "tags (");
|
|
for (int c = 0; c < gCurCase->bindTagNum; ++c) {
|
|
if (c) {
|
|
len += sprintf(data->sql + len, ",");
|
|
}
|
|
len += sprintf(data->sql + len, "?");
|
|
}
|
|
len += sprintf(data->sql + len, ") ");
|
|
}
|
|
|
|
if (!gCurCase->fullCol) {
|
|
len += sprintf(data->sql + len, "(");
|
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
|
if (c) {
|
|
len += sprintf(data->sql + len, ",");
|
|
}
|
|
switch (data->pBind[c].buffer_type) {
|
|
case TSDB_DATA_TYPE_BOOL:
|
|
len += sprintf(data->sql + len, "booldata");
|
|
break;
|
|
case TSDB_DATA_TYPE_TINYINT:
|
|
len += sprintf(data->sql + len, "tinydata");
|
|
break;
|
|
case TSDB_DATA_TYPE_SMALLINT:
|
|
len += sprintf(data->sql + len, "smalldata");
|
|
break;
|
|
case TSDB_DATA_TYPE_INT:
|
|
len += sprintf(data->sql + len, "intdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_BIGINT:
|
|
len += sprintf(data->sql + len, "bigdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_FLOAT:
|
|
len += sprintf(data->sql + len, "floatdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_DOUBLE:
|
|
len += sprintf(data->sql + len, "doubledata");
|
|
break;
|
|
case TSDB_DATA_TYPE_VARCHAR:
|
|
len += sprintf(data->sql + len, "binarydata");
|
|
break;
|
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
|
len += sprintf(data->sql + len, "ts");
|
|
break;
|
|
case TSDB_DATA_TYPE_NCHAR:
|
|
len += sprintf(data->sql + len, "nchardata");
|
|
break;
|
|
case TSDB_DATA_TYPE_UTINYINT:
|
|
len += sprintf(data->sql + len, "utinydata");
|
|
break;
|
|
case TSDB_DATA_TYPE_USMALLINT:
|
|
len += sprintf(data->sql + len, "usmalldata");
|
|
break;
|
|
case TSDB_DATA_TYPE_UINT:
|
|
len += sprintf(data->sql + len, "uintdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_UBIGINT:
|
|
len += sprintf(data->sql + len, "ubigdata");
|
|
break;
|
|
default:
|
|
printf("!!!invalid col type:%d", data->pBind[c].buffer_type);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
len += sprintf(data->sql + len, ") ");
|
|
}
|
|
|
|
len += sprintf(data->sql + len, "values (");
|
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
|
if (c) {
|
|
len += sprintf(data->sql + len, ",");
|
|
}
|
|
len += sprintf(data->sql + len, "?");
|
|
}
|
|
len += sprintf(data->sql + len, ")");
|
|
|
|
if (gCaseCtrl.printStmtSql) {
|
|
printf("\tSQL: %s\n", data->sql);
|
|
}
|
|
}
|
|
|
|
void bpAppendOperatorParam(BindData *data, int32_t *len, int32_t dataType, int32_t idx) {
|
|
OperInfo *pInfo = NULL;
|
|
|
|
if (gCaseCtrl.optrIdxListNum > 0) {
|
|
pInfo = &operInfo[gCaseCtrl.optrIdxList[idx]];
|
|
} else {
|
|
if (TSDB_DATA_TYPE_VARCHAR == dataType || TSDB_DATA_TYPE_NCHAR == dataType || TSDB_DATA_TYPE_GEOMETRY == dataType) {
|
|
#if 1
|
|
pInfo = &operInfo[varoperatorList[rand() % tListLen(varoperatorList)]];
|
|
#else
|
|
pInfo = &operInfo[11];
|
|
#endif
|
|
} else {
|
|
pInfo = &operInfo[operatorList[rand() % tListLen(operatorList)]];
|
|
}
|
|
}
|
|
|
|
switch (pInfo->paramNum) {
|
|
case 2:
|
|
if (pInfo->enclose) {
|
|
*len += sprintf(data->sql + *len, " %s (?)", pInfo->oper);
|
|
} else {
|
|
*len += sprintf(data->sql + *len, " %s ?", pInfo->oper);
|
|
}
|
|
break;
|
|
default:
|
|
printf("!!!invalid operator paramNum:%d\n", pInfo->paramNum);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
void bpAppendFunctionParam(BindData *data, int32_t *len, int32_t dataType, int32_t idx) {
|
|
FuncInfo *pInfo = NULL;
|
|
|
|
if (gCaseCtrl.funcIdxListNum > 0) {
|
|
pInfo = &funcInfo[gCaseCtrl.funcIdxList[idx]];
|
|
} else {
|
|
pInfo = &funcInfo[rand() % tListLen(funcInfo)];
|
|
}
|
|
|
|
switch (pInfo->paramNum) {
|
|
case 1:
|
|
*len += sprintf(data->sql + *len, " %s(?)", pInfo->funcName);
|
|
break;
|
|
default:
|
|
printf("!!!invalid function paramNum:%d\n", pInfo->paramNum);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
int32_t bpAppendColumnName(BindData *data, int32_t type, int32_t len) {
|
|
switch (type) {
|
|
case TSDB_DATA_TYPE_BOOL:
|
|
return sprintf(data->sql + len, "booldata");
|
|
break;
|
|
case TSDB_DATA_TYPE_TINYINT:
|
|
return sprintf(data->sql + len, "tinydata");
|
|
break;
|
|
case TSDB_DATA_TYPE_SMALLINT:
|
|
return sprintf(data->sql + len, "smalldata");
|
|
break;
|
|
case TSDB_DATA_TYPE_INT:
|
|
return sprintf(data->sql + len, "intdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_BIGINT:
|
|
return sprintf(data->sql + len, "bigdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_FLOAT:
|
|
return sprintf(data->sql + len, "floatdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_DOUBLE:
|
|
return sprintf(data->sql + len, "doubledata");
|
|
break;
|
|
case TSDB_DATA_TYPE_VARCHAR:
|
|
return sprintf(data->sql + len, "binarydata");
|
|
break;
|
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
|
return sprintf(data->sql + len, "ts");
|
|
break;
|
|
case TSDB_DATA_TYPE_NCHAR:
|
|
return sprintf(data->sql + len, "nchardata");
|
|
break;
|
|
case TSDB_DATA_TYPE_UTINYINT:
|
|
return sprintf(data->sql + len, "utinydata");
|
|
break;
|
|
case TSDB_DATA_TYPE_USMALLINT:
|
|
return sprintf(data->sql + len, "usmalldata");
|
|
break;
|
|
case TSDB_DATA_TYPE_UINT:
|
|
return sprintf(data->sql + len, "uintdata");
|
|
break;
|
|
case TSDB_DATA_TYPE_UBIGINT:
|
|
return sprintf(data->sql + len, "ubigdata");
|
|
break;
|
|
default:
|
|
printf("!!!invalid col type:%d", type);
|
|
exit(1);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void generateQueryCondSQL(BindData *data, int32_t tblIdx) {
|
|
int32_t len = sprintf(data->sql, "select * from %s%d where ", bpTbPrefix, tblIdx);
|
|
if (!gCurCase->fullCol) {
|
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
|
if (c) {
|
|
len += sprintf(data->sql + len, " and ");
|
|
}
|
|
len += bpAppendColumnName(data, data->pBind[c].buffer_type, len);
|
|
|
|
bpAppendOperatorParam(data, &len, data->pBind[c].buffer_type, c);
|
|
}
|
|
}
|
|
|
|
if (gCaseCtrl.printStmtSql) {
|
|
printf("\tSTMT SQL: %s\n", data->sql);
|
|
}
|
|
}
|
|
|
|
void bpGenerateConstInOpSQL(BindData *data, int32_t tblIdx) {
|
|
int32_t len = 0;
|
|
len = sprintf(data->sql, "select ");
|
|
|
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
|
if (c) {
|
|
len += sprintf(data->sql + len, ", ");
|
|
}
|
|
|
|
len += bpAppendColumnName(data, data->pBind[c].buffer_type, len);
|
|
|
|
bpAppendOperatorParam(data, &len, data->pBind[c].buffer_type, c);
|
|
}
|
|
|
|
len += sprintf(data->sql + len, " from %s%d", bpTbPrefix, tblIdx);
|
|
}
|
|
|
|
void bpGenerateConstInFuncSQL(BindData *data, int32_t tblIdx) {
|
|
int32_t len = 0;
|
|
len = sprintf(data->sql, "select ");
|
|
|
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
|
if (c) {
|
|
len += sprintf(data->sql + len, ", ");
|
|
}
|
|
|
|
bpAppendFunctionParam(data, &len, data->pBind[c].buffer_type, c);
|
|
}
|
|
|
|
len += sprintf(data->sql + len, " from %s%d", bpTbPrefix, tblIdx);
|
|
}
|
|
|
|
void generateQueryMiscSQL(BindData *data, int32_t tblIdx) {
|
|
if (tblIdx == FUNCTION_TEST_IDX && gCurCase->bindNullNum <= 0) {
|
|
bpGenerateConstInFuncSQL(data, tblIdx);
|
|
} else {
|
|
switch (tblIdx) {
|
|
case 0:
|
|
// TODO FILL TEST
|
|
default:
|
|
bpGenerateConstInOpSQL(data, tblIdx);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (gCaseCtrl.printStmtSql) {
|
|
printf("\tSTMT SQL: %s\n", data->sql);
|
|
}
|
|
}
|
|
|
|
void generateErrorSQL(BindData *data, int32_t tblIdx) {
|
|
int32_t len = 0;
|
|
data->sql = taosMemoryCalloc(1, 1024);
|
|
|
|
switch (tblIdx) {
|
|
case 0:
|
|
len = sprintf(data->sql, "insert into %s%d values (?, 1)", bpTbPrefix, tblIdx);
|
|
break;
|
|
case 1:
|
|
len = sprintf(data->sql, "select * from ?");
|
|
break;
|
|
case 2:
|
|
len = sprintf(data->sql, "select * from %s%d where ? = ?", bpTbPrefix, tblIdx);
|
|
break;
|
|
default:
|
|
len = sprintf(data->sql, "select count(*) from %s%d group by ?", bpTbPrefix, tblIdx);
|
|
break;
|
|
}
|
|
|
|
if (gCaseCtrl.printStmtSql) {
|
|
printf("\tSTMT SQL: %s\n", data->sql);
|
|
}
|
|
}
|
|
|
|
void generateColDataType(bool isQuery, BindData *data, int32_t bindIdx, int32_t colIdx, int32_t *dataType) {
|
|
if (bindIdx < gCurCase->bindColNum) {
|
|
if (gCaseCtrl.bindColTypeNum) {
|
|
*dataType = gCaseCtrl.bindColTypeList[colIdx];
|
|
return;
|
|
} else if (gCurCase->fullCol) {
|
|
*dataType = gCurCase->colList[bindIdx];
|
|
return;
|
|
} else if (gCaseCtrl.numericParam) {
|
|
while (true) {
|
|
*dataType = rand() % (TSDB_DATA_TYPE_MAX - 1) + 1;
|
|
if (!IS_NUMERIC_TYPE(*dataType)) {
|
|
continue;
|
|
}
|
|
|
|
break;
|
|
}
|
|
return;
|
|
} else if (0 == colIdx && !isQuery) {
|
|
*dataType = TSDB_DATA_TYPE_TIMESTAMP;
|
|
return;
|
|
} else {
|
|
while (true) {
|
|
#if 1
|
|
*dataType = rand() % (TSDB_DATA_TYPE_MAX - 1) + 1;
|
|
#else
|
|
if (!colExists(data->pBind, TSDB_DATA_TYPE_NCHAR)) {
|
|
*dataType = TSDB_DATA_TYPE_NCHAR;
|
|
} else {
|
|
*dataType = rand() % (TSDB_DATA_TYPE_MAX - 1) + 1;
|
|
}
|
|
#endif
|
|
if (*dataType == TSDB_DATA_TYPE_JSON || *dataType == TSDB_DATA_TYPE_DECIMAL ||
|
|
*dataType == TSDB_DATA_TYPE_BLOB || *dataType == TSDB_DATA_TYPE_MEDIUMBLOB ||
|
|
*dataType == TSDB_DATA_TYPE_VARBINARY || *dataType == TSDB_DATA_TYPE_GEOMETRY) {
|
|
continue;
|
|
}
|
|
|
|
if (colExists(data->pBind, *dataType)) {
|
|
continue;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
*dataType = data->pBind[bindIdx % gCurCase->bindColNum].buffer_type;
|
|
}
|
|
}
|
|
|
|
void generateTagDataType(BindData *data, int32_t bindIdx, int32_t colIdx, int32_t *dataType) {
|
|
if (bindIdx < gCurCase->bindTagNum) {
|
|
if (gCaseCtrl.bindTagTypeNum) {
|
|
*dataType = gCaseCtrl.bindTagTypeList[colIdx];
|
|
return;
|
|
} else if (gCurCase->fullCol) {
|
|
*dataType = gCurCase->colList[bindIdx];
|
|
return;
|
|
} else {
|
|
while (true) {
|
|
*dataType = rand() % (TSDB_DATA_TYPE_MAX - 1) + 1;
|
|
if (*dataType == TSDB_DATA_TYPE_JSON || *dataType == TSDB_DATA_TYPE_DECIMAL ||
|
|
*dataType == TSDB_DATA_TYPE_BLOB || *dataType == TSDB_DATA_TYPE_MEDIUMBLOB ||
|
|
*dataType == TSDB_DATA_TYPE_VARBINARY || *dataType == TSDB_DATA_TYPE_GEOMETRY) {
|
|
continue;
|
|
}
|
|
|
|
if (colExists(data->pTags, *dataType)) {
|
|
continue;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
*dataType = data->pTags[bindIdx % gCurCase->bindTagNum].buffer_type;
|
|
}
|
|
}
|
|
|
|
int32_t prepareColData(bool isQuery, BP_BIND_TYPE bType, BindData *data, int32_t bindIdx, int32_t rowIdx,
|
|
int32_t colIdx) {
|
|
int32_t dataType = TSDB_DATA_TYPE_TIMESTAMP;
|
|
TAOS_STMT2_BIND *pBase = NULL;
|
|
|
|
if (bType == BP_BIND_TAG) {
|
|
pBase = data->pTags;
|
|
generateTagDataType(data, bindIdx, colIdx, &dataType);
|
|
} else {
|
|
pBase = data->pBind;
|
|
generateColDataType(isQuery, data, bindIdx, colIdx, &dataType);
|
|
}
|
|
|
|
switch (dataType) {
|
|
case TSDB_DATA_TYPE_BOOL:
|
|
// pBase[bindIdx].buffer_length = sizeof(bool);
|
|
pBase[bindIdx].buffer = data->boolData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_TINYINT:
|
|
// pBase[bindIdx].buffer_length = sizeof(int8_t);
|
|
pBase[bindIdx].buffer = data->tinyData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_SMALLINT:
|
|
// pBase[bindIdx].buffer_length = sizeof(int16_t);
|
|
pBase[bindIdx].buffer = data->smallData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_INT:
|
|
// pBase[bindIdx].buffer_length = sizeof(int32_t);
|
|
pBase[bindIdx].buffer = data->intData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_BIGINT:
|
|
// pBase[bindIdx].buffer_length = sizeof(int64_t);
|
|
pBase[bindIdx].buffer = data->bigData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_FLOAT:
|
|
// pBase[bindIdx].buffer_length = sizeof(float);
|
|
pBase[bindIdx].buffer = data->floatData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_DOUBLE:
|
|
// pBase[bindIdx].buffer_length = sizeof(double);
|
|
pBase[bindIdx].buffer = data->doubleData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_VARCHAR:
|
|
case TSDB_DATA_TYPE_GEOMETRY:
|
|
// pBase[bindIdx].buffer_length = gVarCharSize;
|
|
// pBase[bindIdx].buffer = data->binaryData + rowIdx * gVarCharSize;
|
|
pBase[bindIdx].buffer = data->binaryData + rowIdx * gVarCharLen;
|
|
pBase[bindIdx].length = data->binaryLen;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
|
// pBase[bindIdx].buffer_length = sizeof(int64_t);
|
|
pBase[bindIdx].buffer = data->tsData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_NCHAR:
|
|
// pBase[bindIdx].buffer_length = gVarCharSize;
|
|
// pBase[bindIdx].buffer = data->binaryData + rowIdx * gVarCharSize;
|
|
pBase[bindIdx].buffer = data->binaryData + rowIdx * gVarCharLen;
|
|
pBase[bindIdx].length = data->binaryLen;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_UTINYINT:
|
|
// pBase[bindIdx].buffer_length = sizeof(uint8_t);
|
|
pBase[bindIdx].buffer = data->utinyData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_USMALLINT:
|
|
// pBase[bindIdx].buffer_length = sizeof(uint16_t);
|
|
pBase[bindIdx].buffer = data->usmallData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_UINT:
|
|
// pBase[bindIdx].buffer_length = sizeof(uint32_t);
|
|
pBase[bindIdx].buffer = data->uintData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
case TSDB_DATA_TYPE_UBIGINT:
|
|
// pBase[bindIdx].buffer_length = sizeof(uint64_t);
|
|
pBase[bindIdx].buffer = data->ubigData + rowIdx;
|
|
pBase[bindIdx].length = NULL;
|
|
pBase[bindIdx].is_null = data->isNull ? (data->isNull + rowIdx) : NULL;
|
|
break;
|
|
default:
|
|
printf("!!!invalid col type:%d", dataType);
|
|
exit(1);
|
|
}
|
|
|
|
pBase[bindIdx].buffer_type = dataType;
|
|
pBase[bindIdx].num = gCurCase->bindRowNum;
|
|
|
|
if (bType == BP_BIND_TAG) {
|
|
pBase[bindIdx].num = 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t prepareInsertData(BindData *data) {
|
|
uint64_t allRowNum = gCurCase->rowNum * gCurCase->tblNum;
|
|
|
|
data->colNum = 0;
|
|
data->colTypes = taosMemoryCalloc(30, sizeof(int32_t));
|
|
data->sql = taosMemoryCalloc(1, 1024);
|
|
data->pBind =
|
|
taosMemoryCalloc((int32_t)(allRowNum / gCurCase->bindRowNum) * gCurCase->bindColNum, sizeof(TAOS_STMT2_BIND));
|
|
data->pTags = taosMemoryCalloc(gCurCase->tblNum * gCurCase->bindTagNum, sizeof(TAOS_STMT2_BIND));
|
|
data->tsData = taosMemoryMalloc(allRowNum * sizeof(int64_t));
|
|
data->boolData = taosMemoryMalloc(allRowNum * sizeof(bool));
|
|
data->tinyData = taosMemoryMalloc(allRowNum * sizeof(int8_t));
|
|
data->utinyData = taosMemoryMalloc(allRowNum * sizeof(uint8_t));
|
|
data->smallData = taosMemoryMalloc(allRowNum * sizeof(int16_t));
|
|
data->usmallData = taosMemoryMalloc(allRowNum * sizeof(uint16_t));
|
|
data->intData = taosMemoryMalloc(allRowNum * sizeof(int32_t));
|
|
data->uintData = taosMemoryMalloc(allRowNum * sizeof(uint32_t));
|
|
data->bigData = taosMemoryMalloc(allRowNum * sizeof(int64_t));
|
|
data->ubigData = taosMemoryMalloc(allRowNum * sizeof(uint64_t));
|
|
data->floatData = taosMemoryMalloc(allRowNum * sizeof(float));
|
|
data->doubleData = taosMemoryMalloc(allRowNum * sizeof(double));
|
|
data->binaryData = taosMemoryMalloc(allRowNum * gVarCharSize);
|
|
data->binaryLen = taosMemoryMalloc(allRowNum * sizeof(int32_t));
|
|
if (gCurCase->bindNullNum) {
|
|
data->isNull = taosMemoryCalloc((int32_t)allRowNum, sizeof(char));
|
|
}
|
|
|
|
for (int32_t i = 0; i < allRowNum; ++i) {
|
|
if (gCurCase->duplicateValue) {
|
|
data->tsData[i] = bpTs;
|
|
if (i % 2 == 1) {
|
|
bpTs++;
|
|
}
|
|
} else {
|
|
data->tsData[i] = bpTs++;
|
|
}
|
|
data->boolData[i] = (bool)(i % 2);
|
|
data->tinyData[i] = (int8_t)i;
|
|
data->utinyData[i] = (uint8_t)(i + 1);
|
|
data->smallData[i] = (int16_t)i;
|
|
data->usmallData[i] = (uint16_t)(i + 1);
|
|
data->intData[i] = (int32_t)i;
|
|
data->uintData[i] = (uint32_t)(i + 1);
|
|
data->bigData[i] = (int64_t)i;
|
|
data->ubigData[i] = (uint64_t)(i + 1);
|
|
data->floatData[i] = (float)i;
|
|
data->doubleData[i] = (double)(i + 1);
|
|
// memset(data->binaryData + gVarCharSize * i, 'a' + i % 26, gVarCharLen);
|
|
memset(data->binaryData + gVarCharLen * i, 'a' + i % 26, gVarCharLen);
|
|
if (gCurCase->bindNullNum) {
|
|
data->isNull[i] = (char)(i % 2);
|
|
}
|
|
data->binaryLen[i] = gVarCharLen;
|
|
}
|
|
|
|
for (int b = 0; b < (allRowNum / gCurCase->bindRowNum); b++) {
|
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
|
prepareColData(false, BP_BIND_COL, data, b * gCurCase->bindColNum + c, b * gCurCase->bindRowNum, c);
|
|
}
|
|
}
|
|
|
|
for (int b = 0; b < gCurCase->tblNum; b++) {
|
|
for (int c = 0; c < gCurCase->bindTagNum; ++c) {
|
|
prepareColData(false, BP_BIND_TAG, data, b * gCurCase->bindTagNum + c, b, c);
|
|
}
|
|
}
|
|
|
|
generateInsertSQL(data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t prepareQueryCondData(BindData *data, int32_t tblIdx) {
|
|
uint64_t bindNum = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
|
|
data->colNum = 0;
|
|
data->colTypes = taosMemoryCalloc(30, sizeof(int32_t));
|
|
data->sql = taosMemoryCalloc(1, 1024);
|
|
data->pBind = taosMemoryCalloc((int32_t)bindNum * gCurCase->bindColNum, sizeof(TAOS_STMT2_BIND));
|
|
data->tsData = taosMemoryMalloc(bindNum * sizeof(int64_t));
|
|
data->boolData = taosMemoryMalloc(bindNum * sizeof(bool));
|
|
data->tinyData = taosMemoryMalloc(bindNum * sizeof(int8_t));
|
|
data->utinyData = taosMemoryMalloc(bindNum * sizeof(uint8_t));
|
|
data->smallData = taosMemoryMalloc(bindNum * sizeof(int16_t));
|
|
data->usmallData = taosMemoryMalloc(bindNum * sizeof(uint16_t));
|
|
data->intData = taosMemoryMalloc(bindNum * sizeof(int32_t));
|
|
data->uintData = taosMemoryMalloc(bindNum * sizeof(uint32_t));
|
|
data->bigData = taosMemoryMalloc(bindNum * sizeof(int64_t));
|
|
data->ubigData = taosMemoryMalloc(bindNum * sizeof(uint64_t));
|
|
data->floatData = taosMemoryMalloc(bindNum * sizeof(float));
|
|
data->doubleData = taosMemoryMalloc(bindNum * sizeof(double));
|
|
data->binaryData = taosMemoryMalloc(bindNum * gVarCharSize);
|
|
data->binaryLen = taosMemoryMalloc(bindNum * sizeof(int32_t));
|
|
if (gCurCase->bindNullNum) {
|
|
data->isNull = taosMemoryCalloc((int32_t)bindNum, sizeof(char));
|
|
}
|
|
|
|
for (int32_t i = 0; i < bindNum; ++i) {
|
|
data->tsData[i] = bpTs + tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum;
|
|
data->boolData[i] = (bool)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->tinyData[i] = (int8_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->utinyData[i] = (uint8_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->smallData[i] = (int16_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->usmallData[i] = (uint16_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->intData[i] = (int32_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->uintData[i] = (uint32_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->bigData[i] = (int64_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->ubigData[i] = (uint64_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->floatData[i] = (float)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->doubleData[i] = (double)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
// memset(data->binaryData + gVarCharSize * i, 'a' + i % 26, gVarCharLen);
|
|
memset(data->binaryData + gVarCharLen * i, 'a' + i % 26, gVarCharLen);
|
|
if (gCurCase->bindNullNum) {
|
|
data->isNull[i] = (char)(i % 2);
|
|
}
|
|
data->binaryLen[i] = gVarCharLen;
|
|
}
|
|
|
|
for (int b = 0; b < bindNum; b++) {
|
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
|
prepareColData(true, BP_BIND_COL, data, b * gCurCase->bindColNum + c, b * gCurCase->bindRowNum, c);
|
|
}
|
|
}
|
|
|
|
generateQueryCondSQL(data, tblIdx);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t prepareQueryMiscData(BindData *data, int32_t tblIdx) {
|
|
uint64_t bindNum = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
|
|
data->colNum = 0;
|
|
data->colTypes = taosMemoryCalloc(30, sizeof(int32_t));
|
|
data->sql = taosMemoryCalloc(1, 1024);
|
|
data->pBind = taosMemoryCalloc((int32_t)bindNum * gCurCase->bindColNum, sizeof(TAOS_STMT2_BIND));
|
|
data->tsData = taosMemoryMalloc(bindNum * sizeof(int64_t));
|
|
data->boolData = taosMemoryMalloc(bindNum * sizeof(bool));
|
|
data->tinyData = taosMemoryMalloc(bindNum * sizeof(int8_t));
|
|
data->utinyData = taosMemoryMalloc(bindNum * sizeof(uint8_t));
|
|
data->smallData = taosMemoryMalloc(bindNum * sizeof(int16_t));
|
|
data->usmallData = taosMemoryMalloc(bindNum * sizeof(uint16_t));
|
|
data->intData = taosMemoryMalloc(bindNum * sizeof(int32_t));
|
|
data->uintData = taosMemoryMalloc(bindNum * sizeof(uint32_t));
|
|
data->bigData = taosMemoryMalloc(bindNum * sizeof(int64_t));
|
|
data->ubigData = taosMemoryMalloc(bindNum * sizeof(uint64_t));
|
|
data->floatData = taosMemoryMalloc(bindNum * sizeof(float));
|
|
data->doubleData = taosMemoryMalloc(bindNum * sizeof(double));
|
|
data->binaryData = taosMemoryMalloc(bindNum * gVarCharSize);
|
|
data->binaryLen = taosMemoryMalloc(bindNum * sizeof(int32_t));
|
|
if (gCurCase->bindNullNum) {
|
|
data->isNull = taosMemoryCalloc((int32_t)bindNum, sizeof(char));
|
|
}
|
|
|
|
for (int32_t i = 0; i < bindNum; ++i) {
|
|
data->tsData[i] = bpTs + tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum;
|
|
data->boolData[i] = (bool)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->tinyData[i] = (int8_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->utinyData[i] = (uint8_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->smallData[i] = (int16_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->usmallData[i] = (uint16_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->intData[i] = (int32_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->uintData[i] = (uint32_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->bigData[i] = (int64_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->ubigData[i] = (uint64_t)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->floatData[i] = (float)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
data->doubleData[i] = (double)(tblIdx * gCurCase->rowNum + rand() % gCurCase->rowNum);
|
|
// memset(data->binaryData + gVarCharSize * i, 'a' + i % 26, gVarCharLen);
|
|
memset(data->binaryData + gVarCharLen * i, 'a' + i % 26, gVarCharLen);
|
|
if (gCurCase->bindNullNum) {
|
|
data->isNull[i] = (char)(i % 2);
|
|
}
|
|
data->binaryLen[i] = gVarCharLen;
|
|
}
|
|
|
|
if (tblIdx == FUNCTION_TEST_IDX) {
|
|
gCaseCtrl.numericParam = true;
|
|
} else {
|
|
gCaseCtrl.numericParam = false;
|
|
}
|
|
|
|
for (int b = 0; b < bindNum; b++) {
|
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
|
prepareColData(true, BP_BIND_COL, data, b * gCurCase->bindColNum + c, b * gCurCase->bindRowNum, c);
|
|
}
|
|
}
|
|
|
|
gCaseCtrl.numericParam = false;
|
|
|
|
generateQueryMiscSQL(data, tblIdx);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void destroyData(BindData *data) {
|
|
taosMemoryFree(data->tsData);
|
|
taosMemoryFree(data->boolData);
|
|
taosMemoryFree(data->tinyData);
|
|
taosMemoryFree(data->utinyData);
|
|
taosMemoryFree(data->smallData);
|
|
taosMemoryFree(data->usmallData);
|
|
taosMemoryFree(data->intData);
|
|
taosMemoryFree(data->uintData);
|
|
taosMemoryFree(data->bigData);
|
|
taosMemoryFree(data->ubigData);
|
|
taosMemoryFree(data->floatData);
|
|
taosMemoryFree(data->doubleData);
|
|
taosMemoryFree(data->binaryData);
|
|
taosMemoryFree(data->binaryLen);
|
|
taosMemoryFree(data->isNull);
|
|
taosMemoryFree(data->pBind);
|
|
taosMemoryFree(data->pTags);
|
|
taosMemoryFree(data->colTypes);
|
|
taosMemoryFree(data->sql);
|
|
}
|
|
|
|
void bpFetchRows(TAOS_RES *result, bool printr, int32_t *rows) {
|
|
TAOS_ROW row;
|
|
int num_fields = taos_num_fields(result);
|
|
TAOS_FIELD *fields = taos_fetch_fields(result);
|
|
char temp[256];
|
|
|
|
// fetch the records row by row
|
|
while ((row = taos_fetch_row(result))) {
|
|
(*rows)++;
|
|
if (printr) {
|
|
memset(temp, 0, sizeof(temp));
|
|
taos_print_row(temp, row, fields, num_fields);
|
|
printf("\t[%s]\n", temp);
|
|
}
|
|
}
|
|
}
|
|
|
|
void bpExecQuery(TAOS *taos, char *sql, bool printr, int32_t *rows) {
|
|
TAOS_RES *result = taos_query(taos, sql);
|
|
int code = taos_errno(result);
|
|
if (code != 0) {
|
|
printf("!!!failed to query table, reason:%s\n", taos_errstr(result));
|
|
taos_free_result(result);
|
|
exit(1);
|
|
}
|
|
|
|
bpFetchRows(result, printr, rows);
|
|
|
|
taos_free_result(result);
|
|
}
|
|
|
|
int32_t bpAppendValueString(char *buf, int type, void *value, int32_t valueLen, int32_t *len) {
|
|
switch (type) {
|
|
case TSDB_DATA_TYPE_NULL:
|
|
*len += sprintf(buf + *len, "null");
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_BOOL:
|
|
*len += sprintf(buf + *len, (*(bool *)value) ? "true" : "false");
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_TINYINT:
|
|
*len += sprintf(buf + *len, "%d", *(int8_t *)value);
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_SMALLINT:
|
|
*len += sprintf(buf + *len, "%d", *(int16_t *)value);
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_INT:
|
|
*len += sprintf(buf + *len, "%d", *(int32_t *)value);
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_BIGINT:
|
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
|
*len += sprintf(buf + *len, "%ld", *(int64_t *)value);
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_FLOAT:
|
|
*len += sprintf(buf + *len, "%e", *(float *)value);
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_DOUBLE:
|
|
*len += sprintf(buf + *len, "%e", *(double *)value);
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_BINARY:
|
|
case TSDB_DATA_TYPE_VARBINARY:
|
|
case TSDB_DATA_TYPE_NCHAR:
|
|
case TSDB_DATA_TYPE_GEOMETRY:
|
|
buf[*len] = '\'';
|
|
++(*len);
|
|
memcpy(buf + *len, value, valueLen);
|
|
*len += valueLen;
|
|
buf[*len] = '\'';
|
|
++(*len);
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_UTINYINT:
|
|
*len += sprintf(buf + *len, "%d", *(uint8_t *)value);
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_USMALLINT:
|
|
*len += sprintf(buf + *len, "%d", *(uint16_t *)value);
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_UINT:
|
|
*len += sprintf(buf + *len, "%u", *(uint32_t *)value);
|
|
break;
|
|
|
|
case TSDB_DATA_TYPE_UBIGINT:
|
|
*len += sprintf(buf + *len, "%lu", *(uint64_t *)value);
|
|
break;
|
|
|
|
default:
|
|
printf("!!!invalid data type:%d\n", type);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
static TAOS_STMT2 *st_stmt2_init(TAOS *taos, bool stb_insert) {
|
|
TAOS_STMT2_OPTION option = {0};
|
|
if (stb_insert) {
|
|
option.singleStbInsert = true;
|
|
option.singleTableBindOnce = true;
|
|
}
|
|
|
|
return taos_stmt2_init(taos, &option);
|
|
}
|
|
|
|
static int st_stmt2_close(TAOS_STMT2 *stmt) { return taos_stmt2_close(stmt); }
|
|
|
|
static char *st_stmt2_error(TAOS_STMT2 *stmt) { return taos_stmt2_error(stmt); }
|
|
|
|
static int st_stmt2_prepare(TAOS_STMT2 *stmt, const char *sql, unsigned long length) {
|
|
return taos_stmt2_prepare(stmt, sql, length);
|
|
}
|
|
|
|
static int st_stmt2_bind(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col_idx) {
|
|
return taos_stmt2_bind_param(stmt, bindv, col_idx);
|
|
}
|
|
|
|
static int st_stmt2_exec(TAOS_STMT2 *stmt, int *affected_rows) { return taos_stmt2_exec(stmt, affected_rows); }
|
|
|
|
static int st_stmt2_is_insert(TAOS_STMT2 *stmt, int *insert) { return taos_stmt2_is_insert(stmt, insert); }
|
|
|
|
// static int st_stmt2_num_params(TAOS_STMT2 *stmt, int *count) {
|
|
// return taos_stmt2_get_fields(stmt, count, NULL);
|
|
// }
|
|
|
|
// static int st_stmt2_get_tag_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_ALL **fields) {
|
|
// return taos_stmt2_get_fields(stmt, count, fields);
|
|
// }
|
|
|
|
// static int st_stmt2_get_col_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_E **fields) {
|
|
// return taos_stmt2_get_fields(stmt, TAOS_FIELD_COL, count, fields);
|
|
// }
|
|
|
|
static int st_stmt2_get_param(TAOS_STMT2 *stmt, int idx, int *type, int *bytes) {
|
|
int32_t code = 0, nums = 0;
|
|
TAOS_FIELD_ALL *fields = NULL;
|
|
|
|
code = taos_stmt2_get_fields(stmt, &nums, &fields);
|
|
if (code) {
|
|
return code;
|
|
}
|
|
|
|
if (idx > nums) {
|
|
taosMemoryFree(fields);
|
|
return -1;
|
|
}
|
|
int i = 0;
|
|
for (; i < nums; i++) {
|
|
if (fields[i].field_type == TAOS_FIELD_COL) {
|
|
idx--;
|
|
}
|
|
if (idx < 0) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
*type = fields[i].type;
|
|
*bytes = fields[i].bytes;
|
|
|
|
taosMemoryFree(fields);
|
|
return 0;
|
|
}
|
|
|
|
static int st_stmt2_set_tbname(TAOS_STMT2 *stmt, char *name) {
|
|
TAOS_STMT2_BINDV bindv = {0};
|
|
bindv.count = 1;
|
|
bindv.tbnames = &name;
|
|
return taos_stmt2_bind_param(stmt, &bindv, -1);
|
|
}
|
|
|
|
static int st_stmt2_set_tags(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *tags) {
|
|
TAOS_STMT2_BINDV bindv = {0};
|
|
bindv.count = 1;
|
|
bindv.tags = &tags;
|
|
return taos_stmt2_bind_param(stmt, &bindv, -1);
|
|
}
|
|
|
|
static int st_stmt2_set_tbname_tags(TAOS_STMT2 *stmt, char *name, TAOS_STMT2_BIND *tags) {
|
|
TAOS_STMT2_BINDV bindv = {0};
|
|
bindv.count = 1;
|
|
bindv.tbnames = &name;
|
|
bindv.tags = &tags;
|
|
return taos_stmt2_bind_param(stmt, &bindv, -1);
|
|
}
|
|
|
|
static int st_stmt2_bind_param_batch(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *bind) {
|
|
TAOS_STMT2_BINDV bindv = {0};
|
|
bindv.count = 1;
|
|
bindv.bind_cols = &bind;
|
|
return taos_stmt2_bind_param(stmt, &bindv, -1);
|
|
}
|
|
|
|
static int st_stmt2_bind_single_param_batch(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *bind, int col_idx) {
|
|
TAOS_STMT2_BINDV bindv = {0};
|
|
bindv.count = 1;
|
|
bindv.bind_cols = &bind;
|
|
return taos_stmt2_bind_param(stmt, &bindv, col_idx);
|
|
}
|
|
|
|
static int st_stmt2_bind_param(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *bind) {
|
|
TAOS_STMT2_BINDV bindv = {0};
|
|
bindv.count = 1;
|
|
bindv.bind_cols = &bind;
|
|
return taos_stmt2_bind_param(stmt, &bindv, -1);
|
|
}
|
|
|
|
static int st_stmt2_add_batch(TAOS_STMT2 *stmt) { return 0; }
|
|
|
|
static TAOS_RES *st_stmt2_use_result(TAOS_STMT2 *stmt) { return taos_stmt2_result(stmt); }
|
|
|
|
void bpCheckIsInsert(TAOS_STMT2 *stmt, int32_t insert) {
|
|
int32_t isInsert = 0;
|
|
if (st_stmt2_is_insert(stmt, &isInsert)) {
|
|
printf("!!!st_stmt2_is_insert error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
if (insert != isInsert) {
|
|
printf("!!!is insert failed\n");
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
void bpCheckParamNum(TAOS_STMT2 *stmt) {
|
|
int32_t num = 0;
|
|
if (taos_stmt2_get_fields(stmt, &num, NULL)) {
|
|
printf("!!!taos_stmt2_get_fields error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
if (gCurCase->bindColNum != num) {
|
|
printf("!!!is insert failed\n");
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
void bpCheckAffectedRows(TAOS_STMT2 *stmt, int32_t times) {
|
|
/* TODO: affected rows from exec
|
|
int32_t rows = taos_stmt_affected_rows(stmt);
|
|
int32_t insertNum = gCurCase->rowNum * gCurCase->tblNum * times;
|
|
if (gCurCase->duplicateValue) {
|
|
insertNum /= 2;
|
|
}
|
|
if (insertNum != rows) {
|
|
printf("!!!affected rows %d mis-match with insert num %d\n", rows, insertNum);
|
|
exit(1);
|
|
}
|
|
*/
|
|
}
|
|
|
|
void bpCheckQueryResult(TAOS_STMT2 *stmt, TAOS *taos, char *stmtSql, TAOS_STMT2_BIND *bind) {
|
|
// query using sql
|
|
char sql[1024];
|
|
int32_t len = 0;
|
|
char *p = stmtSql;
|
|
char *s = NULL;
|
|
int32_t sqlResNum = 0;
|
|
|
|
for (int32_t i = 0; true; ++i, p = s + 1) {
|
|
s = strchr(p, '?');
|
|
if (NULL == s) {
|
|
strcpy(&sql[len], p);
|
|
break;
|
|
}
|
|
|
|
memcpy(&sql[len], p, (int64_t)s - (int64_t)p);
|
|
len += (int32_t)((int64_t)s - (int64_t)p);
|
|
|
|
if (bind[i].is_null && bind[i].is_null[0]) {
|
|
bpAppendValueString(sql, TSDB_DATA_TYPE_NULL, NULL, 0, &len);
|
|
continue;
|
|
}
|
|
|
|
bpAppendValueString(sql, bind[i].buffer_type, bind[i].buffer, (bind[i].length ? bind[i].length[0] : 0), &len);
|
|
}
|
|
|
|
if (gCaseCtrl.printQuerySql) {
|
|
printf("\tQuery SQL: %s\n", sql);
|
|
}
|
|
|
|
bpExecQuery(taos, sql, gCaseCtrl.printRes, &sqlResNum);
|
|
|
|
// query using stmt
|
|
TAOS_RES *res = st_stmt2_use_result(stmt);
|
|
int32_t stmtResNum = 0;
|
|
bpFetchRows(res, gCaseCtrl.printRes, &stmtResNum);
|
|
|
|
if (sqlResNum != stmtResNum) {
|
|
printf("!!!sql res num %d mis-match stmt res num %d\n", sqlResNum, stmtResNum);
|
|
exit(1);
|
|
}
|
|
|
|
printf("***sql res num match stmt res num %d\n", stmtResNum);
|
|
}
|
|
|
|
void bpCheckColTagFields(TAOS_STMT2 *stmt, int32_t fieldNum, TAOS_FIELD_ALL *pFields, int32_t expecteNum,
|
|
TAOS_STMT2_BIND *pBind, BP_BIND_TYPE type) {
|
|
int32_t code = 0;
|
|
|
|
if (fieldNum != expecteNum) {
|
|
printf("!!!%s field num %d mis-match expect num %d\n", BP_BIND_TYPE_STR(type), fieldNum, expecteNum);
|
|
exit(1);
|
|
}
|
|
|
|
if (type == BP_BIND_COL) {
|
|
if (pFields[0].precision != gCaseCtrl.precision) {
|
|
printf("!!!db precision %d mis-match expect %d\n", pFields[0].precision, gCaseCtrl.precision);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
for (int32_t i = 0; i < fieldNum; ++i) {
|
|
if (pFields[i].field_type != type) {
|
|
printf("!!!%s %dth field type %d mis-match expect type %d\n", BP_BIND_TYPE_STR(type), i, pFields[i].field_type,
|
|
TAOS_FIELD_TAG);
|
|
exit(1);
|
|
}
|
|
if (pFields[i].type != pBind[i].buffer_type) {
|
|
printf("!!!%s %dth field type %d mis-match expect type %d\n", BP_BIND_TYPE_STR(type), i, pFields[i].type,
|
|
pBind[i].buffer_type);
|
|
exit(1);
|
|
}
|
|
|
|
if (pFields[i].type == TSDB_DATA_TYPE_BINARY || pFields[i].type == TSDB_DATA_TYPE_VARBINARY ||
|
|
pFields[i].type == TSDB_DATA_TYPE_GEOMETRY) {
|
|
/*
|
|
if (pFields[i].bytes != (pBind[i].buffer_length + 2)) {
|
|
printf("!!!%s %dth field len %d mis-match expect len %d\n", BP_BIND_TYPE_STR(type), i, pFields[i].bytes,
|
|
(pBind[i].buffer_length + 2));
|
|
exit(1);
|
|
}
|
|
*/
|
|
} else if (pFields[i].type == TSDB_DATA_TYPE_NCHAR) {
|
|
/*
|
|
if (pFields[i].bytes != (pBind[i].buffer_length * 4 + 2)) {
|
|
printf("!!!%s %dth field len %d mis-match expect len %d\n", BP_BIND_TYPE_STR(type), i, pFields[i].bytes,
|
|
(pBind[i].buffer_length + 2));
|
|
exit(1);
|
|
}
|
|
*/
|
|
/*} else if (pFields[i].bytes != pBind[i].buffer_length) {
|
|
printf("!!!%s %dth field len %d mis-match expect len %d\n", BP_BIND_TYPE_STR(type), i, pFields[i].bytes,
|
|
pBind[i].buffer_length);
|
|
exit(1);*/
|
|
}
|
|
}
|
|
|
|
if (type == BP_BIND_COL) {
|
|
int fieldType = 0;
|
|
int fieldBytes = 0;
|
|
for (int32_t i = 0; i < fieldNum; ++i) {
|
|
code = st_stmt2_get_param(stmt, i, &fieldType, &fieldBytes);
|
|
if (code) {
|
|
printf("!!!st_stmt2_get_param error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
if (pFields[i].type != fieldType) {
|
|
printf("!!!%s %dth field type %d mis-match expect type %d\n", BP_BIND_TYPE_STR(type), i, fieldType,
|
|
pFields[i].type);
|
|
exit(1);
|
|
}
|
|
|
|
if (pFields[i].bytes != fieldBytes) {
|
|
printf("!!!%s %dth field len %d mis-match expect len %d\n", BP_BIND_TYPE_STR(type), i, fieldBytes,
|
|
pFields[i].bytes);
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (gCaseCtrl.printVerbose) {
|
|
printf("%s fields check passed\n", BP_BIND_TYPE_STR(type));
|
|
}
|
|
}
|
|
|
|
void bpCheckTagFields(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *pBind) {
|
|
int32_t code = 0;
|
|
int fieldNum = 0;
|
|
TAOS_FIELD_ALL *pFields = NULL;
|
|
code = taos_stmt2_get_fields(stmt, &fieldNum, &pFields);
|
|
if (code != 0) {
|
|
printf("!!!taos_stmt2_get_fields error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
int n = fieldNum;
|
|
for (int i = 0; i < n; i++) {
|
|
if (pFields[i].field_type != TAOS_FIELD_TAG) {
|
|
fieldNum--;
|
|
}
|
|
}
|
|
bpCheckColTagFields(stmt, fieldNum, pFields, gCurCase->bindTagNum, pBind, BP_BIND_TAG);
|
|
taos_stmt2_free_fields(stmt, pFields);
|
|
}
|
|
|
|
void bpCheckColFields(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *pBind) {
|
|
if (gCurCase->testType == TTYPE_QUERY) {
|
|
return;
|
|
}
|
|
|
|
int32_t code = 0;
|
|
int fieldNum = 0;
|
|
TAOS_FIELD_ALL *pFields = NULL;
|
|
TAOS_FIELD_ALL *pColFields = NULL;
|
|
|
|
code = taos_stmt2_get_fields(stmt, &fieldNum, &pFields);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_get_col_fields error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
int n = fieldNum;
|
|
pColFields = taosMemoryMalloc(fieldNum * sizeof(TAOS_FIELD_ALL));
|
|
int j = 0;
|
|
for (int i = 0; i < n; i++) {
|
|
if (pFields[i].field_type != TAOS_FIELD_COL) {
|
|
fieldNum--;
|
|
} else {
|
|
pColFields[j++] = pFields[i];
|
|
}
|
|
}
|
|
bpCheckColTagFields(stmt, fieldNum, pColFields, gCurCase->bindColNum, pBind, BP_BIND_COL);
|
|
taosMemoryFree(pFields);
|
|
}
|
|
|
|
void bpShowBindParam(TAOS_STMT2_BIND *bind, int32_t num) {
|
|
for (int32_t i = 0; i < num; ++i) {
|
|
TAOS_STMT2_BIND *b = &bind[i];
|
|
printf("Bind %d: type[%d],buf[%p],len[%d],null[%d],num[%d]\n", i, b->buffer_type, b->buffer,
|
|
/*b->buffer_length,*/ b->length ? *b->length : 0, b->is_null ? *b->is_null : 0, b->num);
|
|
}
|
|
}
|
|
|
|
int32_t bpBindParam(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *bind, bool expectFail) {
|
|
static int32_t n = 0;
|
|
|
|
if (!expectFail) {
|
|
bpCheckColFields(stmt, bind);
|
|
}
|
|
|
|
if (gCurCase->bindRowNum > 1) {
|
|
if (0 == (n++ % 2) || gCurCase->stbInsert) {
|
|
if (st_stmt2_bind_param_batch(stmt, bind)) {
|
|
if (expectFail) return 0;
|
|
printf("!!!st_stmt2_bind_param_batch error:%s\n", st_stmt2_error(stmt));
|
|
bpShowBindParam(bind, gCurCase->bindColNum);
|
|
exit(1);
|
|
}
|
|
} else {
|
|
for (int32_t i = 0; i < gCurCase->bindColNum; ++i) {
|
|
if (st_stmt2_bind_single_param_batch(stmt, bind + i, i)) {
|
|
if (expectFail) continue;
|
|
printf("!!!st_stmt2_bind_single_param_batch %d error:%s\n", i, st_stmt2_error(stmt));
|
|
bpShowBindParam(bind, gCurCase->bindColNum);
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (0 == (n++ % 2)) {
|
|
if (st_stmt2_bind_param_batch(stmt, bind)) {
|
|
if (expectFail) return 0;
|
|
printf("!!!st_stmt2_bind_param_batch error:%s\n", st_stmt2_error(stmt));
|
|
bpShowBindParam(bind, gCurCase->bindColNum);
|
|
exit(1);
|
|
}
|
|
} else {
|
|
if (st_stmt2_bind_param(stmt, bind)) {
|
|
if (expectFail) return 0;
|
|
printf("!!!st_stmt2_bind_param error:%s\n", st_stmt2_error(stmt));
|
|
bpShowBindParam(bind, gCurCase->bindColNum);
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t bpSetTableNameTags(BindData *data, int32_t tblIdx, char *tblName, TAOS_STMT2 *stmt) {
|
|
int32_t code = 0;
|
|
if (gCurCase->bindTagNum > 0) {
|
|
if ((rand() % 2) == 0) {
|
|
code = st_stmt2_set_tbname(stmt, tblName);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckTagFields(stmt, data->pTags + tblIdx * gCurCase->bindTagNum);
|
|
|
|
return st_stmt2_set_tags(stmt, data->pTags + tblIdx * gCurCase->bindTagNum);
|
|
} else {
|
|
return st_stmt2_set_tbname_tags(stmt, tblName, data->pTags + tblIdx * gCurCase->bindTagNum);
|
|
}
|
|
} else {
|
|
return st_stmt2_set_tbname(stmt, tblName);
|
|
}
|
|
}
|
|
|
|
/* prepare [settbname [bind add]] exec */
|
|
int insertMBSETest1(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
int32_t bindTimes = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
if (gCurCase->tblNum > 1) {
|
|
char buf[32];
|
|
sprintf(buf, "t%d", t);
|
|
code = bpSetTableNameTags(&data, t, buf, stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
for (int32_t b = 0; b < bindTimes; ++b) {
|
|
if (bpBindParam(stmt, data.pBind + t * bindTimes * gCurCase->bindColNum + b * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
bpCheckAffectedRows(stmt, 1);
|
|
|
|
destroyData(&data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* prepare [settbname bind add] exec */
|
|
int insertMBSETest2(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
int32_t bindTimes = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
|
|
for (int32_t b = 0; b < bindTimes; ++b) {
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
if (gCurCase->tblNum > 1) {
|
|
char buf[32];
|
|
sprintf(buf, "t%d", t);
|
|
code = bpSetTableNameTags(&data, t, buf, stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (bpBindParam(stmt, data.pBind + t * bindTimes * gCurCase->bindColNum + b * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
bpCheckAffectedRows(stmt, 1);
|
|
|
|
destroyData(&data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* prepare [settbname [bind add] exec] */
|
|
int insertMBMETest1(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
int32_t bindTimes = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
if (gCurCase->tblNum > 1) {
|
|
char buf[32];
|
|
sprintf(buf, "t%d", t);
|
|
code = bpSetTableNameTags(&data, t, buf, stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
for (int32_t b = 0; b < bindTimes; ++b) {
|
|
if (bpBindParam(stmt, data.pBind + t * bindTimes * gCurCase->bindColNum + b * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
bpCheckAffectedRows(stmt, 1);
|
|
|
|
destroyData(&data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* prepare [settbname [bind add exec]] */
|
|
int insertMBMETest2(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
int32_t bindTimes = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
if (gCurCase->tblNum > 1) {
|
|
char buf[32];
|
|
sprintf(buf, "t%d", t);
|
|
code = bpSetTableNameTags(&data, t, buf, stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
for (int32_t b = 0; b < bindTimes; ++b) {
|
|
if (bpBindParam(stmt, data.pBind + t * bindTimes * gCurCase->bindColNum + b * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
bpCheckAffectedRows(stmt, 1);
|
|
|
|
destroyData(&data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* prepare [settbname [settbname bind add exec]] */
|
|
int insertMBMETest3(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
int32_t bindTimes = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
if (gCurCase->tblNum > 1) {
|
|
char buf[32];
|
|
sprintf(buf, "t%d", t);
|
|
code = bpSetTableNameTags(&data, t, buf, stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
for (int32_t b = 0; b < bindTimes; ++b) {
|
|
if (gCurCase->tblNum > 1) {
|
|
char buf[32];
|
|
sprintf(buf, "t%d", t);
|
|
code = bpSetTableNameTags(&data, t, buf, stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (bpBindParam(stmt, data.pBind + t * bindTimes * gCurCase->bindColNum + b * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
bpCheckAffectedRows(stmt, 1);
|
|
|
|
destroyData(&data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* prepare [settbname bind add exec] */
|
|
int insertMBMETest4(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
int32_t bindTimes = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
|
|
for (int32_t b = 0; b < bindTimes; ++b) {
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
if (gCurCase->tblNum > 1) {
|
|
char buf[32];
|
|
sprintf(buf, "t%d", t);
|
|
code = bpSetTableNameTags(&data, t, buf, stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (bpBindParam(stmt, data.pBind + t * bindTimes * gCurCase->bindColNum + b * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
bpCheckAffectedRows(stmt, 1);
|
|
|
|
destroyData(&data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* [prepare [settbname [bind add] exec]] */
|
|
int insertMPMETest1(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
int32_t loop = 0;
|
|
|
|
while (gCurCase->bindColNum >= 2) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
int32_t bindTimes = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
if (gCurCase->tblNum > 1) {
|
|
char buf[32];
|
|
sprintf(buf, "t%d", t);
|
|
code = bpSetTableNameTags(&data, t, buf, stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
for (int32_t b = 0; b < bindTimes; ++b) {
|
|
if (bpBindParam(stmt, data.pBind + t * bindTimes * gCurCase->bindColNum + b * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
destroyData(&data);
|
|
|
|
gCurCase->bindColNum -= 2;
|
|
gCurCase->fullCol = false;
|
|
loop++;
|
|
}
|
|
|
|
bpCheckAffectedRows(stmt, loop);
|
|
|
|
gExecLoopTimes = loop;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* prepare [settbname [bind] exec] */
|
|
int insertStbTest(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
int32_t bindTimes = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
if (gCurCase->tblNum > 1) {
|
|
char buf[32];
|
|
sprintf(buf, "t%d", t);
|
|
code = bpSetTableNameTags(&data, t, buf, stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
for (int32_t b = 0; b < bindTimes; ++b) {
|
|
if (bpBindParam(stmt, data.pBind + t * bindTimes * gCurCase->bindColNum + b * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
destroyData(&data);
|
|
|
|
bpCheckAffectedRows(stmt, 1);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* [prepare [settbnametag [bind add] exec]] */
|
|
int insertAUTOTest1(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
int32_t loop = 0;
|
|
|
|
while (gCurCase->bindTagNum > 0 && gCurCase->bindColNum > 0) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
int32_t bindTimes = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
if (gCurCase->tblNum > 1) {
|
|
char buf[32];
|
|
sprintf(buf, "t%d", t);
|
|
code = bpSetTableNameTags(&data, t, buf, stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname_tags error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
for (int32_t b = 0; b < bindTimes; ++b) {
|
|
if (bpBindParam(stmt, data.pBind + t * bindTimes * gCurCase->bindColNum + b * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
destroyData(&data);
|
|
|
|
gCurCase->bindColNum -= 2;
|
|
gCurCase->bindTagNum -= 2;
|
|
gCurCase->fullCol = false;
|
|
loop++;
|
|
}
|
|
|
|
bpCheckAffectedRows(stmt, loop);
|
|
|
|
gExecLoopTimes = loop;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* [prepare [settbnametag [bind add exec]]] */
|
|
int insertAUTOTest2(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
int32_t loop = 0;
|
|
|
|
while (gCurCase->bindTagNum > 0 && gCurCase->bindColNum > 0) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
int32_t bindTimes = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
for (int32_t b = 0; b < bindTimes; ++b) {
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
if (gCurCase->tblNum > 1) {
|
|
char buf[32];
|
|
sprintf(buf, "t%d", t);
|
|
code = bpSetTableNameTags(&data, t, buf, stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname_tags error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
if (bpBindParam(stmt, data.pBind + t * bindTimes * gCurCase->bindColNum + b * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
destroyData(&data);
|
|
|
|
gCurCase->bindColNum -= 2;
|
|
gCurCase->bindTagNum -= 2;
|
|
gCurCase->fullCol = false;
|
|
loop++;
|
|
}
|
|
|
|
bpCheckAffectedRows(stmt, loop);
|
|
|
|
gExecLoopTimes = loop;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* normal table [prepare [bind add exec]] */
|
|
int insertAUTOTest3(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
int32_t loop = 0;
|
|
|
|
while (gCurCase->bindColNum > 0) {
|
|
BindData data = {0};
|
|
data.singleTbInsert = true;
|
|
prepareInsertData(&data);
|
|
|
|
int32_t bindTimes = gCurCase->rowNum / gCurCase->bindRowNum;
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
data.singleTbIdx = t;
|
|
generateInsertSQL(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
for (int32_t b = 0; b < bindTimes; ++b) {
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
if (bpBindParam(stmt, data.pBind + t * bindTimes * gCurCase->bindColNum + b * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
destroyData(&data);
|
|
|
|
gCurCase->bindColNum -= 2;
|
|
gCurCase->fullCol = false;
|
|
loop++;
|
|
}
|
|
|
|
bpCheckAffectedRows(stmt, loop);
|
|
|
|
gExecLoopTimes = loop;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* select * from table */
|
|
int queryColumnTest(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
memset(&data, 0, sizeof(data));
|
|
prepareQueryCondData(&data, t);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
for (int32_t n = 0; n < (gCurCase->rowNum / gCurCase->bindRowNum); ++n) {
|
|
bpCheckIsInsert(stmt, 0);
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
if (bpBindParam(stmt, data.pBind + n * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (rand() % 2 == 0) {
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckQueryResult(stmt, taos, data.sql, data.pBind + n * gCurCase->bindColNum);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 0);
|
|
|
|
destroyData(&data);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* value in query sql */
|
|
int queryMiscTest(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
memset(&data, 0, sizeof(data));
|
|
prepareQueryMiscData(&data, t);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
for (int32_t n = 0; n < (gCurCase->rowNum / gCurCase->bindRowNum); ++n) {
|
|
bpCheckIsInsert(stmt, 0);
|
|
|
|
if (gCaseCtrl.checkParamNum) {
|
|
bpCheckParamNum(stmt);
|
|
}
|
|
|
|
if (bpBindParam(stmt, data.pBind + n * gCurCase->bindColNum, false)) {
|
|
exit(1);
|
|
}
|
|
|
|
if (rand() % 2 == 0) {
|
|
if (st_stmt2_add_batch(stmt)) {
|
|
printf("!!!st_stmt2_add_batch error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if (st_stmt2_exec(stmt, NULL) != 0) {
|
|
printf("!!!st_stmt2_exec error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckQueryResult(stmt, taos, data.sql, data.pBind + n * gCurCase->bindColNum);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 0);
|
|
|
|
destroyData(&data);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int insertNonExistsTb(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
char *buf = "tbnexist";
|
|
code = bpSetTableNameTags(&data, 0, buf, stmt);
|
|
if (code == 0) {
|
|
printf("!!!st_stmt2_set_tbname expected error not occurred\n");
|
|
exit(1);
|
|
}
|
|
|
|
if (0 == st_stmt2_bind_param_batch(stmt, data.pBind)) {
|
|
printf("!!!st_stmt2_bind_param_batch expected error not occurred\n");
|
|
exit(1);
|
|
}
|
|
|
|
if (0 == st_stmt2_exec(stmt, NULL)) {
|
|
printf("!!!st_stmt2_execute expected error not occurred\n");
|
|
exit(1);
|
|
}
|
|
|
|
destroyData(&data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void bpAddWrongVarBuffLen(TAOS_STMT2_BIND *pBind) {
|
|
for (int32_t i = 0; i < gCurCase->bindColNum; ++i) {
|
|
if (pBind[i].buffer_type == TSDB_DATA_TYPE_BINARY || pBind[i].buffer_type == TSDB_DATA_TYPE_VARBINARY ||
|
|
pBind[i].buffer_type == TSDB_DATA_TYPE_NCHAR) {
|
|
*pBind[i].length += 100;
|
|
}
|
|
}
|
|
}
|
|
|
|
int insertVarLenErr(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
prepareInsertData(&data);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("!!!failed to execute st_stmt2_prepare. error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpCheckIsInsert(stmt, 1);
|
|
|
|
code = bpSetTableNameTags(&data, 0, "t0", stmt);
|
|
if (code != 0) {
|
|
printf("!!!st_stmt2_set_tbname error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
bpAddWrongVarBuffLen(data.pBind);
|
|
|
|
if (bpBindParam(stmt, data.pBind, true)) {
|
|
exit(1);
|
|
}
|
|
|
|
destroyData(&data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int errorSQLTest1(TAOS_STMT2 *stmt, TAOS *taos) {
|
|
BindData data = {0};
|
|
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
memset(&data, 0, sizeof(data));
|
|
generateErrorSQL(&data, t);
|
|
|
|
int code = st_stmt2_prepare(stmt, data.sql, 0);
|
|
if (code != 0) {
|
|
printf("*st_stmt2_prepare error as expected, error:%s\n", st_stmt2_error(stmt));
|
|
} else {
|
|
printf("!!!st_stmt2_prepare succeed, which should be error\n");
|
|
exit(1);
|
|
}
|
|
|
|
destroyData(&data);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void prepareCheckResultImpl(TAOS *taos, char *tname, bool printr, int expected, bool silent) {
|
|
if (TTYPE_INSERT_NG == gCurCase->testType) {
|
|
return;
|
|
}
|
|
|
|
char sql[255] = "SELECT * FROM ";
|
|
int32_t rows = 0;
|
|
|
|
strcat(sql, tname);
|
|
bpExecQuery(taos, sql, printr, &rows);
|
|
|
|
if (rows == expected) {
|
|
if (!silent) {
|
|
printf("***%d rows are fetched as expected from %s\n", rows, tname);
|
|
}
|
|
} else {
|
|
printf("!!!expect rows %d mis-match rows %d fetched from %s\n", expected, rows, tname);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
void prepareCheckResult(TAOS *taos, bool silent) {
|
|
char buf[32];
|
|
for (int32_t t = 0; t < gCurCase->tblNum; ++t) {
|
|
if (gCurCase->tblNum > 1) {
|
|
sprintf(buf, "%s%d", bpTbPrefix, t);
|
|
} else {
|
|
sprintf(buf, "%s%d", bpTbPrefix, 0);
|
|
}
|
|
|
|
prepareCheckResultImpl(
|
|
taos, buf, gCaseCtrl.printRes,
|
|
gCurCase->duplicateValue ? (gCurCase->rowNum * gExecLoopTimes / 2) : (gCurCase->rowNum * gExecLoopTimes),
|
|
silent);
|
|
}
|
|
|
|
gExecLoopTimes = 1;
|
|
}
|
|
|
|
// 120table 60 record each table
|
|
int sql_perf1(TAOS *taos) {
|
|
char *sql[3000] = {0};
|
|
TAOS_RES *result;
|
|
|
|
for (int i = 0; i < 3000; i++) {
|
|
sql[i] = taosMemoryCalloc(1, 1048576);
|
|
}
|
|
|
|
int len = 0;
|
|
int tss = 0;
|
|
for (int l = 0; l < 3000; ++l) {
|
|
len = sprintf(sql[l], "insert into ");
|
|
for (int t = 0; t < 120; ++t) {
|
|
len += sprintf(sql[l] + len, "m%d values ", t);
|
|
for (int m = 0; m < 60; ++m) {
|
|
len += sprintf(sql[l] + len,
|
|
"(%d, %d, %d, %d, %d, %d, %f, %f, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", "
|
|
"\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") ",
|
|
tss++, m, m, m, m, m, m + 1.0, m + 1.0);
|
|
}
|
|
}
|
|
}
|
|
|
|
int64_t starttime = taosGetTimestampUs();
|
|
for (int i = 0; i < 3000; ++i) {
|
|
result = taos_query(taos, sql[i]);
|
|
int code = taos_errno(result);
|
|
if (code != 0) {
|
|
printf("%d failed to query table, reason:%s\n", taos_errstr(result));
|
|
taos_free_result(result);
|
|
exit(1);
|
|
}
|
|
|
|
taos_free_result(result);
|
|
}
|
|
int64_t endtime = taosGetTimestampUs();
|
|
printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000 * 120 * 60,
|
|
(endtime - starttime) / 1000000UL, (endtime - starttime) / (3000 * 120 * 60));
|
|
|
|
for (int i = 0; i < 3000; i++) {
|
|
taosMemoryFree(sql[i]);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
// one table 60 records one time
|
|
int sql_perf_s1(TAOS *taos) {
|
|
char **sql = calloc(1, sizeof(char *) * 360000);
|
|
TAOS_RES *result;
|
|
|
|
for (int i = 0; i < 360000; i++) {
|
|
sql[i] = taosMemoryCalloc(1, 9000);
|
|
}
|
|
|
|
int len = 0;
|
|
int tss = 0;
|
|
int id = 0;
|
|
for (int t = 0; t < 120; ++t) {
|
|
for (int l = 0; l < 3000; ++l) {
|
|
len = sprintf(sql[id], "insert into m%d values ", t);
|
|
for (int m = 0; m < 60; ++m) {
|
|
len += sprintf(sql[id] + len,
|
|
"(%d, %d, %d, %d, %d, %d, %f, %f, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", "
|
|
"\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") ",
|
|
tss++, m, m, m, m, m, m + 1.0, m + 1.0);
|
|
}
|
|
if (len >= 9000) {
|
|
printf("sql:%s,len:%d\n", sql[id], len);
|
|
exit(1);
|
|
}
|
|
++id;
|
|
}
|
|
}
|
|
|
|
unsigned long long starttime = taosGetTimestampUs();
|
|
for (int i = 0; i < 360000; ++i) {
|
|
result = taos_query(taos, sql[i]);
|
|
int code = taos_errno(result);
|
|
if (code != 0) {
|
|
printf("failed to query table, reason:%s\n", taos_errstr(result));
|
|
taos_free_result(result);
|
|
exit(1);
|
|
}
|
|
|
|
taos_free_result(result);
|
|
}
|
|
unsigned long long endtime = taosGetTimestampUs();
|
|
printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000 * 120 * 60,
|
|
(endtime - starttime) / 1000000UL, (endtime - starttime) / (3000 * 120 * 60));
|
|
|
|
for (int i = 0; i < 360000; i++) {
|
|
taosMemoryFree(sql[i]);
|
|
}
|
|
|
|
taosMemoryFree(sql);
|
|
|
|
return 0;
|
|
}
|
|
|
|
// small record size
|
|
int sql_s_perf1(TAOS *taos) {
|
|
char *sql[3000] = {0};
|
|
TAOS_RES *result;
|
|
|
|
for (int i = 0; i < 3000; i++) {
|
|
sql[i] = taosMemoryCalloc(1, 1048576);
|
|
}
|
|
|
|
int len = 0;
|
|
int tss = 0;
|
|
for (int l = 0; l < 3000; ++l) {
|
|
len = sprintf(sql[l], "insert into ");
|
|
for (int t = 0; t < 120; ++t) {
|
|
len += sprintf(sql[l] + len, "m%d values ", t);
|
|
for (int m = 0; m < 60; ++m) {
|
|
len += sprintf(sql[l] + len, "(%d, %d) ", tss++, m % 2);
|
|
}
|
|
}
|
|
}
|
|
|
|
unsigned long long starttime = taosGetTimestampUs();
|
|
for (int i = 0; i < 3000; ++i) {
|
|
result = taos_query(taos, sql[i]);
|
|
int code = taos_errno(result);
|
|
if (code != 0) {
|
|
printf("failed to query table, reason:%s\n", taos_errstr(result));
|
|
taos_free_result(result);
|
|
exit(1);
|
|
}
|
|
|
|
taos_free_result(result);
|
|
}
|
|
unsigned long long endtime = taosGetTimestampUs();
|
|
printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000 * 120 * 60,
|
|
(endtime - starttime) / 1000000UL, (endtime - starttime) / (3000 * 120 * 60));
|
|
|
|
for (int i = 0; i < 3000; i++) {
|
|
taosMemoryFree(sql[i]);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void generateCreateTableSQL(char *buf, int32_t tblIdx, int32_t colNum, int32_t *colList, int32_t tableType) {
|
|
int32_t blen = 0;
|
|
blen = sprintf(buf, "create table %s%d ", (1 == tableType ? bpStbPrefix : bpTbPrefix), tblIdx);
|
|
|
|
if (tableType == 3) {
|
|
blen += sprintf(buf + blen, "using %s%d", bpStbPrefix, bpDefaultStbId);
|
|
}
|
|
|
|
if (tableType == 0 || tableType == 1) {
|
|
blen += sprintf(buf + blen, " (");
|
|
|
|
for (int c = 0; c < colNum; ++c) {
|
|
if (c > 0) {
|
|
blen += sprintf(buf + blen, ",");
|
|
}
|
|
|
|
switch (colList[c]) {
|
|
case TSDB_DATA_TYPE_BOOL:
|
|
blen += sprintf(buf + blen, "booldata bool");
|
|
break;
|
|
case TSDB_DATA_TYPE_TINYINT:
|
|
blen += sprintf(buf + blen, "tinydata tinyint");
|
|
break;
|
|
case TSDB_DATA_TYPE_SMALLINT:
|
|
blen += sprintf(buf + blen, "smalldata smallint");
|
|
break;
|
|
case TSDB_DATA_TYPE_INT:
|
|
blen += sprintf(buf + blen, "intdata int");
|
|
break;
|
|
case TSDB_DATA_TYPE_BIGINT:
|
|
blen += sprintf(buf + blen, "bigdata bigint");
|
|
break;
|
|
case TSDB_DATA_TYPE_FLOAT:
|
|
blen += sprintf(buf + blen, "floatdata float");
|
|
break;
|
|
case TSDB_DATA_TYPE_DOUBLE:
|
|
blen += sprintf(buf + blen, "doubledata double");
|
|
break;
|
|
case TSDB_DATA_TYPE_VARCHAR:
|
|
blen += sprintf(buf + blen, "binarydata binary(%d)", gVarCharSize);
|
|
break;
|
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
|
blen += sprintf(buf + blen, "ts timestamp");
|
|
break;
|
|
case TSDB_DATA_TYPE_NCHAR:
|
|
blen += sprintf(buf + blen, "nchardata nchar(%d)", gVarCharSize);
|
|
break;
|
|
case TSDB_DATA_TYPE_UTINYINT:
|
|
blen += sprintf(buf + blen, "utinydata tinyint unsigned");
|
|
break;
|
|
case TSDB_DATA_TYPE_USMALLINT:
|
|
blen += sprintf(buf + blen, "usmalldata smallint unsigned");
|
|
break;
|
|
case TSDB_DATA_TYPE_UINT:
|
|
blen += sprintf(buf + blen, "uintdata int unsigned");
|
|
break;
|
|
case TSDB_DATA_TYPE_UBIGINT:
|
|
blen += sprintf(buf + blen, "ubigdata bigint unsigned");
|
|
break;
|
|
default:
|
|
printf("invalid col type:%d", colList[c]);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
blen += sprintf(buf + blen, ")");
|
|
}
|
|
|
|
if (1 == tableType) {
|
|
blen += sprintf(buf + blen, " tags (");
|
|
for (int c = 0; c < colNum; ++c) {
|
|
if (c > 0) {
|
|
blen += sprintf(buf + blen, ",");
|
|
}
|
|
switch (colList[c]) {
|
|
case TSDB_DATA_TYPE_BOOL:
|
|
blen += sprintf(buf + blen, "tbooldata bool");
|
|
break;
|
|
case TSDB_DATA_TYPE_TINYINT:
|
|
blen += sprintf(buf + blen, "ttinydata tinyint");
|
|
break;
|
|
case TSDB_DATA_TYPE_SMALLINT:
|
|
blen += sprintf(buf + blen, "tsmalldata smallint");
|
|
break;
|
|
case TSDB_DATA_TYPE_INT:
|
|
blen += sprintf(buf + blen, "tintdata int");
|
|
break;
|
|
case TSDB_DATA_TYPE_BIGINT:
|
|
blen += sprintf(buf + blen, "tbigdata bigint");
|
|
break;
|
|
case TSDB_DATA_TYPE_FLOAT:
|
|
blen += sprintf(buf + blen, "tfloatdata float");
|
|
break;
|
|
case TSDB_DATA_TYPE_DOUBLE:
|
|
blen += sprintf(buf + blen, "tdoubledata double");
|
|
break;
|
|
case TSDB_DATA_TYPE_VARCHAR:
|
|
blen += sprintf(buf + blen, "tbinarydata binary(%d)", gVarCharSize);
|
|
break;
|
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
|
blen += sprintf(buf + blen, "tts timestamp");
|
|
break;
|
|
case TSDB_DATA_TYPE_NCHAR:
|
|
blen += sprintf(buf + blen, "tnchardata nchar(%d)", gVarCharSize);
|
|
break;
|
|
case TSDB_DATA_TYPE_UTINYINT:
|
|
blen += sprintf(buf + blen, "tutinydata tinyint unsigned");
|
|
break;
|
|
case TSDB_DATA_TYPE_USMALLINT:
|
|
blen += sprintf(buf + blen, "tusmalldata smallint unsigned");
|
|
break;
|
|
case TSDB_DATA_TYPE_UINT:
|
|
blen += sprintf(buf + blen, "tuintdata int unsigned");
|
|
break;
|
|
case TSDB_DATA_TYPE_UBIGINT:
|
|
blen += sprintf(buf + blen, "tubigdata bigint unsigned");
|
|
break;
|
|
default:
|
|
printf("invalid col type:%d", colList[c]);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
blen += sprintf(buf + blen, ")");
|
|
}
|
|
|
|
if (3 == tableType) {
|
|
blen += sprintf(buf + blen, " tags (");
|
|
for (int c = 0; c < colNum; ++c) {
|
|
if (c > 0) {
|
|
blen += sprintf(buf + blen, ",");
|
|
}
|
|
switch (colList[c]) {
|
|
case TSDB_DATA_TYPE_BOOL:
|
|
blen += sprintf(buf + blen, "%s", rand() % 2 ? "true" : "false");
|
|
break;
|
|
case TSDB_DATA_TYPE_TINYINT:
|
|
blen += sprintf(buf + blen, "%d", rand() % 128);
|
|
break;
|
|
case TSDB_DATA_TYPE_SMALLINT:
|
|
blen += sprintf(buf + blen, "%d", rand() % 128);
|
|
break;
|
|
case TSDB_DATA_TYPE_INT:
|
|
blen += sprintf(buf + blen, "%d", rand() % 128);
|
|
break;
|
|
case TSDB_DATA_TYPE_BIGINT:
|
|
blen += sprintf(buf + blen, "%d", rand() % 128);
|
|
break;
|
|
case TSDB_DATA_TYPE_FLOAT:
|
|
blen += sprintf(buf + blen, "%f", rand() % 128);
|
|
break;
|
|
case TSDB_DATA_TYPE_DOUBLE:
|
|
blen += sprintf(buf + blen, "%f", rand() % 128);
|
|
break;
|
|
case TSDB_DATA_TYPE_VARCHAR:
|
|
blen += sprintf(buf + blen, "'var%d'", rand() % 128);
|
|
break;
|
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
|
blen += sprintf(buf + blen, "%lld", bpTs);
|
|
break;
|
|
case TSDB_DATA_TYPE_NCHAR:
|
|
blen += sprintf(buf + blen, "'nch%d'", rand() % 128);
|
|
break;
|
|
case TSDB_DATA_TYPE_UTINYINT:
|
|
blen += sprintf(buf + blen, "%d", rand() % 128);
|
|
break;
|
|
case TSDB_DATA_TYPE_USMALLINT:
|
|
blen += sprintf(buf + blen, "%d", rand() % 128);
|
|
break;
|
|
case TSDB_DATA_TYPE_UINT:
|
|
blen += sprintf(buf + blen, "%d", rand() % 128);
|
|
break;
|
|
case TSDB_DATA_TYPE_UBIGINT:
|
|
blen += sprintf(buf + blen, "%d", rand() % 128);
|
|
break;
|
|
default:
|
|
printf("invalid col type:%d", colList[c]);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
blen += sprintf(buf + blen, ")");
|
|
}
|
|
|
|
if (gCaseCtrl.printCreateTblSql) {
|
|
printf("\tCreate Table SQL:%s\n", buf);
|
|
}
|
|
}
|
|
|
|
char *bpPrecisionStr(uint8_t precision) {
|
|
switch (precision) {
|
|
case TIME_PRECISION_MILLI:
|
|
return "ms";
|
|
case TIME_PRECISION_MICRO:
|
|
return "us";
|
|
case TIME_PRECISION_NANO:
|
|
return "ns";
|
|
default:
|
|
return "unknwon";
|
|
}
|
|
}
|
|
|
|
void bpSetStartupTs() {
|
|
switch (gCaseCtrl.precision) {
|
|
case TIME_PRECISION_MILLI:
|
|
bpTs = BP_STARTUP_TS;
|
|
break;
|
|
case TIME_PRECISION_MICRO:
|
|
bpTs = BP_STARTUP_TS * 1000;
|
|
break;
|
|
case TIME_PRECISION_NANO:
|
|
bpTs = BP_STARTUP_TS * 1000000;
|
|
break;
|
|
default:
|
|
bpTs = BP_STARTUP_TS;
|
|
break;
|
|
}
|
|
}
|
|
|
|
void prepare(TAOS *taos, int32_t colNum, int32_t *colList, int prepareStb) {
|
|
TAOS_RES *result;
|
|
int code;
|
|
char createDbSql[128] = {0};
|
|
|
|
result = taos_query(taos, "drop database demo");
|
|
taos_free_result(result);
|
|
|
|
sprintf(createDbSql, "create database demo keep 36500 precision \"%s\"", bpPrecisionStr(gCaseCtrl.precision));
|
|
printf("\tCreate Database SQL:%s\n", createDbSql);
|
|
|
|
result = taos_query(taos, createDbSql);
|
|
code = taos_errno(result);
|
|
if (code != 0) {
|
|
printf("!!!failed to create database, reason:%s\n", taos_errstr(result));
|
|
taos_free_result(result);
|
|
exit(1);
|
|
}
|
|
taos_free_result(result);
|
|
|
|
result = taos_query(taos, "use demo");
|
|
taos_free_result(result);
|
|
|
|
if (0 == prepareStb) {
|
|
// create table
|
|
for (int i = 0; i < 10; i++) {
|
|
char buf[1024];
|
|
generateCreateTableSQL(buf, i, colNum, colList, 0);
|
|
result = taos_query(taos, buf);
|
|
code = taos_errno(result);
|
|
if (code != 0) {
|
|
printf("!!!failed to create table, reason:%s\n", taos_errstr(result));
|
|
taos_free_result(result);
|
|
exit(1);
|
|
}
|
|
taos_free_result(result);
|
|
}
|
|
} else {
|
|
if (1 == prepareStb || 3 == prepareStb) {
|
|
char buf[1024];
|
|
generateCreateTableSQL(buf, bpDefaultStbId, colNum, colList, 1);
|
|
|
|
result = taos_query(taos, buf);
|
|
code = taos_errno(result);
|
|
if (code != 0) {
|
|
printf("!!!failed to create table, reason:%s\n", taos_errstr(result));
|
|
taos_free_result(result);
|
|
exit(1);
|
|
}
|
|
taos_free_result(result);
|
|
}
|
|
|
|
if (3 == prepareStb) {
|
|
for (int i = 0; i < 10; i++) {
|
|
char buf[1024];
|
|
generateCreateTableSQL(buf, i, colNum, colList, 3);
|
|
result = taos_query(taos, buf);
|
|
code = taos_errno(result);
|
|
if (code != 0) {
|
|
printf("!!!failed to create table, reason:%s\n", taos_errstr(result));
|
|
taos_free_result(result);
|
|
exit(1);
|
|
}
|
|
taos_free_result(result);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
int32_t runCase(TAOS *taos, int32_t caseIdx, int32_t caseRunIdx, bool silent) {
|
|
TAOS_STMT2 *stmt = NULL;
|
|
int64_t beginUs, endUs, totalUs;
|
|
CaseCfg cfg = gCase[caseIdx];
|
|
CaseCfg cfgBk;
|
|
gCurCase = &cfg;
|
|
|
|
bpSetStartupTs();
|
|
|
|
if ((gCaseCtrl.bindColTypeNum || gCaseCtrl.bindColNum) && (gCurCase->colNum != gFullColNum)) {
|
|
return 1;
|
|
}
|
|
|
|
if (gCurCase->preCaseIdx >= 0) {
|
|
bool printRes = gCaseCtrl.printRes;
|
|
bool printStmtSql = gCaseCtrl.printStmtSql;
|
|
gCaseCtrl.printRes = false;
|
|
gCaseCtrl.printStmtSql = false;
|
|
runCase(taos, gCurCase->preCaseIdx, caseRunIdx, true);
|
|
gCaseCtrl.printRes = printRes;
|
|
gCaseCtrl.printStmtSql = printStmtSql;
|
|
|
|
gCurCase = &cfg;
|
|
}
|
|
|
|
if (gCaseCtrl.runTimes) {
|
|
gCurCase->runTimes = gCaseCtrl.runTimes;
|
|
}
|
|
|
|
if (gCaseCtrl.rowNum) {
|
|
gCurCase->rowNum = gCaseCtrl.rowNum;
|
|
}
|
|
|
|
if (gCaseCtrl.autoCreateTbl) {
|
|
if (gCurCase->testType == TTYPE_INSERT && gCurCase->tblNum > 1) {
|
|
gCurCase->autoCreateTbl = 1;
|
|
if (gCurCase->bindTagNum <= 0) {
|
|
gCurCase->bindTagNum = gCurCase->colNum;
|
|
}
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
if (gCurCase->fullCol) {
|
|
gCurCase->bindColNum = gCurCase->colNum;
|
|
if (gCurCase->autoCreateTbl) {
|
|
gCurCase->bindTagNum = gCurCase->colNum;
|
|
}
|
|
}
|
|
|
|
gCurCase->bindNullNum = gCaseCtrl.bindNullNum;
|
|
if (gCaseCtrl.bindColNum) {
|
|
gCurCase->bindColNum = gCaseCtrl.bindColNum;
|
|
gCurCase->fullCol = false;
|
|
}
|
|
if (gCaseCtrl.bindTagNum) {
|
|
gCurCase->bindTagNum = gCaseCtrl.bindTagNum;
|
|
gCurCase->fullCol = false;
|
|
}
|
|
if (gCaseCtrl.bindRowNum) {
|
|
gCurCase->bindRowNum = gCaseCtrl.bindRowNum;
|
|
}
|
|
if (gCaseCtrl.bindColTypeNum) {
|
|
gCurCase->bindColNum = gCaseCtrl.bindColTypeNum;
|
|
gCurCase->fullCol = false;
|
|
}
|
|
if (gCaseCtrl.bindTagTypeNum) {
|
|
gCurCase->bindTagNum = gCaseCtrl.bindTagTypeNum;
|
|
gCurCase->fullCol = false;
|
|
}
|
|
|
|
if (!silent) {
|
|
printf("* Case %d - [%s]%s Begin *\n", caseRunIdx, gCaseCtrl.caseCatalog, gCurCase->caseDesc);
|
|
}
|
|
|
|
totalUs = 0;
|
|
cfgBk = cfg;
|
|
for (int32_t n = 0; n < gCurCase->runTimes; ++n) {
|
|
if (gCurCase->preCaseIdx < 0) {
|
|
prepare(taos, gCurCase->colNum, gCurCase->colList, gCurCase->autoCreateTbl);
|
|
}
|
|
|
|
beginUs = taosGetTimestampUs();
|
|
|
|
stmt = st_stmt2_init(taos, gCurCase->stbInsert);
|
|
if (!stmt) {
|
|
printf("!!!st_stmt2_init failed, error:%s\n", st_stmt2_error(stmt));
|
|
exit(1);
|
|
}
|
|
|
|
(*gCurCase->runFn)(stmt, taos);
|
|
|
|
(void)st_stmt2_close(stmt);
|
|
|
|
endUs = taosGetTimestampUs();
|
|
totalUs += (endUs - beginUs);
|
|
|
|
prepareCheckResult(taos, silent);
|
|
|
|
cfg = cfgBk;
|
|
}
|
|
|
|
if (!silent) {
|
|
printf("* Case %d - [%s]%s [AvgTime:%.3fms] End *\n", caseRunIdx, gCaseCtrl.caseCatalog, gCurCase->caseDesc,
|
|
((double)totalUs) / 1000 / gCurCase->runTimes);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void *runCaseList(TAOS *taos) {
|
|
static int32_t caseRunIdx = 0;
|
|
static int32_t caseRunNum = 0;
|
|
int32_t caseNum = 0;
|
|
int32_t caseIdx = (gCaseCtrl.caseIdx >= 0) ? gCaseCtrl.caseIdx : 0;
|
|
|
|
for (int32_t i = caseIdx; i < sizeof(gCase) / sizeof(gCase[0]); ++i) {
|
|
if (gCaseCtrl.caseNum > 0 && caseNum >= gCaseCtrl.caseNum) {
|
|
break;
|
|
}
|
|
|
|
if (gCaseCtrl.caseRunNum > 0 && caseRunNum >= gCaseCtrl.caseRunNum) {
|
|
break;
|
|
}
|
|
|
|
if (gCaseCtrl.caseRunIdx >= 0 && caseRunIdx < gCaseCtrl.caseRunIdx) {
|
|
caseRunIdx++;
|
|
continue;
|
|
}
|
|
|
|
if (runCase(taos, i, caseRunIdx, false)) {
|
|
continue;
|
|
}
|
|
|
|
caseRunIdx++;
|
|
caseNum++;
|
|
caseRunNum++;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void runAll(TAOS *taos) {
|
|
strcpy(gCaseCtrl.caseCatalog, "Default Test");
|
|
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
|
runCaseList(taos);
|
|
|
|
#if 1
|
|
strcpy(gCaseCtrl.caseCatalog, "Micro DB precision Test");
|
|
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
|
gCaseCtrl.precision = TIME_PRECISION_MICRO;
|
|
runCaseList(taos);
|
|
gCaseCtrl.precision = TIME_PRECISION_MILLI;
|
|
|
|
strcpy(gCaseCtrl.caseCatalog, "Nano DB precision Test");
|
|
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
|
gCaseCtrl.precision = TIME_PRECISION_NANO;
|
|
runCaseList(taos);
|
|
gCaseCtrl.precision = TIME_PRECISION_MILLI;
|
|
|
|
strcpy(gCaseCtrl.caseCatalog, "Auto Create Table Test");
|
|
gCaseCtrl.autoCreateTbl = true;
|
|
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
|
runCaseList(taos);
|
|
gCaseCtrl.autoCreateTbl = false;
|
|
|
|
strcpy(gCaseCtrl.caseCatalog, "Null Test");
|
|
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
|
gCaseCtrl.bindNullNum = 1;
|
|
runCaseList(taos);
|
|
gCaseCtrl.bindNullNum = 0;
|
|
|
|
strcpy(gCaseCtrl.caseCatalog, "Bind Row Test");
|
|
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
|
gCaseCtrl.bindRowNum = 1;
|
|
runCaseList(taos);
|
|
gCaseCtrl.bindRowNum = 0;
|
|
|
|
strcpy(gCaseCtrl.caseCatalog, "Row Num Test");
|
|
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
|
gCaseCtrl.rowNum = 1000;
|
|
gCaseCtrl.printRes = false;
|
|
runCaseList(taos);
|
|
gCaseCtrl.rowNum = 0;
|
|
gCaseCtrl.printRes = true;
|
|
|
|
strcpy(gCaseCtrl.caseCatalog, "Runtimes Test");
|
|
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
|
gCaseCtrl.runTimes = 2;
|
|
runCaseList(taos);
|
|
gCaseCtrl.runTimes = 0;
|
|
|
|
strcpy(gCaseCtrl.caseCatalog, "Check Param Test");
|
|
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
|
gCaseCtrl.checkParamNum = true;
|
|
runCaseList(taos);
|
|
gCaseCtrl.checkParamNum = false;
|
|
|
|
strcpy(gCaseCtrl.caseCatalog, "Bind Col Num Test");
|
|
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
|
gCaseCtrl.bindColNum = 6;
|
|
runCaseList(taos);
|
|
gCaseCtrl.bindColNum = 0;
|
|
|
|
#endif
|
|
|
|
/*
|
|
strcpy(gCaseCtrl.caseCatalog, "Bind Col Type Test");
|
|
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
|
gCaseCtrl.bindColTypeNum = tListLen(bindColTypeList);
|
|
gCaseCtrl.bindColTypeList = bindColTypeList;
|
|
runCaseList(taos);
|
|
*/
|
|
|
|
printf("All Test End\n");
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
TAOS *taos = NULL;
|
|
|
|
srand((unsigned int)time(NULL));
|
|
|
|
// connect to server
|
|
if (argc < 2) {
|
|
printf("please input server ip \n");
|
|
return 0;
|
|
}
|
|
|
|
taos = taos_connect(argv[1], "root", "taosdata", NULL, 0);
|
|
if (taos == NULL) {
|
|
printf("failed to connect to db, reason:%s\n", taos_errstr(taos));
|
|
exit(1);
|
|
}
|
|
|
|
runAll(taos);
|
|
|
|
taos_close(taos);
|
|
|
|
return 0;
|
|
}
|