Skip to content

Conversation

@olavloite
Copy link
Collaborator

Replaces all ExecOptions with actual connection variables, and makes the ExecOptions field a real temporary field that is only used when the application passes in an ExecOptions instance as an argument for a statement.

@olavloite olavloite requested a review from bhatt4982 August 27, 2025 12:07
@olavloite olavloite requested a review from a team as a code owner August 27, 2025 12:07
@olavloite olavloite force-pushed the replace-exec-options-with-connection-variables branch from 0d38114 to e91ab0d Compare August 27, 2025 16:14
Replaces all ExecOptions with actual connection variables, and makes the ExecOptions
field a real temporary field that is only used when the application passes in an
ExecOptions instance as an argument for a statement.
@olavloite olavloite force-pushed the replace-exec-options-with-connection-variables branch from e91ab0d to cf68db7 Compare August 28, 2025 05:27
}
}

func TestGenericConnectionState_GoogleSQL(t *testing.T) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test shows the overall features of transactional connection state for GoogleSQL.

t.Fatal(err)
}
}
func TestGenericConnectionState_PostgreSQL(t *testing.T) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test shows the overall features of transactional connection state for PostgreSQL.

@olavloite olavloite force-pushed the replace-exec-options-with-connection-variables branch from 2f15f3d to 5840e5e Compare August 28, 2025 08:22
@olavloite olavloite force-pushed the replace-exec-options-with-connection-variables branch from 5840e5e to d7b55fc Compare August 28, 2025 08:37
The Spanner database/sql driver now uses a single multiplexed session for all operations.
Setting a value for MinSessions and MaxSessions is therefore no longer necessary for
workloads that have a significantly higher or lower usage than can normally be served
by the default session pool.

One multiplexed session can execute any number of both read-only and read/write
transactions concurrently.

