-
Notifications
You must be signed in to change notification settings - Fork 110
Add support for prepared statements in JDBC #3116
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
Merged
ohadzeliger
merged 14 commits into
FoundationDB:main
from
ohadzeliger:jdbc-prep-statement
Feb 13, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f33aff0
Initial implementation of prepared statement support in JDBC
ohadzeliger bc29a03
Add supported_version and support for nested arrays.
ohadzeliger 4f2532a
Merge branch 'refs/heads/main' into jdbc-prep-statement
ohadzeliger cec42ee
merge from Main, enable test for JDBC
ohadzeliger 9d6d634
Optimize array creation to reuse the existing columns, protect agains…
ohadzeliger 2f2182a
Delete modified file
ohadzeliger f14fe3e
REmove Todo
ohadzeliger 36e3ac6
Fix test with nested arrays
ohadzeliger e478fcf
Exclude more tests with nested arrays
ohadzeliger ea84095
PR Comments
ohadzeliger bcea9d6
Merge branch 'main' into jdbc-prep-statement
ohadzeliger 3cacdfa
PR Comments: Make protobuf changes backwards compatible, add checks w…
ohadzeliger 231affc
Remove exclusion on prepared.yamsql
ohadzeliger dd32218
PR comments
ohadzeliger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
fdb-relational-jdbc/src/main/java/com/apple/foundationdb/relational/jdbc/JDBCArrayImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* JDBCArrayImpl.java | ||
* | ||
* This source file is part of the FoundationDB open source project | ||
* | ||
* Copyright 2015-2025 Apple Inc. and the FoundationDB project authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.apple.foundationdb.relational.jdbc; | ||
|
||
import com.apple.foundationdb.relational.api.SqlTypeNamesSupport; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.sql.Array; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.SQLFeatureNotSupportedException; | ||
import java.util.Map; | ||
|
||
/** | ||
* A simplistic implementation of a {@link Array} that wraps around a | ||
* {@link com.apple.foundationdb.relational.jdbc.grpc.v1.column.Array}. | ||
* TODO: We can't use the other implementation of array in {@link RelationalArrayFacade} as it makes several assumptions | ||
* that would be incompatible with the need to transfer an array across the wire (e.g. the type of element is missing, | ||
* {@link RelationalArrayFacade#getArray()} returns a type other than a Java array). | ||
ScottDugas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
public class JDBCArrayImpl implements Array { | ||
@Nonnull | ||
private final com.apple.foundationdb.relational.jdbc.grpc.v1.column.Array underlying; | ||
|
||
public JDBCArrayImpl(@Nonnull final com.apple.foundationdb.relational.jdbc.grpc.v1.column.Array underlying) { | ||
this.underlying = underlying; | ||
} | ||
|
||
@Override | ||
public String getBaseTypeName() throws SQLException { | ||
return SqlTypeNamesSupport.getSqlTypeName(getBaseType()); | ||
} | ||
|
||
@Override | ||
public int getBaseType() throws SQLException { | ||
return underlying.getElementType(); | ||
} | ||
|
||
@Override | ||
public Object getArray() throws SQLException { | ||
return TypeConversion.fromArray(underlying); | ||
} | ||
|
||
@Override | ||
public Object getArray(final Map<String, Class<?>> map) throws SQLException { | ||
throw new SQLFeatureNotSupportedException("Custom type mapping is not supported"); | ||
} | ||
|
||
@Override | ||
public Object getArray(final long index, final int count) throws SQLException { | ||
throw new SQLFeatureNotSupportedException("Array slicing is not supported"); | ||
} | ||
|
||
@Override | ||
public Object getArray(final long index, final int count, final Map<String, Class<?>> map) throws SQLException { | ||
throw new SQLFeatureNotSupportedException("Custom type mapping is not supported"); | ||
} | ||
|
||
@Override | ||
public ResultSet getResultSet() throws SQLException { | ||
throw new SQLFeatureNotSupportedException("Array as result set is not supported"); | ||
} | ||
|
||
@Override | ||
public ResultSet getResultSet(final Map<String, Class<?>> map) throws SQLException { | ||
throw new SQLFeatureNotSupportedException("Array as result set is not supported"); | ||
} | ||
|
||
@Override | ||
public ResultSet getResultSet(final long index, final int count) throws SQLException { | ||
throw new SQLFeatureNotSupportedException("Array as result set is not supported"); | ||
} | ||
|
||
@Override | ||
public ResultSet getResultSet(final long index, final int count, final Map<String, Class<?>> map) throws SQLException { | ||
throw new SQLFeatureNotSupportedException("Array as result set is not supported"); | ||
} | ||
|
||
@Override | ||
public void free() throws SQLException { | ||
} | ||
|
||
/** | ||
* Package protected getter. | ||
ScottDugas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @return the underlying protobuf struct | ||
*/ | ||
@Nonnull | ||
com.apple.foundationdb.relational.jdbc.grpc.v1.column.Array getUnderlying() { | ||
return underlying; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.