Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for prepared statements in JDBC #3116

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ohadzeliger
Copy link
Contributor

@ohadzeliger ohadzeliger commented Feb 6, 2025

This PR enables support for prepared statements on the JDBC server.
Specifically, support for PreparedStatement setObject() and setArray().
Also, JDBCRelationalConnection needed support for array creation.
A slew of type conversion utilities were added in support of these features.
In general, we have 3 models that we are dealing with:

  • Java (including primitives, [], null)
  • JDBC (including primitive, Array, Struct, NULL)
  • Protobuf

And because of the way the API is structured, we may need to perform conversions between all 3. Specifically, we support the following:

  • Java and SQL primitives are treated the same way
  • Java arrays are only supported in Connection.createArrayOf, where the type of array elements is also provided
  • SQL Array and Struct are assumed in all cases of nesting. That is, an array of elements would be assumed to have SQL Array if there is any nested array. The reasoning is that we would need the additional type information in these cases
    Some cleanup and restructuring of that code may be warranted, in addition to null, error and edge case testing.

The protobuf for the Array definition was changed in order to support the extra type information. This causes version incompatibility with the previous version so multi-server tests for arrays needed to be excluded. Another option would have been to replicate the array definition for backwards compatibility but that would have added tech debt to the system.

@ohadzeliger ohadzeliger changed the title Initial implementation of prepared statement support in JDBC Add support for prepared statements in JDBC Feb 6, 2025
@ohadzeliger ohadzeliger marked this pull request as ready for review February 7, 2025 14:11
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.

1 participant