Skip to content

merge: from main to 3.0 branch#34705

Open
guanshengliang wants to merge 25 commits into3.0from
merge/mainto3.0
Open

merge: from main to 3.0 branch#34705
guanshengliang wants to merge 25 commits into3.0from
merge/mainto3.0

Conversation

@guanshengliang
Copy link
Contributor

Description

Issue(s)

  • Close/close/Fix/fix/Resolve/resolve: Issue Link

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

@guanshengliang guanshengliang requested review from a team, dapan1121, hzcheng and zitsen as code owners March 6, 2026 11:17
Copilot AI review requested due to automatic review settings March 6, 2026 11:17
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request merges recent changes from the main branch into the 3.0 branch, focusing on enhancing the build system, expanding documentation, and refining core functionalities. Key areas of improvement include better Windows compatibility for libcurl, comprehensive guides for pSpace data ingestion, and more granular control within the privilege system. Additionally, internal data caching mechanisms have been optimized, and command-line tools have been streamlined. The testing framework also received updates to support these new features and ensure stability.

Highlights

  • CMake Build System Enhancements: Improved libcurl integration for Windows builds, including specific library linking and ExternalProject_Add configuration, ensuring better cross-platform compatibility.
  • Documentation Expansion: Added comprehensive documentation for pSpace data ingestion in both English and Chinese, detailing feature overviews, task creation, connection configurations, data point mapping, and collection modes.
  • Privilege System Refinements: Introduced new LOCK ROLE and UNLOCK ROLE privileges, updated the PRIV_INFO_TABLE_VERSION, and refined column-level privilege checks to enhance security and access control.
  • Data Sink Cache Improvements: Clarified comments and added debug logging for disk-based buffer operations, and refined ownership transfer for ctgEnqueue operations in the catalog cache for better memory management.
  • CLI Tool Updates: Removed the -R (RESTful) option from taos-cli and taosdump documentation and code, streamlining command-line interface options.
  • Test Framework Updates: Minor updates to the test framework README, including Python dependency installation for screen and clarified batch test execution instructions, alongside new test cases for column and topic privileges.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • cmake/external.cmake
    • Added Windows-specific libcurl linking and ExternalProject_Add configuration.
  • docs/en/06-advanced/05-data-in/22-pspace.md
    • Added new documentation for pSpace data ingestion.
  • docs/en/14-reference/02-tools/07-taos-cli.md
    • Removed -R (RESTful) option from taos-cli documentation.
    • Fixed minor formatting issues.
  • docs/en/14-reference/02-tools/09-taosdump.md
    • Removed -R (RESTful) option from taosdump documentation.
  • docs/zh/04-get-started/_03-docker.md
    • Added troubleshooting steps for Docker Hub image pull failures.
    • Fixed minor formatting issues.
  • docs/zh/06-advanced/05-data-in/22-pspace.mdx
    • Added new Chinese documentation for pSpace data ingestion.
  • docs/zh/08-operation/03-install.md
    • Updated version numbers for TDengine TSDB-OSS packages in installation instructions.
  • docs/zh/14-reference/02-tools/07-taos-cli.md
    • Removed -R (RESTful) option from taos-cli documentation.
    • Fixed minor formatting issues.
  • docs/zh/14-reference/02-tools/09-taosdump.md
    • Removed -R (RESTful) option from taosdump documentation.
  • docs/zh/14-reference/05-connector/_linux_install.mdx
    • Updated version numbers for TDengine TSDB-OSS Client in Linux installation instructions.
  • docs/zh/14-reference/05-connector/_macos_install.mdx
    • Updated version numbers for TDengine TSDB-OSS Client in macOS installation instructions.
  • docs/zh/14-reference/05-connector/_windows_install.mdx
    • Updated version numbers for TDengine TSDB-OSS Client in Windows installation instructions.
  • docs/zh/27-train-faq/01-faq.md
    • Added a new FAQ entry regarding Docker Hub image pull failures.
  • include/libs/new-stream/dataSink.h
    • Updated comments for data sink cache mechanisms.
    • Added stdbool.h include.
  • include/libs/nodes/querynodes.h
    • Added appendByPrivCond flag to SColumnNode for privilege checks.
  • include/util/tcurl.h
    • Defined CURL_STATICLIB for Windows.
    • Removed conditional compilation for curl.h include.
  • include/util/tpriv.h
    • Incremented PRIV_INFO_TABLE_VERSION.
    • Added a comment explaining the purpose of PRIV_INFO_TABLE_VERSION.
  • source/client/src/clientHb.c
    • Changed taosArrayDestroy to tFreeSUserAuthBatchRsp for freeing user authentication response.
  • source/common/CMakeLists.txt
    • Linked ext_curl to the common library on Windows.
  • source/common/src/tpriv.c
    • Defined SYS_ADMIN_CORE_ROLES.
    • Updated privilege requirements for PRIV_USER_UNLOCK, PRIV_USER_LOCK, PRIV_ROLE_UNLOCK, and PRIV_ROLE_LOCK.
  • source/dnode/mnode/impl/src/mndConsumer.c
    • Added mndReleaseUser call to ensure proper user resource release.
  • source/dnode/mnode/impl/src/mndDb.c
    • Added keepTimeOffset to the dumped database information.
  • source/dnode/vnode/src/vnd/vnodeSync.c
    • Clarified log messages for vnode sync pre/post close and close operations.
  • source/libs/catalog/src/catalog.c
    • Clarified comment for catalogGetUserAuth regarding shallow copy behavior.
  • source/libs/catalog/src/ctgCache.c
    • Modified ctgEnqueue to accept an enqueued boolean pointer, ensuring proper ownership transfer and memory management for SGetUserAuthRsp.
  • source/libs/new-stream/src/dataSinkCache.c
    • Clarified comment regarding pointer movement during data reading.
  • source/libs/new-stream/src/dataSinkFile.c
    • Clarified comments regarding pointer movement and file block writing.
  • source/libs/new-stream/src/dataSinkMgr.c
    • Fixed a semicolon in initStreamDataSink.
    • Updated comments for initStreamDataCache and destroyStreamDataCache.
  • source/libs/new-stream/src/streamUtil.c
    • Removed conditional compilation for curl.h.
    • Removed Windows-specific streamSendNotifyContent implementation.
  • source/libs/nodes/src/nodesCloneFuncs.c
    • Added flags field to columnNodeCopy for proper cloning.
  • source/libs/nodes/src/nodesUtilFuncs.c
    • Improved column collection logic to handle appendByPrivCond.
    • Refined permission checks for invisible columns.
  • source/libs/parser/inc/sql.y
    • Added UNLOCK ROLE and LOCK ROLE to the SQL grammar.
  • source/libs/parser/src/parAuthenticator.c
    • Set appendByPrivCond flag for rewritten column nodes.
  • source/libs/parser/src/parInsertSql.c
    • Added logic to destroy pPrivCols and pTagCond in setVnodeModifOpStmt.
  • source/libs/parser/src/parTranslater.c
    • Enhanced column permission checks to prevent selection of invisible columns.
    • Updated fillPrivSetRowCols to include tags in column count.
  • source/libs/sync/src/syncMain.c
    • Clarified log messages for sync node close.
    • Added warning for failed ping timer stop.
  • source/util/src/tcurl.c
    • Removed conditional compilation for Windows-specific tcurl functions.
  • source/util/src/tpagedbuf.c
    • Added debug logging for paged buffer file operations (open, close, clear).
    • Improved error handling for file truncation.
  • test/README.md
    • Updated formatting and added Python dependency installation for screen.
    • Clarified notes regarding test execution.
  • test/cases/24-Users/test_user_privilege_sysinfo.py
    • Updated privilege test cases to expect errors for show db.vgroups and show d2.vgroups for sysinfo0 user.
    • Added a specific permission denied check for information_schema.ins_databases columns.
  • test/cases/25-Privileges/test_priv_control.py
    • Modified a privilege test case to expect 0 rows instead of a permission denied error for a row not authorized.
  • test/cases/25-Privileges/test_priv_rbac.py
    • Added new test cases for column-level privileges and topic privileges.
    • Granted lock role, unlock role, lock user, unlock user to a test user.
  • tools/taos-tools/src/taosdump.c
    • Removed the -R (RESTful) option from taosdump options and parsing.
