Skip to content

fix(oracle): remove trailing semicolons from prebuilt tools and clean…#3215

Open
Deeven-Seru wants to merge 1 commit into
googleapis:mainfrom
Deeven-Seru:fix-3181-oracle-prebuilt
Open

fix(oracle): remove trailing semicolons from prebuilt tools and clean…#3215
Deeven-Seru wants to merge 1 commit into
googleapis:mainfrom
Deeven-Seru:fix-3181-oracle-prebuilt

Conversation

@Deeven-Seru
Copy link
Copy Markdown
Contributor

Fixes #3181

Summary

Oracle prebuilt tools defined in internal/prebuiltconfigs/tools/oracledb.yaml were failing with:

ORA-00933: SQL command not properly ended

when invoked via the oracle-sql tool type.

Root cause: the prebuilt SQL statements in the YAML included trailing semicolons. When passed as full SQL
strings through the driver, those semicolons cause Oracle to reject the statement as not properly ended.

This PR removes the trailing semicolons from the prebuilt SQL and cleans up a leftover debug print in the
oracle-sql tool implementation.

@Deeven-Seru Deeven-Seru requested a review from a team as a code owner May 12, 2026 09:27
Copy link
Copy Markdown
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 removes trailing semicolons from SQL statements in the Oracle prebuilt configurations and deletes debug print statements from the Oracle SQL tool. The review feedback highlights discrepancies between the tool descriptions and their SQL implementations in oracledb.yaml, specifically noting missing columns and hardcoded parameters. Furthermore, a suggestion was made to implement structured logging in oraclesql.go instead of simply removing the debug output to preserve visibility for troubleshooting.

Comment thread internal/prebuiltconfigs/tools/oracledb.yaml Outdated
Comment thread internal/prebuiltconfigs/tools/oracledb.yaml Outdated
Comment thread internal/tools/oracle/oraclesql/oraclesql.go
@Deeven-Seru Deeven-Seru force-pushed the fix-3181-oracle-prebuilt branch from 08d6bf0 to 2809af2 Compare May 12, 2026 10:23
@Deeven-Seru
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
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 enhances the Oracle database tools by adding filtering and dynamic sorting capabilities to prebuilt SQL queries, such as table listing and top SQL analysis. It also replaces standard output debugging with structured logging in the Go implementation. Feedback focuses on correcting documentation discrepancies regarding query scope, improving the robustness of SQL string filtering to handle case and whitespace, and enriching log messages with specific tool names and parameters for better observability.

parameters:
- name: table_names_csv
type: string
description: "Optional: A comma-separated list of table names. If empty, details for all tables in user-accessible schemas will be listed."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The parameter description for table_names_csv states that it lists tables in "user-accessible schemas", which typically refers to the ALL_TABLES view. However, the query on line 41 uses USER_TABLES, which is restricted to the current user's schema. This discrepancy should be resolved by correcting the description to reflect that it only lists tables in the current schema, matching the tool's overall description.

t.last_analyzed
FROM user_tables t
LEFT JOIN user_segments s ON t.table_name = s.segment_name AND s.segment_type IN ('TABLE', 'TABLE PARTITION', 'TABLE SUBPARTITION')
WHERE (:1 IS NULL OR INSTR(',' || :1 || ',', ',' || t.table_name || ',') > 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The INSTR logic for filtering by a comma-separated list is sensitive to spaces and case. If a user provides TABLE1, TABLE2, the match for TABLE2 will fail due to the leading space in the parameter string. Additionally, Oracle table names are usually uppercase. It is recommended to make the filter more robust by stripping spaces and converting to uppercase for comparison.

  WHERE (:1 IS NULL OR INSTR(',' || UPPER(REPLACE(:1, ' ', '')) || ',', ',' || UPPER(t.table_name) || ',') > 0)

return nil, util.NewClientServerError("error getting logger", http.StatusInternalServerError, err)
}
fmt.Printf("\n")
logger.DebugContext(ctx, "executing %s tool query: %s", resourceType, newStatement)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Logging the resourceType ("oracle-sql") is helpful, but logging the specific tool name (t.Name) would provide much better context when multiple Oracle tools are being used. Also, including the parameter values in the debug log would greatly assist in troubleshooting query execution issues.

Suggested change
logger.DebugContext(ctx, "executing %s tool query: %s", resourceType, newStatement)
logger.DebugContext(ctx, "executing tool %q (%s) query: %s with params: %v", t.Name, resourceType, newStatement, sliceParams)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

all prebuilt tools for oracle mcp except execute_sql throws error "ORA-00933: SQL command not properly ended"

2 participants