-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [Spanner] update result_set to return undeclared parameters in …
…ExecuteSql API (#5528) * chore(bazel): update gapic-generator-php to v1.6.1 PiperOrigin-RevId: 489247285 Source-Link: googleapis/googleapis@c40ef67 Source-Link: googleapis/googleapis-gen@64e38ac Copy-Tag: eyJwIjoiU3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiNjRlMzhhY2U3NjI5NGYxZDhkNWI0MzVmYTEwYzY3NjVjMmI0NGY0OSJ9 chore(bazel): update gapic-generator-php to v1.6.0 PiperOrigin-RevId: 487322191 Source-Link: googleapis/googleapis@2a470e2 Source-Link: googleapis/googleapis-gen@50976a5 Copy-Tag: eyJwIjoiU3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiNTA5NzZhNTc1OTc3ZmM5MmQxYWE3OTQyOGM3YjMxNjdlMTc2ZGZmZiJ9 feat: Update transaction.proto to include different lock modes PiperOrigin-RevId: 481838475 Source-Link: googleapis/googleapis@922f1f3 Source-Link: googleapis/googleapis-gen@bf32c6e Copy-Tag: eyJwIjoiU3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiYmYzMmM2ZTQxM2Q0ZDdmZDNjOTliNzI1ZmFiNjUzZWI5ODNkOWRkNiJ9 feat: Update result_set.proto to return undeclared parameters in ExecuteSql API PiperOrigin-RevId: 480025979 Source-Link: googleapis/googleapis@cb6fbe8 Source-Link: googleapis/googleapis-gen@bf166b8 Copy-Tag: eyJwIjoiU3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiYmYxNjZiODlkMmE2YWEzNTEwMzc0Mzg3YWYwZjQ1ZTQ4MjhkZWEwMyJ9 chore(bazel): update protobuf to v3.21.7 PiperOrigin-RevId: 477955264 Source-Link: googleapis/googleapis@a724450 Source-Link: googleapis/googleapis-gen@4abcbca Copy-Tag: eyJwIjoiU3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiNGFiY2JjYWVjODU1ZTc0YTBiMjJhNDk4OGNmOWUwZWI2MWE4MzA5NCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore(bazel): update gapic-generator-php to v1.6.2 PiperOrigin-RevId: 493134713 Source-Link: googleapis/googleapis@83d92bd Source-Link: googleapis/googleapis-gen@223117b Copy-Tag: eyJwIjoiU3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiMjIzMTE3YjcyYWYxMmM2YjlhYjYxMWYzMTA3MjljM2EyZjQ5M2YyZiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Add location methods PiperOrigin-RevId: 499263614 Source-Link: googleapis/googleapis@ba2db0d Source-Link: googleapis/googleapis-gen@503d1e8 Copy-Tag: eyJwIjoiU3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiNTAzZDFlOGVmZjA0NTM1ZmM1ZDRiNzRmZTFjODk0ZTY3ZmQ1OTZiMiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore(bazel): update gapic-generator-php to v1.6.4 PiperOrigin-RevId: 499941754 Source-Link: googleapis/googleapis@71b5bbc Source-Link: googleapis/googleapis-gen@113c51b Copy-Tag: eyJwIjoiU3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiMTEzYzUxYjMwM2I0N2ZlODMxNWM1MzYyNjBkYTUwYTkyYzI3N2IzOSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * manual fix for tests --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: David Supplee <2079879+dwsupplee@users.noreply.github.com> Co-authored-by: David Supplee <dsupplee@google.com> Co-authored-by: Brent Shaffer <betterbrent@google.com>
- Loading branch information
1 parent
abdcdcf
commit 3516ed6
Showing
33 changed files
with
1,606 additions
and
417 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
75 changes: 75 additions & 0 deletions
75
Spanner/samples/V1/SpannerClient/batch_create_sessions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START spanner_v1_generated_Spanner_BatchCreateSessions_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Spanner\V1\BatchCreateSessionsResponse; | ||
use Google\Cloud\Spanner\V1\SpannerClient; | ||
|
||
/** | ||
* Creates multiple new sessions. | ||
* | ||
* This API can be used to initialize a session cache on the clients. | ||
* See https://goo.gl/TgSFN2 for best practices on session cache management. | ||
* | ||
* @param string $formattedDatabase The database in which the new sessions are created. Please see | ||
* {@see SpannerClient::databaseName()} for help formatting this field. | ||
* @param int $sessionCount The number of sessions to be created in this batch call. | ||
* The API may return fewer than the requested number of sessions. If a | ||
* specific number of sessions are desired, the client can make additional | ||
* calls to BatchCreateSessions (adjusting | ||
* [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] as necessary). | ||
*/ | ||
function batch_create_sessions_sample(string $formattedDatabase, int $sessionCount): void | ||
{ | ||
// Create a client. | ||
$spannerClient = new SpannerClient(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var BatchCreateSessionsResponse $response */ | ||
$response = $spannerClient->batchCreateSessions($formattedDatabase, $sessionCount); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedDatabase = SpannerClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); | ||
$sessionCount = 0; | ||
|
||
batch_create_sessions_sample($formattedDatabase, $sessionCount); | ||
} | ||
// [END spanner_v1_generated_Spanner_BatchCreateSessions_sync] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START spanner_v1_generated_Spanner_BeginTransaction_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Spanner\V1\SpannerClient; | ||
use Google\Cloud\Spanner\V1\Transaction; | ||
use Google\Cloud\Spanner\V1\TransactionOptions; | ||
|
||
/** | ||
* Begins a new transaction. This step can often be skipped: | ||
* [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and | ||
* [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a | ||
* side-effect. | ||
* | ||
* @param string $formattedSession The session in which the transaction runs. Please see | ||
* {@see SpannerClient::sessionName()} for help formatting this field. | ||
*/ | ||
function begin_transaction_sample(string $formattedSession): void | ||
{ | ||
// Create a client. | ||
$spannerClient = new SpannerClient(); | ||
|
||
// Prepare any non-scalar elements to be passed along with the request. | ||
$options = new TransactionOptions(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var Transaction $response */ | ||
$response = $spannerClient->beginTransaction($formattedSession, $options); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedSession = SpannerClient::sessionName( | ||
'[PROJECT]', | ||
'[INSTANCE]', | ||
'[DATABASE]', | ||
'[SESSION]' | ||
); | ||
|
||
begin_transaction_sample($formattedSession); | ||
} | ||
// [END spanner_v1_generated_Spanner_BeginTransaction_sync] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START spanner_v1_generated_Spanner_Commit_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Spanner\V1\CommitResponse; | ||
use Google\Cloud\Spanner\V1\SpannerClient; | ||
|
||
/** | ||
* Commits a transaction. The request includes the mutations to be | ||
* applied to rows in the database. | ||
* | ||
* `Commit` might return an `ABORTED` error. This can occur at any time; | ||
* commonly, the cause is conflicts with concurrent | ||
* transactions. However, it can also happen for a variety of other | ||
* reasons. If `Commit` returns `ABORTED`, the caller should re-attempt | ||
* the transaction from the beginning, re-using the same session. | ||
* | ||
* On very rare occasions, `Commit` might return `UNKNOWN`. This can happen, | ||
* for example, if the client job experiences a 1+ hour networking failure. | ||
* At that point, Cloud Spanner has lost track of the transaction outcome and | ||
* we recommend that you perform another read from the database to see the | ||
* state of things as they are now. | ||
* | ||
* @param string $formattedSession The session in which the transaction to be committed is running. Please see | ||
* {@see SpannerClient::sessionName()} for help formatting this field. | ||
*/ | ||
function commit_sample(string $formattedSession): void | ||
{ | ||
// Create a client. | ||
$spannerClient = new SpannerClient(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var CommitResponse $response */ | ||
$response = $spannerClient->commit($formattedSession); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedSession = SpannerClient::sessionName( | ||
'[PROJECT]', | ||
'[INSTANCE]', | ||
'[DATABASE]', | ||
'[SESSION]' | ||
); | ||
|
||
commit_sample($formattedSession); | ||
} | ||
// [END spanner_v1_generated_Spanner_Commit_sync] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START spanner_v1_generated_Spanner_CreateSession_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Spanner\V1\Session; | ||
use Google\Cloud\Spanner\V1\SpannerClient; | ||
|
||
/** | ||
* Creates a new session. A session can be used to perform | ||
* transactions that read and/or modify data in a Cloud Spanner database. | ||
* Sessions are meant to be reused for many consecutive | ||
* transactions. | ||
* | ||
* Sessions can only execute one transaction at a time. To execute | ||
* multiple concurrent read-write/write-only transactions, create | ||
* multiple sessions. Note that standalone reads and queries use a | ||
* transaction internally, and count toward the one transaction | ||
* limit. | ||
* | ||
* Active sessions use additional server resources, so it is a good idea to | ||
* delete idle and unneeded sessions. | ||
* Aside from explicit deletes, Cloud Spanner may delete sessions for which no | ||
* operations are sent for more than an hour. If a session is deleted, | ||
* requests to it return `NOT_FOUND`. | ||
* | ||
* Idle sessions can be kept alive by sending a trivial SQL query | ||
* periodically, e.g., `"SELECT 1"`. | ||
* | ||
* @param string $formattedDatabase The database in which the new session is created. Please see | ||
* {@see SpannerClient::databaseName()} for help formatting this field. | ||
*/ | ||
function create_session_sample(string $formattedDatabase): void | ||
{ | ||
// Create a client. | ||
$spannerClient = new SpannerClient(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var Session $response */ | ||
$response = $spannerClient->createSession($formattedDatabase); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedDatabase = SpannerClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); | ||
|
||
create_session_sample($formattedDatabase); | ||
} | ||
// [END spanner_v1_generated_Spanner_CreateSession_sync] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START spanner_v1_generated_Spanner_DeleteSession_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Spanner\V1\SpannerClient; | ||
|
||
/** | ||
* Ends a session, releasing server resources associated with it. This will | ||
* asynchronously trigger cancellation of any operations that are running with | ||
* this session. | ||
* | ||
* @param string $formattedName The name of the session to delete. Please see | ||
* {@see SpannerClient::sessionName()} for help formatting this field. | ||
*/ | ||
function delete_session_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$spannerClient = new SpannerClient(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
$spannerClient->deleteSession($formattedName); | ||
printf('Call completed successfully.' . PHP_EOL); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedName = SpannerClient::sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); | ||
|
||
delete_session_sample($formattedName); | ||
} | ||
// [END spanner_v1_generated_Spanner_DeleteSession_sync] |
Oops, something went wrong.