Activity
  • The pull request is a merge from the main branch to the 3.0 branch, consolidating recent development efforts.
  • Changes include updates to the build system, documentation, core privilege management, and data handling.
  • New documentation for pSpace data ingestion has been added in both English and Chinese.
  • The privilege system has been extended with new role locking capabilities and refined column-level access checks.
  • The taos-cli and taosdump tools have been updated by removing the -R (RESTful) option.
  • Test cases have been added and modified to cover new privilege features and ensure system stability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR merges recent changes from main into the 3.0 branch, bringing in updates across privileges/RBAC behavior, catalog caching, Windows/libcurl integration, stream notifications, tests, and documentation.

Changes:

  • Removes deprecated RESTful CLI option for taosdump and updates corresponding docs.
  • Extends privilege/column-visibility handling (parser + privilege tables) and adjusts/expands privilege test coverage (including TMQ topic privilege checks).
  • Adds/extends Windows support for libcurl (build + headers), and includes several stability/cleanup fixes (e.g., paged buffer truncation, consumer user release, batch response free).

Reviewed changes

Copilot reviewed 43 out of 55 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/taos-tools/src/taosdump.c Removes -R/--restful option handling.
test/cases/25-Privileges/test_priv_rbac.py Adds column/topic privilege checks; uses TMQ Consumer.
test/cases/25-Privileges/test_priv_control.py Updates expected behavior for row/column combined privilege case.
test/cases/24-Users/test_user_privilege_sysinfo.py Adjusts sysinfo privilege expectations (vgroups/columns).
test/README.md Improves formatting and adds prerequisites notes.
source/util/src/tpagedbuf.c Adds debug/cleanup logging and truncates paged buffer file on clear.
source/util/src/tcurl.c Removes Windows no-op path; uses curl implementation universally.
source/libs/sync/src/syncMain.c Improves logs and stop-timer warning behavior.
source/libs/parser/src/parTranslater.c Updates invisible-column handling and privilege column checks.
source/libs/parser/src/parInsertSql.c Clears previously stored privilege/tag condition nodes to avoid leaks.
source/libs/parser/src/parAuthenticator.c Marks columns appended by privilege conditions.
source/libs/parser/inc/sql.y Adds LOCK ROLE / UNLOCK ROLE privilege types.
source/libs/nodes/src/nodesUtilFuncs.c Fixes column collection/cloning bookkeeping for later flag updates.
source/libs/nodes/src/nodesCloneFuncs.c Ensures column flags are copied during clone.
source/libs/new-stream/src/streamUtil.c Removes Windows stub for stream notify; enables notify code path.
source/libs/new-stream/src/dataSinkMgr.c Fixes function terminator and translates comments to English.
source/libs/new-stream/src/dataSinkFile.c Translates comments to English.
source/libs/new-stream/src/dataSinkCache.c Translates comments to English.
source/libs/catalog/src/ctgCache.c Changes queue enqueue API and adjusts user-auth enqueue ownership handling.
source/libs/catalog/src/catalog.c Clarifies shallow-copy caveat in catalogGetUserAuth doc.
source/dnode/vnode/src/vnd/vnodeSync.c Improves sync close log messages.
source/dnode/mnode/impl/src/mndDb.c Adds keepTimeOffset field output in db info dump.
source/dnode/mnode/impl/src/mndConsumer.c Releases operator user on show consumer path.
source/common/src/tpriv.c Adds role lock/unlock privs; adjusts required roles for lock/unlock user.
source/common/CMakeLists.txt Adds curl dependency for Windows build of common.
source/client/src/clientHb.c Uses structured free for user-auth batch response.
include/util/tpriv.h Bumps privilege table version to 4.
include/util/tcurl.h Enables CURL_STATICLIB on Windows; includes curl headers unconditionally.
include/libs/nodes/querynodes.h Adds appendByPrivCond bit flag on column nodes.
include/libs/new-stream/dataSink.h Replaces large CN comment block with concise English notes; adds <stdbool.h>.
docs/zh/27-train-faq/01-faq.md Adds Docker Hub pull failure FAQ entry with anchor.
docs/zh/14-reference/05-connector/_windows_install.mdx Updates referenced version to 3.4.0.9.
docs/zh/14-reference/05-connector/_macos_install.mdx Updates referenced version to 3.4.0.9.
docs/zh/14-reference/05-connector/_linux_install.mdx Updates referenced version and tarball name to 3.4.0.9.
docs/zh/14-reference/02-tools/09-taosdump.md Removes RESTful option from taosdump docs.
docs/zh/14-reference/02-tools/07-taos-cli.md Removes RESTful option mention; formatting cleanup.
docs/zh/08-operation/03-install.md Updates referenced versions to 3.4.0.9.
docs/zh/06-advanced/05-data-in/pic/pspace-07.png Adds pSpace documentation asset.
docs/zh/06-advanced/05-data-in/pic/pspace-06.png Adds pSpace documentation asset.
docs/zh/06-advanced/05-data-in/22-pspace.mdx Adds new Chinese pSpace guide page.
docs/zh/04-get-started/_03-docker.md Adds troubleshooting link to Docker Hub pull failure FAQ.
docs/en/assets/pspace-06.png Adds English pSpace documentation asset.
docs/en/assets/pspace-02.png Adds English pSpace documentation asset.
docs/en/14-reference/02-tools/09-taosdump.md Removes RESTful option from taosdump docs.
docs/en/14-reference/02-tools/07-taos-cli.md Removes RESTful option mention; formatting cleanup.
docs/en/06-advanced/05-data-in/22-pspace.md Adds new English pSpace guide page.
cmake/external.cmake Enables building/ext-linking libcurl on Windows (static, websockets, schannel).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1389 to +1398
code = ctgEnqueue(pCtg, op, &enqueued);
// Clear source pointers to transfer ownership after successful enqueue
if (enqueued) {
pAuth->objPrivs = NULL;
pAuth->selectTbs = NULL;
pAuth->insertTbs = NULL;
pAuth->deleteTbs = NULL;
pAuth->tokens = NULL;
pAuth->ownedDbs = NULL;
}
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctgUpdateUserEnqueue mutates pAuth by NULLing pointer fields when the operation is enqueued. This breaks callers that still need pAuth after the call (e.g., ctgGetUserAuth enqueues pRsp and then returns it to catalogGetUserAuth, but the pointer fields will be cleared). Consider enqueuing a deep-copy/moved clone instead (so the queue owns its copy), or only transferring ownership when the caller explicitly indicates it, but avoid modifying output structs that are returned to callers.

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +102
def subscribe_topic(self, user, password, group_id, topic_name):
attr = {
'group.id': group_id,
'td.connect.user': user,
'td.connect.pass': password,
'auto.offset.reset': 'earliest'
}
consumer = Consumer(attr)
consumer.subscribe([topic_name])

Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subscribe_topic creates a TMQ Consumer but never closes it. In the test suite this can leak sockets/threads and cause subsequent cases to hang or flake. Please ensure the consumer is closed (e.g., try/finally around subscribe + an explicit consumer.close()/unsubscribe() as appropriate).

