Skip to content

Conversation

@Pengrongkun
Copy link
Contributor

Description

https://project.feishu.cn/taosdata_td/defect/detail/6506118573

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?

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Pengrongkun, 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 addresses a bug in the stmt2 prepared statement mechanism, specifically when it interacts with information_schema.ins_tables queries that utilize placeholders. The core change involves improving the parser's ability to correctly interpret and bind values from placeholders for database and table names, ensuring accurate query execution. The changes are validated by a new dedicated test case.

Highlights

  • Enhanced Placeholder Handling for Information Schema Queries: The parsing utility has been updated to correctly extract and process placeholder values (e.g., ?) when querying information_schema.ins_tables for db_name and table_name columns. This includes proper handling of NCHAR and VARCHAR data types and memory management for conversions.
  • New Test Case for stmt2 Information Schema Queries: A new test case has been added to stmt2Test.cpp to validate the functionality of querying information_schema.ins_tables using prepared statements (stmt2) with bound parameters, ensuring the fix works as expected.
  • Logging Level Adjustments: Several logging statements in clientStmt2.c have been adjusted, primarily changing ILOG_E to DLOG_E and TLOG to DLOG, to refine the verbosity of the client-side statement logging.
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

@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 appears to fix an issue with prepared statement queries, particularly for information_schema tables, by enhancing how placeholder values are handled in the parser. The changes in parUtil.c seem robust and correctly manage different data types and memory for placeholders. The logging levels in clientStmt2.c have been adjusted, which is a reasonable change. However, I've identified a couple of issues in the new test case in stmt2Test.cpp that should be addressed.

Comment on lines +1934 to +1935
// int code = taos_stmt2_prepare(stmt, "select tbname,t2,b from stmt2_testdb_7.stb where ts = ? and tbname = ?", 0);
// checkError(stmt, code);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This commented-out code should be removed to keep the codebase clean and maintainable.

Comment on lines +1987 to +1989
code = taos_stmt2_get_fields(stmt, &fieldNum, &pFields);
checkError(stmt, code);
ASSERT_EQ(fieldNum, 2);
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 assertion ASSERT_EQ(fieldNum, 2) is confusing. The function taos_stmt2_get_fields is expected to return the number of result columns, which is 3 for the query select table_name, db_name, stable_name .... The number of parameters for this query is 2.

If taos_stmt2_get_fields is intended to get the parameter count for SELECT queries, its name is misleading. If it's meant to get result fields, the assertion is incorrect. Please clarify the function's behavior for SELECT statements or correct the test. If you intended to get the number of parameters, a function like taos_stmt2_get_param_num should be used if available.

@guanshengliang guanshengliang merged commit 65156bc into 3.3.6 Dec 10, 2025
11 of 12 checks passed
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.

4 participants