See https://cloud.google.com/spanner/docs/sessions#multiplexed_sessions for more
information on multiplexed sessions.
key = strings.ToLower(name)
} else {
key = name + "." + extension
key = strings.ToLower(extension) + "." + strings.ToLower(name)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This fixes the issue with key/name being in the wrong order in #495

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...

Support CREATE DATABASE and DROP DATABASE statements.
@olavloite olavloite merged commit ea765b1 into delayed-tx-opts Sep 3, 2025
14 checks passed
@olavloite olavloite deleted the replace-exec-options-with-connection-variables branch September 3, 2025 06:03
olavloite added a commit that referenced this pull request Sep 3, 2025
* chore: use a callback to supply tx opts

Use a callback to supply transaction options, so changes to the connection
variables at the start of a transaction (before it has actually been activated)
are also included in the transaction. This is necessary to support SET LOCAL
statements that have an impact on the actual transaction, such as the
following example script:

```
BEGIN TRANSACTION;
SET LOCAL ISOLATION_LEVEL='repeatable_read';
UPDATE my_table SET my_col=1 WHERE id=1;
COMMIT;
```

This change depends on googleapis/google-cloud-go#12779

* fix: update all dependencies (#492)

* fix: update all dependencies

* chore: go mod tidy and update tests

Update tests to match the behavior of using multiplexed sessions by default for
all operations.

---------

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

* feat: use a single multiplexed session for all operations (#500)

The Spanner database/sql driver now uses a single multiplexed session for all operations.
Setting a value for MinSessions and MaxSessions is therefore no longer necessary for
workloads that have a significantly higher or lower usage than can normally be served
by the default session pool.

One multiplexed session can execute any number of both read-only and read/write
transactions concurrently.

See https://cloud.google.com/spanner/docs/sessions#multiplexed_sessions for more
information on multiplexed sessions.

* chore: fix some flaky test cases (#499)

* chore: replace ExecOptions for connection variables (#497)

* chore: replace ExecOptions for connection variables

Replaces all ExecOptions with actual connection variables, and makes the ExecOptions
field a real temporary field that is only used when the application passes in an
ExecOptions instance as an argument for a statement.

* feat: use a single multiplexed session for all operations (#500)

The Spanner database/sql driver now uses a single multiplexed session for all operations.
Setting a value for MinSessions and MaxSessions is therefore no longer necessary for
workloads that have a significantly higher or lower usage than can normally be served
by the default session pool.

One multiplexed session can execute any number of both read-only and read/write
transactions concurrently.

See https://cloud.google.com/spanner/docs/sessions#multiplexed_sessions for more
information on multiplexed sessions.

* chore: fix some flaky test cases (#499)

* feat: create/drop database statements (#502)

Support CREATE DATABASE and DROP DATABASE statements.

---------

Co-authored-by: Mend Renovate <bot@renovateapp.com>
olavloite added a commit that referenced this pull request Sep 3, 2025
* chore: parse SET/SHOW statements with simple parser

Parse SET/SHOW statements using the simple parser. Any connection variable that
is not covered by a regular expression client-side statement, will be picked up
by this simple parser.

In a following step, all regex-based client-side statements will be removed, and
the parsing will happen using the simple parser. This further simplifies and
unifies all client-side statement parsing and handling, and makes all connection
variables transactional.

* chore: fix formatting

* chore: use a callback to supply tx opts (#496)

* chore: use a callback to supply tx opts

Use a callback to supply transaction options, so changes to the connection
variables at the start of a transaction (before it has actually been activated)
are also included in the transaction. This is necessary to support SET LOCAL
statements that have an impact on the actual transaction, such as the
following example script:

```
BEGIN TRANSACTION;
SET LOCAL ISOLATION_LEVEL='repeatable_read';
UPDATE my_table SET my_col=1 WHERE id=1;
COMMIT;
```

This change depends on googleapis/google-cloud-go#12779

* fix: update all dependencies (#492)

* fix: update all dependencies

* chore: go mod tidy and update tests

Update tests to match the behavior of using multiplexed sessions by default for
all operations.

---------

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

* feat: use a single multiplexed session for all operations (#500)

The Spanner database/sql driver now uses a single multiplexed session for all operations.
Setting a value for MinSessions and MaxSessions is therefore no longer necessary for
workloads that have a significantly higher or lower usage than can normally be served
by the default session pool.

One multiplexed session can execute any number of both read-only and read/write
transactions concurrently.

See https://cloud.google.com/spanner/docs/sessions#multiplexed_sessions for more
information on multiplexed sessions.

* chore: fix some flaky test cases (#499)

* chore: replace ExecOptions for connection variables (#497)

* chore: replace ExecOptions for connection variables

Replaces all ExecOptions with actual connection variables, and makes the ExecOptions
field a real temporary field that is only used when the application passes in an
ExecOptions instance as an argument for a statement.

* feat: use a single multiplexed session for all operations (#500)

The Spanner database/sql driver now uses a single multiplexed session for all operations.
Setting a value for MinSessions and MaxSessions is therefore no longer necessary for
workloads that have a significantly higher or lower usage than can normally be served
by the default session pool.

One multiplexed session can execute any number of both read-only and read/write
transactions concurrently.

See https://cloud.google.com/spanner/docs/sessions#multiplexed_sessions for more
information on multiplexed sessions.

* chore: fix some flaky test cases (#499)

* feat: create/drop database statements (#502)

Support CREATE DATABASE and DROP DATABASE statements.

---------

Co-authored-by: Mend Renovate <bot@renovateapp.com>

---------

Co-authored-by: Sanjeev Bhatt <bhatt4982@gmail.com>
Co-authored-by: Mend Renovate <bot@renovateapp.com>
olavloite added a commit that referenced this pull request Sep 3, 2025
* chore: add generic transactional connection state

Adds data structures for generic transactional connection state. These structures
will be used to keep all connection state in one place, making it easier to add
new connection variables.

This also adds support for transactional connection state; Changes that are made
during a transaction are only persisted if the transaction is committed. It also
allows for setting temporary (local) values during a transaction.

This change is the first step in a multi-step process for moving all connection
variables into a generic structure. Following changes will move the other
connection variables into this structure, and will add support for executing
`set local ...` statements.

* chore: move connection variables to connection state

Move individual connection variables to the generic connection state.

* chore: fix formatting

* chore: parse SET/SHOW statements with simple parser (#495)

* chore: parse SET/SHOW statements with simple parser

Parse SET/SHOW statements using the simple parser. Any connection variable that
is not covered by a regular expression client-side statement, will be picked up
by this simple parser.

In a following step, all regex-based client-side statements will be removed, and
the parsing will happen using the simple parser. This further simplifies and
unifies all client-side statement parsing and handling, and makes all connection
variables transactional.

* chore: fix formatting

* chore: use a callback to supply tx opts (#496)

* chore: use a callback to supply tx opts

Use a callback to supply transaction options, so changes to the connection
variables at the start of a transaction (before it has actually been activated)
are also included in the transaction. This is necessary to support SET LOCAL
statements that have an impact on the actual transaction, such as the
following example script:

```
BEGIN TRANSACTION;
SET LOCAL ISOLATION_LEVEL='repeatable_read';
UPDATE my_table SET my_col=1 WHERE id=1;
COMMIT;
```

This change depends on googleapis/google-cloud-go#12779

* fix: update all dependencies (#492)

* fix: update all dependencies

* chore: go mod tidy and update tests

Update tests to match the behavior of using multiplexed sessions by default for
all operations.

---------

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

* feat: use a single multiplexed session for all operations (#500)

The Spanner database/sql driver now uses a single multiplexed session for all operations.
Setting a value for MinSessions and MaxSessions is therefore no longer necessary for
workloads that have a significantly higher or lower usage than can normally be served
by the default session pool.

One multiplexed session can execute any number of both read-only and read/write
transactions concurrently.

See https://cloud.google.com/spanner/docs/sessions#multiplexed_sessions for more
information on multiplexed sessions.

* chore: fix some flaky test cases (#499)

* chore: replace ExecOptions for connection variables (#497)

* chore: replace ExecOptions for connection variables

Replaces all ExecOptions with actual connection variables, and makes the ExecOptions
field a real temporary field that is only used when the application passes in an
ExecOptions instance as an argument for a statement.

* feat: use a single multiplexed session for all operations (#500)

The Spanner database/sql driver now uses a single multiplexed session for all operations.
Setting a value for MinSessions and MaxSessions is therefore no longer necessary for
workloads that have a significantly higher or lower usage than can normally be served
by the default session pool.

One multiplexed session can execute any number of both read-only and read/write
transactions concurrently.

See https://cloud.google.com/spanner/docs/sessions#multiplexed_sessions for more
information on multiplexed sessions.

* chore: fix some flaky test cases (#499)

* feat: create/drop database statements (#502)

Support CREATE DATABASE and DROP DATABASE statements.

---------

Co-authored-by: Mend Renovate <bot@renovateapp.com>

---------

Co-authored-by: Sanjeev Bhatt <bhatt4982@gmail.com>
Co-authored-by: Mend Renovate <bot@renovateapp.com>

---------

Co-authored-by: Sanjeev Bhatt <bhatt4982@gmail.com>
Co-authored-by: Mend Renovate <bot@renovateapp.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.

3 participants