Skip to content

Commit 0974937

Browse files
olavloiteaakashanandgrenovate-botrelease-please[bot]pracucci
committed
chore: add .NET wrapper for SpannerLib (googleapis#533)
* chore: add CreatePool and CreateConnection functions for SpannerLib Creates a spannerlib module and adds functions for CreatePool and CreateConnection. * chore: add Java wrapper for SpannerLib Adds a Java wrapper for SpannerLib and some simple tests for this wrapper. * chore: add Execute function for SpannerLib Adds an Execute function for SpannerLib that can be used to execute any type of SQL statement. The return type is always a Rows object. The Rows object is empty for DDL statements, it only contains ResultSetStats for DML statements without a THEN RETURN clause, and it contains actual row data for queries and DML statements with a THEN RETURN clause. The Execute function can also be used to execute client-side SQL statements, like BEGIN, COMMIT, SET, SHOW, etc. * chore: add transaction support for SpannerLib * chore: add ExecuteBatch to SpannerLib Adds an ExecuteBatch function to SpannerLib that supports executing DML or DDL statements as a single batch. The function accepts an ExecuteBatchDml request for both types of batches. The type of batch that is actually being executed is determined based on the statements in the batch. Mixing DML and DDL in the same batch is not supported. Queries are also not supported in batches. * chore: add WriteMutations function for SpannerLib Adds a WriteMutations function for SpannerLib. This function can be used to write mutations to Spanner in two ways: 1. In a transaction: The mutations are buffered in the current read/write transaction. The returned message is empty. 2. Outside a transaction: The mutations are written to Spanner directly in a new read/write transaction. The returned message contains the CommitResponse. * chore: add .NET wrapper for SpannerLib Adds a .NET wrapper and tests for SpannerLib. * chore: add Java wrapper for SpannerLib (googleapis#527) * chore: add Java wrapper for SpannerLib Adds a Java wrapper for SpannerLib and some simple tests for this wrapper. * chore: add Execute function for SpannerLib (googleapis#529) * chore: add Execute function for SpannerLib Adds an Execute function for SpannerLib that can be used to execute any type of SQL statement. The return type is always a Rows object. The Rows object is empty for DDL statements, it only contains ResultSetStats for DML statements without a THEN RETURN clause, and it contains actual row data for queries and DML statements with a THEN RETURN clause. The Execute function can also be used to execute client-side SQL statements, like BEGIN, COMMIT, SET, SHOW, etc. * chore: add transaction support for SpannerLib (googleapis#530) * chore: add transaction support for SpannerLib * chore: add ExecuteBatch to SpannerLib (googleapis#531) * chore: add ExecuteBatch to SpannerLib Adds an ExecuteBatch function to SpannerLib that supports executing DML or DDL statements as a single batch. The function accepts an ExecuteBatchDml request for both types of batches. The type of batch that is actually being executed is determined based on the statements in the batch. Mixing DML and DDL in the same batch is not supported. Queries are also not supported in batches. * chore: add WriteMutations function for SpannerLib (googleapis#532) Adds a WriteMutations function for SpannerLib. This function can be used to write mutations to Spanner in two ways: 1. In a transaction: The mutations are buffered in the current read/write transaction. The returned message is empty. 2. Outside a transaction: The mutations are written to Spanner directly in a new read/write transaction. The returned message contains the CommitResponse. * fix: check for error after calling Next() * chore: return long instead of int * chore: remove TODO * chore: add grpc-server API for SpannerLib (googleapis#534) * chore: add grpc-server API for SpannerLib Adds a gRPC server that exposes the API of SpannerLib. This allows clients to connect to run SpannerLib as a child process and connect to it using gRPC. * refactor(ruby): Introduce MessageHandler and Rows classes (googleapis#553) * refactor: add new message handler in ruby wrapper * chore: delay transaction activation until actual use (googleapis#552) * chore: store temp TransactionOptions in connection state Store temporary TransactionOptions in the connection state as local options. Local options only apply to the current transaction. This simplifies the internal state handling of the driver, as all transaction state should only be read from the connection state, and not also from a temporary variable. This also enables the use of a combination of temporary transaction options and using SQL statements to set further options. The shared library always includes temporary transaction options, as the BeginTransaction function accepts TransactionOptions as an input argument. This meant that using SQL statements to set further transaction options was not supported through the shared library. * chore: delay transaction activation until actual use Delay the actual transaction activation until the first actual usage of the transaction. That is; the first time that a statement is being sent to Spanner. This allows the application to amend the transaction options after calling BeginTx or executing `BEGIN TRANSACTION`. The transaction options can be amended by executing a statement like `SET TRANSACTION READ ONLY`. * chore: update actions/checkout action to v5 (googleapis#555) * fix: update all dependencies (googleapis#551) * fix: update all dependencies * chore: go mod tidy --------- Co-authored-by: Knut Olav Løite <koloite@gmail.com> * chore: add signal handler to remove temp file * chore: add .NET gRPC wrapper (googleapis#539) * fix: update dependency net.java.dev.jna:jna to v5.18.0 (googleapis#538) * chore: update all dependencies (googleapis#537) * fix: update all dependencies (googleapis#536) * fix: update all dependencies * chore: go mod tidy --------- Co-authored-by: Knut Olav Løite <koloite@gmail.com> * chore(main): release 1.18.1 (googleapis#525) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> * fix: update module github.com/googleapis/go-sql-spanner to v1.18.1 (googleapis#540) * chore: add .NET gRPC wrapper Adds a gRPC wrapper for .NET. This wrapper uses the gRPC API to connect to SpannerLib. The gRPC channel uses a Unix domain socket. * fix: update dependency net.java.dev.jna:jna to v5.18.1 (googleapis#544) This PR contains the following updates: | Package | Change | Age | Confidence | |---|---|---|---| | [net.java.dev.jna:jna](https://redirect.github.com/java-native-access/jna) | `5.18.0` -> `5.18.1` | [![age](https://developer.mend.io/api/mc/badges/age/maven/net.java.dev.jna:jna/5.18.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/net.java.dev.jna:jna/5.18.0/5.18.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>java-native-access/jna (net.java.dev.jna:jna)</summary> ### [`v5.18.1`](https://redirect.github.com/java-native-access/jna/blob/HEAD/CHANGES.md#Release-5181) [Compare Source](https://redirect.github.com/java-native-access/jna/compare/5.18.0...5.18.1) \============== ## Bug Fixes - [#&#8203;1686](https://redirect.github.com/java-native-access/jna/issues/1686): Fix `sortFields` race condition while getting fields - [@&#8203;bendk](https://redirect.github.com/bendk). </details> --- ### Configuration 📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/googleapis/go-sql-spanner). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xMzEuOSIsInVwZGF0ZWRJblZlciI6IjQxLjEzMS45IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> * feat: add authority param support to DSN (googleapis#546) Signed-off-by: Marco Pracucci <marco@pracucci.com> * fix: update all dependencies (googleapis#542) * fix: update all dependencies * chore: go mod tidy * build: add ByteBuddy for Java wrapper --------- Co-authored-by: Knut Olav Løite <koloite@gmail.com> * feat(ruby): Add Ruby FFI wrapper for spannerlib (googleapis#545) * feat(ruby): add Ruby FFI wrapper for spannerlib * chore(main): release 1.19.0 (googleapis#541) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> * chore: store temp TransactionOptions in connection state (googleapis#548) Store temporary TransactionOptions in the connection state as local options. Local options only apply to the current transaction. This simplifies the internal state handling of the driver, as all transaction state should only be read from the connection state, and not also from a temporary variable. This also enables the use of a combination of temporary transaction options and using SQL statements to set further options. The shared library always includes temporary transaction options, as the BeginTransaction function accepts TransactionOptions as an input argument. This meant that using SQL statements to set further transaction options was not supported through the shared library. * feat: parse SET TRANSACTION statements (googleapis#549) * feat: parse SET TRANSACTION statements Parse SET TRANSACTION statements and translate these to SET LOCAL statements. SET TRANSACTION may only be executed in a transaction block, and can only be used for a specific, limited set of connection properties. The syntax is specified by the SQL standard and PostgreSQL. See also https://www.postgresql.org/docs/current/sql-set-transaction.html This change only adds partial support. The following features will be added in future changes: 1. SET TRANSACTION READ {WRITE | ONLY} is not picked up by the driver, as the type of transaction is set directly when BeginTx is called. A refactor of this transaction handling is needed to be able to pick up SET TRANSACTION READ ONLY / SET TRANSACTION READ WRITE statements that are executed after BeginTx has been called. 2. PostgreSQL allows multiple transaction modes to be set in a single SET TRANSACTION statement. E.g. the following is allowed: SET TRANSACTION READ WRITE, ISOLATION LEVEL SERIALIZABLE The current implementation only supports one transaction mode per SET statement. * feat: support multiple transaction options in one statement * feat: support transaction options in BEGIN statements (googleapis#550) * feat: parse SET TRANSACTION statements Parse SET TRANSACTION statements and translate these to SET LOCAL statements. SET TRANSACTION may only be executed in a transaction block, and can only be used for a specific, limited set of connection properties. The syntax is specified by the SQL standard and PostgreSQL. See also https://www.postgresql.org/docs/current/sql-set-transaction.html This change only adds partial support. The following features will be added in future changes: 1. SET TRANSACTION READ {WRITE | ONLY} is not picked up by the driver, as the type of transaction is set directly when BeginTx is called. A refactor of this transaction handling is needed to be able to pick up SET TRANSACTION READ ONLY / SET TRANSACTION READ WRITE statements that are executed after BeginTx has been called. 2. PostgreSQL allows multiple transaction modes to be set in a single SET TRANSACTION statement. E.g. the following is allowed: SET TRANSACTION READ WRITE, ISOLATION LEVEL SERIALIZABLE The current implementation only supports one transaction mode per SET statement. * feat: support multiple transaction options in one statement * feat: support transaction options in BEGIN statements Adds support for including transaction options in BEGIN statements, like: ```sql BEGIN READ ONLY; BEGIN READ WRITE; BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ; BEGIN READ WRITE, ISOLATION LEVEL SERIALIZABLE; ``` * chore: re-trigger checks * chore: add timeout for server startup --------- Signed-off-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: Mend Renovate <bot@renovateapp.com> Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: aakashanandg <aakashanand@google.com> * chore: return long instead of int * chore: remove TODO --------- Signed-off-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: aakashanandg <aakashanand@google.com> Co-authored-by: Mend Renovate <bot@renovateapp.com> Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Marco Pracucci <marco@pracucci.com> --------- Signed-off-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: aakashanandg <aakashanand@google.com> Co-authored-by: Mend Renovate <bot@renovateapp.com> Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Marco Pracucci <marco@pracucci.com>
1 parent b21c1df commit 0974937

File tree

120 files changed

+28320
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+28320
-170
lines changed

.github/workflows/spanner-lib-tests.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,27 @@ jobs:
4848
- name: Build shared library
4949
working-directory: spannerlib/shared
5050
run: go build -o spannerlib.so -buildmode=c-shared shared_lib.go
51+
- name: Build gRPC server
52+
working-directory: spannerlib/grpc-server
53+
run: |
54+
go build -o grpc_server server.go
55+
chmod +x grpc_server
5156
- name: Copy to Java wrapper
5257
working-directory: spannerlib
5358
run: |
5459
echo "$RUNNER_OS"
5560
if [ "$RUNNER_OS" == "Windows" ]; then
5661
mkdir -p wrappers/spannerlib-java/src/main/resources/win32-x86-64
5762
cp shared/spannerlib.so wrappers/spannerlib-java/src/main/resources/win32-x86-64/spanner.dll
63+
cp grpc-server/grpc_server wrappers/spannerlib-java/src/main/resources/win32-x86-64/grpc_server
5864
elif [ "$RUNNER_OS" == "macOS" ]; then
5965
mkdir -p wrappers/spannerlib-java/src/main/resources/darwin-aarch64
6066
cp shared/spannerlib.so wrappers/spannerlib-java/src/main/resources/darwin-aarch64/libspanner.dylib
67+
cp grpc-server/grpc_server wrappers/spannerlib-java/src/main/resources/darwin-aarch64/grpc_server
6168
else
6269
mkdir -p wrappers/spannerlib-java/src/main/resources/linux-x86-64
6370
cp shared/spannerlib.so wrappers/spannerlib-java/src/main/resources/linux-x86-64/libspanner.so
71+
cp grpc-server/grpc_server wrappers/spannerlib-java/src/main/resources/linux-x86-64/grpc_server
6472
fi
6573
shell: bash
6674
- name: ls spannerlib.so
@@ -71,3 +79,90 @@ jobs:
7179
run: mvn -Djna.debug_load=true test
7280
working-directory: spannerlib/wrappers/spannerlib-java
7381
shell: bash
82+
83+
dotnet-wrapper:
84+
strategy:
85+
matrix:
86+
go-version: [1.25.x]
87+
os: [ubuntu-latest, macos-latest, windows-latest]
88+
runs-on: ${{ matrix.os }}
89+
steps:
90+
- name: Install dotnet
91+
uses: actions/setup-dotnet@v4
92+
with:
93+
dotnet-version: '9.0.x'
94+
- name: Install Go
95+
uses: actions/setup-go@v5
96+
with:
97+
go-version: ${{ matrix.go-version }}
98+
- name: Checkout code
99+
uses: actions/checkout@v4
100+
with:
101+
submodules: 'true'
102+
- name: Build shared library
103+
working-directory: spannerlib/shared
104+
run: go build -o spannerlib.so -buildmode=c-shared shared_lib.go
105+
- name: Copy to .NET wrapper
106+
working-directory: spannerlib
107+
run: |
108+
mkdir -p wrappers/spannerlib-dotnet/spannerlib-dotnet-native/libraries/any
109+
if [ "$RUNNER_OS" == "Windows" ]; then
110+
cp shared/spannerlib.so wrappers/spannerlib-dotnet/spannerlib-dotnet-native/libraries/any/spannerlib.dll
111+
else
112+
cp shared/spannerlib.so wrappers/spannerlib-dotnet/spannerlib-dotnet-native/libraries/any/spannerlib
113+
fi
114+
shell: bash
115+
- name: Build .NET native library package
116+
run: dotnet pack
117+
working-directory: spannerlib/wrappers/spannerlib-dotnet/spannerlib-dotnet-native
118+
shell: bash
119+
- name: Add .NET package source
120+
run: |
121+
if [ "$RUNNER_OS" == "Windows" ]; then
122+
echo ${GITHUB_WORKSPACE}"\spannerlib\wrappers\spannerlib-dotnet\spannerlib-dotnet-native\bin\Release"
123+
dotnet nuget add source ${GITHUB_WORKSPACE}"\spannerlib\wrappers\spannerlib-dotnet\spannerlib-dotnet-native\bin\Release" --name local
124+
else
125+
dotnet nuget add source "$PWD"/bin/Release --name local
126+
fi
127+
working-directory: spannerlib/wrappers/spannerlib-dotnet/spannerlib-dotnet-native
128+
shell: bash
129+
- name: Build gRPC server
130+
working-directory: spannerlib/grpc-server
131+
run: |
132+
go build -o grpc_server server.go
133+
chmod +x grpc_server
134+
- name: Copy gRPC server to .NET wrapper
135+
working-directory: spannerlib
136+
run: |
137+
mkdir -p wrappers/spannerlib-dotnet/spannerlib-dotnet-grpc-server/binaries/any
138+
if [ "$RUNNER_OS" == "Windows" ]; then
139+
cp grpc-server/grpc_server wrappers/spannerlib-dotnet/spannerlib-dotnet-grpc-server/binaries/any/grpc_server.exe
140+
else
141+
cp grpc-server/grpc_server wrappers/spannerlib-dotnet/spannerlib-dotnet-grpc-server/binaries/any/grpc_server
142+
fi
143+
shell: bash
144+
- name: Build .NET gRPC server package
145+
run: dotnet pack
146+
working-directory: spannerlib/wrappers/spannerlib-dotnet/spannerlib-dotnet-grpc-server
147+
shell: bash
148+
- name: Add .NET package source
149+
run: |
150+
if [ "$RUNNER_OS" == "Windows" ]; then
151+
dotnet nuget add source ${GITHUB_WORKSPACE}"\spannerlib\wrappers\spannerlib-dotnet\spannerlib-dotnet-grpc-server\bin\Release" --name local-grpc-server
152+
else
153+
dotnet nuget add source "$PWD"/bin/Release --name local-grpc-server
154+
fi
155+
working-directory: spannerlib/wrappers/spannerlib-dotnet/spannerlib-dotnet-grpc-server
156+
shell: bash
157+
- name: Restore dependencies
158+
run: dotnet restore
159+
working-directory: spannerlib/wrappers/spannerlib-dotnet
160+
shell: bash
161+
- name: Build
162+
run: dotnet build --no-restore
163+
working-directory: spannerlib/wrappers/spannerlib-dotnet
164+
shell: bash
165+
- name: .NET Unit Tests
166+
working-directory: spannerlib/wrappers/spannerlib-dotnet/spannerlib-dotnet-tests
167+
run: dotnet test --no-build --verbosity normal
168+
shell: bash

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "spannerlib/grpc-server/googleapis"]
2+
path = spannerlib/grpc-server/googleapis
3+
url = git@github.com:googleapis/googleapis.git

spannerlib/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ require (
1010
cloud.google.com/go/longrunning v0.6.7
1111
cloud.google.com/go/spanner v1.86.0
1212
github.com/google/go-cmp v0.7.0
13+
github.com/google/uuid v1.6.0
1314
github.com/googleapis/go-sql-spanner v1.19.0
15+
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c
1416
google.golang.org/grpc v1.76.0
1517
google.golang.org/protobuf v1.36.10
1618
)
@@ -36,7 +38,6 @@ require (
3638
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
3739
github.com/golang/protobuf v1.5.4 // indirect
3840
github.com/google/s2a-go v0.1.9 // indirect
39-
github.com/google/uuid v1.6.0 // indirect
4041
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
4142
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
4243
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
@@ -62,6 +63,5 @@ require (
6263
golang.org/x/time v0.13.0 // indirect
6364
google.golang.org/api v0.252.0 // indirect
6465
google.golang.org/genproto v0.0.0-20250804133106-a7a43d27e69b // indirect
65-
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c // indirect
6666
google.golang.org/genproto/googleapis/rpc v0.0.0-20251007200510-49b9836ed3ff // indirect
6767
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
go build -o grpc_server server.go
2+
chmod +x grpc_server
3+
cp grpc_server ../wrappers/spannerlib-dotnet/spannerlib-dotnet-grpc/binaries/any/grpc_server
4+
cp grpc_server ../wrappers/spannerlib-dotnet/spannerlib-dotnet-grpc/binaries/osx-arm64/grpc_server
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
go build -o grpc_server server.go
2+
chmod +x grpc_server
3+
mkdir -p ../wrappers/spannerlib-java/src/main/resources/darwin-aarch64
4+
cp grpc_server ../wrappers/spannerlib-java/src/main/resources/darwin-aarch64/grpc_server
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
PATH="${PATH}:${HOME}/go/bin"
2+
ln -sf "${PWD}"/google/spannerlib googleapis/google/spannerlib
3+
cd googleapis || exit 1
4+
protoc \
5+
--go_out=../ \
6+
--go_opt=paths=source_relative \
7+
--go-grpc_out=../ \
8+
--go-grpc_opt=paths=source_relative \
9+
google/spannerlib/v1/spannerlib.proto
10+
protoc \
11+
--java_out=../../wrappers/spannerlib-java/src/main/java/ \
12+
--plugin=protoc-gen-java-grpc=/Users/loite/protoc-gen-grpc-java-1.75.0-osx-aarch_64.exe \
13+
--java-grpc_out=../../wrappers/spannerlib-java/src/main/java/ \
14+
--java-grpc_opt=paths=source_relative \
15+
google/spannerlib/v1/spannerlib.proto
16+
protoc \
17+
--csharp_out=../../wrappers/spannerlib-dotnet/spannerlib-dotnet-grpc-v1/ \
18+
--plugin=protoc-gen-csharp_grpc=/Users/loite/.nuget/packages/grpc.tools/2.72.0/tools/macosx_x64/grpc_csharp_plugin \
19+
--csharp_grpc_out=../../wrappers/spannerlib-dotnet/spannerlib-dotnet-grpc-v1/ \
20+
--csharp_opt=file_extension=.g.cs \
21+
--csharp_grpc_opt=no_server \
22+
--proto_path=. \
23+
google/spannerlib/v1/spannerlib.proto
24+
cd .. || exit 1
25+
rm googleapis/google/spannerlib
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/loite/GolandProjects/go-sql-spanner/spannerlib/grpc-server/google/spannerlib

0 commit comments

Comments
 (0)