Skip to content

Conversation

olavloite
Copy link
Collaborator

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.

@olavloite olavloite requested a review from a team as a code owner September 19, 2025 12:51
@olavloite olavloite force-pushed the spanner-lib-grpc-server branch 4 times, most recently from a2d112a to 32c6656 Compare September 19, 2025 16:35
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.
@olavloite olavloite force-pushed the spanner-lib-grpc-server branch from 32c6656 to 9229a2d Compare September 20, 2025 10:09
olavloite and others added 5 commits October 7, 2025 19:37
* refactor: add new message handler in ruby wrapper
* 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`.
* fix: update all dependencies

* chore: go mod tidy

---------

Co-authored-by: Knut Olav Løite <koloite@gmail.com>
Copy link
Contributor

@bhatt4982 bhatt4982 left a comment

Choose a reason for hiding this comment

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

LGTM...

tp = os.Args[2]
}
if tp == "unix" {
defer func() { _ = os.Remove(name) }()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should we add signal handler for cleanup

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added

olavloite and others added 5 commits October 16, 2025 12:52
* fix: update dependency net.java.dev.jna:jna to v5.18.0 (#538)

* chore: update all dependencies (#537)

* fix: update all dependencies (#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 (#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 (#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 (#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 (#546)

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* fix: update all dependencies (#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 (#545)

* feat(ruby): add Ruby FFI wrapper for spannerlib

* chore(main): release 1.19.0 (#541)

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>

* chore: store temp TransactionOptions in connection state (#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 (#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 (#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>
@olavloite olavloite force-pushed the spanner-lib-grpc-server branch from 06b55b4 to 24011dd Compare October 16, 2025 11:48
@olavloite olavloite merged commit 1fc04fe into spanner-lib-dotnet-wrapper Oct 16, 2025
25 of 26 checks passed
@olavloite olavloite deleted the spanner-lib-grpc-server branch October 16, 2025 12:10
olavloite added a commit that referenced this pull request Oct 18, 2025
* 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 (#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 (#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 (#530)

* chore: add transaction support for SpannerLib

* chore: add ExecuteBatch to SpannerLib (#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 (#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 (#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 (#553)

* refactor: add new message handler in ruby wrapper

* chore: delay transaction activation until actual use (#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 (#555)

* fix: update all dependencies (#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 (#539)

* fix: update dependency net.java.dev.jna:jna to v5.18.0 (#538)

* chore: update all dependencies (#537)

* fix: update all dependencies (#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 (#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 (#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 (#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 (#546)

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* fix: update all dependencies (#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 (#545)

* feat(ruby): add Ruby FFI wrapper for spannerlib

* chore(main): release 1.19.0 (#541)

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>

* chore: store temp TransactionOptions in connection state (#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 (#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 (#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>
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.

4 participants