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

feat: support DATABASE statements #1143

Closed
wants to merge 5 commits into from
Closed

Conversation

olavloite
Copy link
Collaborator

Adds support for the following DATABASE statements in the Connection API:

  • CREATE DATABASE <database_id>: Creates a database (passes the statement through to the CreateDatabase RPC)
  • ALTER DATABASE <database_id>: Alters an existing database (passes the statement through to the UpdateDatabaseDdl RPC)
  • DROP DATABASE <database_id>: Drops an existing database (parsed and translated into a call to the DropDatabase RPC)
  • SHOW VARIABLE DATABASES: Lists the databases on the current instance (parsed and translated into a call to the ListDatabases RPC)
  • USE DATABASE <database_id>: Changes the database that is used by the connection to execute queries, updates, etc.

Also adds support for creating a Connection that is not connected to a specific database, but only to a Spanner instance. This can be used to connect to an empty instance, then create a database on the instance, and then call USE DATABASE <database_id> to use the database with the connection.

This feature allows users to execute scripts like this directly through the Connection API (and thereby also through JDBC):

CREATE DATABASE db;
ALTER DATABASE db SET OPTIONS (optimizer_version = 1);
USE DATABASE db;

CREATE TABLE Singers (...);
INSERT INTO Singers (...);
SELECT * FROM Singers;

DROP DATABASE db;

Needed for googleapis/java-spanner-jdbc#457

Adds support for the following DATABASE statements in the Connection API:
- CREATE DATABASE <database_id>
- ALTER DATABASE <database_id>
- DROP DATABASE <database_id>
- USE DATABASE <database_id>

Needed for googleapis/java-spanner-jdbc#457
@olavloite olavloite requested review from a team as code owners May 7, 2021 08:31
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/java-spanner API. label May 7, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label May 7, 2021
@codecov
Copy link

codecov bot commented May 7, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@3c55eb3). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 98aabd2 differs from pull request most recent head 1df208e. Consider uploading reports for the commit 1df208e to get more accurate results

@@           Coverage Diff           @@
##             main    #1143   +/-   ##
=======================================
  Coverage        ?   84.92%           
  Complexity      ?     2797           
=======================================
  Files           ?      156           
  Lines           ?    14430           
  Branches        ?     1392           
=======================================
  Hits            ?    12255           
  Misses          ?     1598           
  Partials        ?      577           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c55eb3...1df208e. Read the comment docs.

@thiagotnunes thiagotnunes added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label May 17, 2021
Copy link
Contributor

@thiagotnunes thiagotnunes left a comment

Choose a reason for hiding this comment

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

I started an internal discussion in regards to the syntax of the following statements:

  • SHOW VARIABLE DATABASES
  • USE DATABASE <database id>

I will let you know once we have a response here, sorry for the delay.

@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Apr 21, 2022
@arpan14 arpan14 closed this Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. cla: yes This human has signed the Contributor License Agreement. do not merge Indicates a pull request not ready for merge, due to either quality or timing. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants