Skip to content

support stored system procedures#171

Merged
yfuruyama merged 1 commit intocloudspannerecosystem:masterfrom
nktks:add-call
Jul 4, 2024
Merged

support stored system procedures#171
yfuruyama merged 1 commit intocloudspannerecosystem:masterfrom
nktks:add-call

Conversation

@nktks
Copy link
Copy Markdown
Contributor

@nktks nktks commented Jul 4, 2024

From this release 1, Stored system procedures is supported.

As I tested at cloud console 2, it runs as query.
So I changed statement.go to parse CALL to SelectStatement and it works.
Let me know if we need to parse CALL statement to another struct.

Test Result (Click me)
  • run heavy query
spanner> SELECT * FROM Users AS a CROSS JOIN Users AS b;
  • select query_id and run stored system procedures
spanner> SELECT * FROM spanner_sys.oldest_active_queries;
+-----------------------------+----------------------+-------------------------------------------------+----------------+----------------------------------------------------------------+---------------------+
| START_TIME                  | TEXT_FINGERPRINT     | TEXT                                            | TEXT_TRUNCATED | SESSION_ID                                                     | QUERY_ID            |
+-----------------------------+----------------------+-------------------------------------------------+----------------+----------------------------------------------------------------+---------------------+
| 2024-07-04T02:56:49.130403Z | -2292417946475336118 | SELECT * FROM Users AS a CROSS JOIN Users AS b  | false          | AJ4XPT3hwhcYscZWWnmr-bL5ZhBHztPGqTytWk7dXF29MfFcCTHdk7c5G6LAfQ | 3962375048429130423 |
| 2024-07-04T02:56:49.803515Z | 2871458697993773986  | SELECT * FROM spanner_sys.oldest_active_queries | false          | AJ4XPT2FaN-3h6jc8Xo4knSl4ak8PRrVcbK3SUe5mf_M3kRM--w_PjKh4BLiAg | 951441015441622781  |
+-----------------------------+----------------------+-------------------------------------------------+----------------+----------------------------------------------------------------+---------------------+
2 rows in set (11.44 msecs)
timestamp:            2024-07-04T11:56:49.803681+09:00
cpu time:             0.61 msecs
rows scanned:         0 rows
deleted rows scanned: 0 rows
optimizer version:    6
optimizer statistics: auto_20240703_12_32_08UTC

spanner> CALL cancel_query("3962375048429130423");
Empty set (19.1 msecs)
timestamp:            2024-07-04T11:56:56.343631+09:00
cpu time:             1.81 msecs
rows scanned:         0 rows
deleted rows scanned: 0 rows
optimizer version:    6
optimizer statistics: auto_20240703_12_32_08UTC

spanner>
  • query is canceled
spanner> SELECT * FROM Users AS a CROSS JOIN Users AS b;
ERROR: spanner: code = "Canceled", desc = "The operation was cancelled."
spanner>
  • explain
spanner> EXPLAIN CALL cancel_query("3962375048429130423");
+----+----------------------+
| ID | Query_Execution_Plan |
+----+----------------------+
|  0 | Serialize Result     |
|  1 | +- TVF               |
|  2 |    +- Unit Relation  |
+----+----------------------+
1 rows in set (0.10 sec)

spanner> EXPLAIN ANALYZE CALL cancel_query("3962375048429130423");
+----+----------------------+---------------+------------+---------------+
| ID | Query_Execution_Plan | Rows_Returned | Executions | Total_Latency |
+----+----------------------+---------------+------------+---------------+
|  0 | Serialize Result     | 0             | 1          | 1.01 secs     |
|  1 | +- TVF               | 0             | 1          | 1.01 secs     |
|  2 |    +- Unit Relation  |               |            |               |
+----+----------------------+---------------+------------+---------------+
Empty set (1.01 secs)
timestamp:            2024-07-04T11:58:09.291468+09:00
cpu time:             1.28 msecs
rows scanned:         0 rows
deleted rows scanned: 0 rows
optimizer version:    6
optimizer statistics: auto_20240703_12_32_08UTC

spanner>
image image

Footnotes

  1. https://cloud.google.com/spanner/docs/release-notes#July_03_2024

@yfuruyama yfuruyama self-requested a review July 4, 2024 03:28
Copy link
Copy Markdown
Collaborator

@yfuruyama yfuruyama left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for supporting this!

@yfuruyama yfuruyama merged commit e1ee214 into cloudspannerecosystem:master Jul 4, 2024
@yfuruyama
Copy link
Copy Markdown
Collaborator

@nktks nktks deleted the add-call branch July 4, 2024 04:25
@nktks
Copy link
Copy Markdown
Contributor Author

nktks commented Jul 4, 2024

Thank you so much!

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.

2 participants