Copilot uses AI. Check for mistakes.
Comment on lines +898 to 926
# URL_HASH MD5=b25588a43556068be05e1624e0e74d41
get_from_local_if_exists("https://github.com/curl/curl/releases/download/curl-8_2_1/curl-8.2.1.tar.gz")
ExternalProject_Add(ext_curl
URL ${_url}
URL_HASH MD5=b25588a43556068be05e1624e0e74d41
PREFIX "${_base}"
CMAKE_ARGS -DCMAKE_BUILD_TYPE:STRING=${TD_CONFIG_NAME}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:STRING=${_ins}
CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR:PATH=lib
CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=OFF
CMAKE_ARGS -DBUILD_TESTING:BOOL=OFF
CMAKE_ARGS -DBUILD_CURL_EXE:BOOL=OFF
CMAKE_ARGS -DENABLE_WEBSOCKETS:BOOL=ON
CMAKE_ARGS -DCURL_USE_SCHANNEL:BOOL=ON
CMAKE_ARGS -DCURL_USE_OPENSSL:BOOL=OFF
CMAKE_ARGS -DCURL_ZLIB:BOOL=OFF
CMAKE_ARGS -DCURL_DISABLE_LDAP:BOOL=ON
CMAKE_ARGS -DCURL_DISABLE_LDAPS:BOOL=ON
BUILD_COMMAND
COMMAND "${CMAKE_COMMAND}" --build . --config "${TD_CONFIG_NAME}"
INSTALL_COMMAND
COMMAND "${CMAKE_COMMAND}" --install . --config "${TD_CONFIG_NAME}" --prefix "${_ins}"
EXCLUDE_FROM_ALL TRUE
VERBATIM
)
else()
string(JOIN " " _c_flags ${_c_flags_list})
# URL https://github.com/curl/curl/releases/download/curl-8_2_1/curl-8.2.1.tar.gz
# URL_HASH MD5=b25588a43556068be05e1624e0e74d41
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ext_curl external dependency is verified using URL_HASH MD5=..., which relies on MD5, a cryptographically broken hash function, for integrity checking of third‑party code. An attacker who can intercept or influence the download channel could craft a curl tarball with a colliding MD5 and have malicious code accepted into your build, potentially leading to execution of attacker‑controlled code in the build environment. Replace MD5 with a modern, collision‑resistant hash (for example a SHA‑256 checksum or stronger signature‑based verification supported by CMake) for the URL_HASH used when fetching ext_curl on all platforms.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request merges significant changes, including enabling libcurl support on Windows, improving code maintainability by translating comments, and enhancing the privilege system with new features like LOCK/UNLOCK ROLE and more refined column-level access control. It also incorporates important memory safety fixes, including addressing several resource leaks. However, a memory leak was identified in the catalog cache enqueue logic where allocated operation objects are not freed upon failure, which needs to be addressed to prevent potential memory exhaustion. Additionally, there are suggestions to further enhance security and documentation quality.

Comment on lines +1389 to +1403
code = ctgEnqueue(pCtg, op, &enqueued);
// Clear source pointers to transfer ownership after successful enqueue
if (enqueued) {
pAuth->objPrivs = NULL;
pAuth->selectTbs = NULL;
pAuth->insertTbs = NULL;
pAuth->deleteTbs = NULL;
pAuth->tokens = NULL;
pAuth->ownedDbs = NULL;
}

_return:

tFreeSGetUserAuthRsp(pAuth);
if (!enqueued) {
tFreeSGetUserAuthRsp(pAuth);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

A memory leak occurs in ctgUpdateUserEnqueue and other enqueue functions when ctgEnqueue fails. The SCtgCacheOperation object op is allocated using taosMemoryCalloc, but it is not freed if ctgEnqueue returns an error (i.e., when enqueued is false). Additionally, the msg object assigned to op->data is also leaked in this scenario. Repeated failures could lead to memory exhaustion and a potential Denial of Service (DoS).

get_from_local_if_exists("https://github.com/curl/curl/releases/download/curl-8_2_1/curl-8.2.1.tar.gz")
ExternalProject_Add(ext_curl
URL ${_url}
URL_HASH MD5=b25588a43556068be05e1624e0e74d41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For security reasons, it is recommended to use a stronger hashing algorithm than MD5 for verifying the downloaded file. ExternalProject_Add supports SHA256, which should be preferred.

The SHA256 hash for curl-8.2.1.tar.gz is 431175130424587834751581b8333535f0535350b6b44b5665805213038a685b.

        URL_HASH SHA256=431175130424587834751581b8333535f0535350b6b44b5665805213038a685b


如果启动 TDengine 服务时出现异常,请查看数据库日志以获取更多信息。你也可以参考 TDengine 的官方文档中的故障排除部分,或者在 TDengine 开源社区中寻求帮助。
1. 如果无法正常从 Docker Hub 拉取镜像,请参考常见问题列表中的相关问题:[如果从 Docker Hub 拉取 TDengine 镜像失败,应该如何解决?](https://docs.taosdata.com/train-faq/faq/#docker-hub-failure)
1. 如果启动 TDengine 服务时出现异常,请查看数据库日志以获取更多信息。你也可以参考 TDengine 的官方文档中的故障排除部分,或者在 TDengine 开源社区中寻求帮助。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The numbered list in the "故障排查" (Troubleshooting) section is not correctly formatted. To ensure both items appear in a single ordered list, the second item should be numbered 2. instead of 1..

Suggested change
1. 如果启动 TDengine 服务时出现异常,请查看数据库日志以获取更多信息。你也可以参考 TDengine 的官方文档中的故障排除部分,或者在 TDengine 开源社区中寻求帮助。
2. 如果启动 TDengine 服务时出现异常,请查看数据库日志以获取更多信息。你也可以参考 TDengine 的官方文档中的故障排除部分,或者在 TDengine 开源社区中寻求帮助。

DuanKuanJun and others added 19 commits March 10, 2026 10:51
Closes: https://project.feishu.cn/taosdata_td/defect/detail/6779768893

* fix: SAST Check invalid rules

* fix: shellArguments.c format indent

* fix: shellArguments.c format indent 2

* fix: shellEngine.c format indent
* fix(taos-tools): fix sast warnings

* fix(taos-tools): add error handling

* fix(taos-tools): fix typo

* fix(taos-tools): optimize judgment condition

* fix(taosdump): fix wrong if condition
@guanshengliang guanshengliang requested a review from feici02 as a code owner March 12, 2026 01:41
Copilot AI review requested due to automatic review settings March 12, 2026 02:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 96 out of 98 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 324 to +327
QUERY_CHECK_NULL(taosArrayPush(pVirtualScanInfo->pSortCtxList, &pCtx), code, lino, _return, terrno)
pCtx = NULL;
VTS_ERR_JRET(tsortAddSource(pVirtualScanInfo->pSortHandle, ps));
ps = NULL;
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the loop, pCtx is set to NULL before tsortAddSource() succeeds. If tsortAddSource() fails, the allocated SLoadNextCtx has already been pushed into pSortCtxList but won't be freed in the _return cleanup (since the local pCtx is NULL), leading to a leak and leaving pSortCtxList out of sync with the sort handle sources. Consider only nulling pCtx after tsortAddSource() succeeds (and/or cleaning up the last pushed ctx on failure, or calling cleanUpVirtualScanInfo() in the error path).

Copilot uses AI. Check for mistakes.
Comment on lines 823 to 843
int pos = 0;
BArray* fields = NULL;
int16_t field_count = 0;
char* binanry_prefix = stb->binaryPrefex ? stb->binaryPrefex : "";
char* nchar_prefix = stb->ncharPrefex ? stb->ncharPrefex : "";

if (!buf || !stb || !k || size <= 0) {
return -1;
}

if (fields_cate == GEN_ROW_FIELDS_TAG) {
fields = stb->tags;
field_count = stb->tags->size;
} else {
fields = stb->cols;
field_count = stb->cols->size;
}

for (uint16_t i = 0; i < field_count; ++i) {
Field* field = benchArrayGet(fields, i);
for (int16_t i = 0; i < field_count; ++i) {
Field* field = benchArrayGet(fields, (size_t)i);
char* prefix = "";
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

field_count is derived from stb->tags->size / stb->cols->size (container sizes), but it's stored as int16_t and used in the loop bound. This can truncate/overflow if the column/tag count exceeds INT16_MAX, causing incorrect iteration or an infinite loop. Use size_t (or at least int32_t) for field_count and the loop index, and avoid casting through signed 16-bit types here.

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +104
# 注册信号处理器
signal.signal(signal.SIGUSR1, self.signalHandler) # 暂停/恢复 alter 线程
signal.signal(signal.SIGUSR2, self.signalHandler) # 停止 alter 线程
signal.signal(signal.SIGINT, self.signalHandler) # Ctrl+C 停止所有
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signal.SIGUSR1/signal.SIGUSR2 are not available on Windows Python, but this test case is registered for Windows (tdCases.addWindows). Registering these handlers unconditionally will raise at runtime on Windows. Guard these registrations with hasattr(signal, "SIGUSR1")/hasattr(signal, "SIGUSR2") (or platform checks), or only register them on Linux.

Copilot uses AI. Check for mistakes.
Comment on lines +256 to +270
# 等待插入线程完成
insertThread.join()
tdLog.info("Insert thread completed")

# 等待消费线程完成
consumeThread1.join()
tdLog.info("Consumer thread g1 completed")
consumeThread2.join()
tdLog.info("Consumer thread g2 completed")

self.consume()
# 停止 alter 线程
tdLog.info("Stopping alter threads...")
self.stopAlter = True
self.pauseAlter.set() # 确保线程不会卡在等待状态

Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run() waits for the consumer threads (consumeThread1/2.join()) before setting self.stopAlter = True. Meanwhile the alter threads continue running and can keep generating new messages, preventing consumer.poll() from timing out and causing the consumer joins to block indefinitely (so the test may never reach the stop/cleanup logic). Consider signaling stopAlter (and/or a separate consumer stop condition) before joining consumers, or add a bounded consume loop/timeout so the test always terminates.

Copilot uses AI. Check for mistakes.
Comment on lines 452 to 456
bool hashMapInsert(HashMap *map, const char *key, void *value) {
// lock map
pthread_mutex_lock(&map->lock);
(void)pthread_mutex_lock(&map->lock);
uint32_t hash = bkdrHash(key) % HASH32_MAP_MAX_BUCKETS;
HashMapEntry *entry = (HashMapEntry *)malloc(sizeof(HashMapEntry));
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pthread_mutex_lock(&map->lock) return value is ignored. If it fails (e.g., EINVAL), the function will continue and mutate shared state without holding the lock. Since this code already treats mutex init failure as fatal, consider also checking the lock return and handling it (e.g., perror + abort or returning false).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.